Added cross-reference support for document generator.
[silc.git] / util / robodoc / Source / generator.c
index 9e3d5825f8bc03283ae844bf3ace0a713e5093cc..e057f077cab913bd71e92a5b99bb5265470cba9a 100644 (file)
@@ -64,7 +64,7 @@ RB_Generate_Documentation (
 
       if (output_mode == HTML)
         {
-          sprintf(fname, "%s_%s.html", doc_base, cur_header->function_name);
+          sprintf(fname, "%s-%s.html", doc_base, cur_header->function_name);
           dest_doc = fopen(fname, "w");
           if (!dest_doc)
             {
@@ -73,7 +73,7 @@ RB_Generate_Documentation (
            }
         }
 
-      RB_Generate_Header_Start (dest_doc, cur_header);
+      RB_Generate_Header_Start (dest_doc, cur_header, src_name);
 
       next_line = cur_header->contents;
       item_type = RB_Find_Item (&next_line, &item_line);
@@ -268,11 +268,11 @@ RB_Generate_Doc_Start (
 #if 0
          fprintf (dest_doc,
                   "<H3 ALIGN=\"center\">TABLE OF CONTENTS</H3>\n");
-#endif
          fprintf (dest_doc, "<OL>\n");
+#endif
 
          /* Generate quick index file, for fast referencing */
-         sprintf(iname, "%s_index.tmpl", doc_base);
+         sprintf(iname, "%s-index.tmpl", doc_base);
           index = fopen(iname, "w");
           if (!index)
            {
@@ -286,7 +286,7 @@ RB_Generate_Doc_Start (
            {
              char fname[256];
 
-             sprintf(fname, "%s_%s.html", doc_base
+             sprintf(fname, "%s-%s.html", RB_FilePart(doc_base)
                      cur_header->function_name);
 
              if (cur_header->name && cur_header->function_name)
@@ -296,7 +296,8 @@ RB_Generate_Doc_Start (
                      int item_type;
                      char *next_line, *item_line = NULL;
                    
-                     RB_Generate_Header_Start (dest_doc, cur_header);
+                     RB_Generate_Header_Start (dest_doc, cur_header, 
+                                               src_name);
 
                      next_line = cur_header->contents;
                      item_type = RB_Find_Item (&next_line, &item_line);
@@ -335,7 +336,7 @@ RB_Generate_Doc_Start (
 
                      if (index)
                        {
-                         fprintf (index, " >> <A HREF=\"%s\">%s</A><BR>\n",
+                         fprintf (index, "<A HREF=\"%s\"><IMG SRC=\"index_pic.gif\" BORDER=\"0\" ALT=\"\">%s</A><BR>\n",
                                   name, cur_header->function_name);
                        }
 
@@ -344,15 +345,17 @@ RB_Generate_Doc_Start (
                  else
                    {
                      fprintf (dest_doc, "<LI><A HREF=\"%s\">%s</A>\n",
-                              fname, cur_header->name);
+                              fname, cur_header->function_name);
                      if (index)
-                       fprintf (index, " >> <A HREF=\"%s\">%s</A><BR>\n",
+                       fprintf (index, "<A HREF=\"%s\"><IMG SRC=\"index_pic.gif\" BORDER=\"0\" ALT=\"\">%s</A><BR>\n",
                                 fname, cur_header->function_name);
                    }
                }
            }
 
+#if 0
          fprintf (dest_doc, "</OL>\n");
+#endif
 
          if (index)
            fclose(index);
@@ -546,7 +549,8 @@ RB_Generate_Doc_End (FILE * dest_doc, char *name)
  */
 
 void
-RB_Generate_Header_Start (FILE * dest_doc, struct RB_header *cur_header)
+RB_Generate_Header_Start (FILE * dest_doc, struct RB_header *cur_header,
+                         const char *src_name)
 {
   char *cook_link;
 
@@ -572,28 +576,35 @@ RB_Generate_Header_Start (FILE * dest_doc, struct RB_header *cur_header)
 #endif
          if (cur_header->type == FUNCTION_HEADER)
            fprintf (dest_doc, 
-                    "\n<FONT SIZE=\"+3\" COLOR=\"#000044\"><B>"
+                    "\n<FONT SIZE=\"+2\" COLOR=\"#000055\"><B>"
                     "Function <A NAME=\"%s\">%s</A>"
                     "</FONT></B><BR><BR>\n\n",
                     cur_header->function_name,
                     cur_header->function_name);
          else if (cur_header->type == STRUCT_HEADER)
            fprintf (dest_doc, 
-                    "\n<FONT SIZE=\"+3\" COLOR=\"#000044\"><B>"
+                    "\n<FONT SIZE=\"+2\" COLOR=\"#000055\"><B>"
                     "Structure <A NAME=\"%s\">%s</A>"
                     "</FONT></B><BR><BR>\n\n",
                     cur_header->function_name,
                     cur_header->function_name);
          else if (cur_header->type == VARIABLE_HEADER)
            fprintf (dest_doc, 
-                    "\n<FONT SIZE=\"+3\" COLOR=\"#000044\"><B>"
+                    "\n<FONT SIZE=\"+2\" COLOR=\"#000055\"><B>"
                     "Variable <A NAME=\"%s\">%s</A>"
                     "</FONT></B><BR><BR>\n\n",
                     cur_header->function_name,
                     cur_header->function_name);
+         else if (cur_header->type == MAIN_HEADER)
+           fprintf (dest_doc, 
+                    "\n<FONT SIZE=\"+2\" COLOR=\"#000055\"><B>"
+                    "<A NAME=\"%s\">%s</A>"
+                    "</FONT></B><BR><SMALL>Header: %s</SMALL><BR><BR>\n\n",
+                    cur_header->function_name,
+                    cur_header->function_name, src_name);
          else
            fprintf (dest_doc, 
-                    "\n<FONT SIZE=\"+3\" COLOR=\"#000044\"><B>"
+                    "\n<FONT SIZE=\"+2\" COLOR=\"#000055\"><B>"
                     "<A NAME=\"%s\">%s</A>"
                     "</FONT></B><BR><BR>\n\n",
                     cur_header->function_name,
@@ -744,7 +755,7 @@ RB_Generate_Item_Name (FILE * dest_doc, int item_type)
       fprintf (dest_doc, format_str,
               att_start_command[MAKE_BOLD][output_mode]);
       if (output_mode == HTML)
-       fprintf (dest_doc, "\n<FONT COLOR=\"#000044\">");
+       fprintf (dest_doc, "\n<FONT COLOR=\"#000055\">");
       fprintf (dest_doc, format_str, item_names[item_type]);
       if (output_mode == HTML)
        fprintf (dest_doc, "\n</FONT>");
@@ -840,6 +851,9 @@ RB_Generate_Item_Doc (FILE * dest_doc, char *dest_name,
   if (item_attributes[item_type] & TEXT_BODY_SHINE)
     fprintf (dest_doc, format_str,
             att_start_command[MAKE_SHINE][output_mode]);
+  if (item_attributes[item_type] & TEXT_BODY_DEFAULT)
+    fprintf (dest_doc, format_str,
+            att_start_command[MAKE_DEFAULT][output_mode]);
 
   /* 
    * For some modes, the text body is always non-prop
@@ -893,6 +907,9 @@ RB_Generate_Item_Doc (FILE * dest_doc, char *dest_name,
   if (item_attributes[item_type] & TEXT_BODY_LARGE_FONT)
     fprintf (dest_doc, format_str,
             att_stop_command[MAKE_LARGE][output_mode]);
+  if (item_attributes[item_type] & TEXT_BODY_DEFAULT)
+    fprintf (dest_doc, format_str,
+            att_stop_command[MAKE_DEFAULT][output_mode]);
 
   if (output_mode != HTML)
     {
@@ -1265,8 +1282,13 @@ RB_Generate_Item_Body (FILE * dest_doc, char *dest_name,
                    }
                  else if (file_name && strcmp (file_name, dest_name))
                    {
+#if 0
                      fprintf (dest_doc, "<A HREF=\"%s#%s\">%s</A>",
                               file_name, label_name, label_name);
+#endif
+                     fprintf (dest_doc, "<A HREF=\"%s-%s.html\">%s</A>",
+                              RB_FilePartStart(file_name), label_name, 
+                              label_name);
                    }
                  else
                    {
@@ -1276,8 +1298,9 @@ RB_Generate_Item_Body (FILE * dest_doc, char *dest_name,
                          fprintf (dest_doc, "<A HREF=\"#%s\">%s</A>",
                                   label_name, label_name);
 #endif
-                         fprintf (dest_doc, "<A HREF=\"%s_%s.html\">%s</A>",
-                                  doc_base, label_name, label_name);
+                         fprintf (dest_doc, "<A HREF=\"%s-%s.html\">%s</A>",
+                                  RB_FilePart(doc_base), label_name, 
+                                              label_name);
                        }
                      else
                        {