Added options to make Robodoc more customizable. master
authorPekka Riikonen <priikone@silcnet.org>
Sun, 3 Feb 2008 15:21:27 +0000 (17:21 +0200)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 3 Feb 2008 15:21:27 +0000 (17:21 +0200)
Added --module_index_menu to generate module index menu on a module
page and to generate header index menu on a header page.

Added --document_header option to specify file where to read document
header.

Added --document_footer option to specify file where to read document
footer.

Made other minor modifications mainly to the HTML generator.

Source/generator.c
Source/globals.c
Source/globals.h
Source/html_generator.c
Source/html_generator.h
Source/links.c
Source/optioncheck.c
Source/robodoc.c
Source/robodoc.h

index 491aa223b1b252b0ec634a30f2d1447295b72530..1d7dd41fada3fed46863d562f4918ea5dabefde1 100644 (file)
@@ -999,6 +999,41 @@ void Generate_IndexMenu(
 
 }
 
 
 }
 
+void Generate_Header_IndexMenu(
+    FILE *dest_doc,
+    char *filename,
+    struct RB_Part *owner,
+    struct RB_Document *document )
+{
+    switch ( output_mode )
+    {
+    case HTML:
+        RB_HTML_Generate_Header_IndexMenu( dest_doc, filename,
+                                          document, owner, NULL );
+        break;
+    default:
+        break;
+    }
+
+}
+
+void Generate_Module_IndexMenu(
+    FILE *dest_doc,
+    char *filename,
+    struct RB_Document *document )
+{
+    switch ( output_mode )
+    {
+    case HTML:
+        RB_HTML_Generate_Module_IndexMenu( dest_doc, filename,
+                                          document, NULL );
+        break;
+    default:
+        break;
+    }
+
+}
+
 void Generate_Begin_Extra(
     FILE *dest_doc )
 {
 void Generate_Begin_Extra(
     FILE *dest_doc )
 {
@@ -1043,7 +1078,7 @@ void RB_Generate_Nav_Bar(
     case XMLDOCBOOK:
         break;
     case HTML:
     case XMLDOCBOOK:
         break;
     case HTML:
-        if ( course_of_action.do_one_file_per_header )
+      if ( course_of_action.do_one_file_per_header )
         {
             /* Nothing */
         }
         {
             /* Nothing */
         }
@@ -1145,7 +1180,7 @@ void RB_Name_Headers(
 /****f* Generator/RB_Sort_Items
  * FUNCTION
  *   Sort the items in all the headers according to the order
 /****f* Generator/RB_Sort_Items
  * FUNCTION
  *   Sort the items in all the headers according to the order
- *   specified in the 'item order' block in the robodoc.rc 
+ *   specified in the 'item order' block in the robodoc.rc
  *   file.
  * SYNOPSIS
  */
  *   file.
  * SYNOPSIS
  */
@@ -1390,21 +1425,33 @@ void RB_Generate_MultiDoc(
         if ( i_part->headers == 0 )
             continue;
 
         if ( i_part->headers == 0 )
             continue;
 
-
         if ( output_mode != TROFF )
         {
             document_file = RB_Open_Documentation( i_part );
             RB_Generate_Doc_Start( document,
         if ( output_mode != TROFF )
         {
             document_file = RB_Open_Documentation( i_part );
             RB_Generate_Doc_Start( document,
-                                   document_file, srcname, srcname, 1,
+                                   document_file, srcname,
+                                  i_part->filename->name, 1,
                                    docname, document->charset );
 
             Generate_Begin_Navigation( document_file );
             if ( document->actions.do_one_file_per_header )
             {
                                    docname, document->charset );
 
             Generate_Begin_Navigation( document_file );
             if ( document->actions.do_one_file_per_header )
             {
-                RB_HTML_Generate_Nav_Bar_One_File_Per_Header( document,
-                                                              document_file,
-                                                              i_part->
-                                                              headers );
+               if ( document->actions.do_module_index_menu )
+               {
+                   if ( i_part->headers[0].htype->typeCharacter == 'h' )
+                       Generate_Module_IndexMenu( document_file, docname,
+                                                  document );
+                   else
+                       Generate_Header_IndexMenu( document_file, docname,
+                                                  i_part, document );
+               }
+               else
+               {
+                   RB_HTML_Generate_Nav_Bar_One_File_Per_Header( document,
+                                                                 document_file,
+                                                                 i_part->
+                                                                 headers );
+               }
             }
             else
             {
             }
             else
             {
@@ -1421,6 +1468,17 @@ void RB_Generate_MultiDoc(
                                    i_part, docname );
             }
             RB_Generate_Part( document_file, document, i_part );
                                    i_part, docname );
             }
             RB_Generate_Part( document_file, document, i_part );
+
+           if ( document->actions.do_header_toc && output_mode == HTML )
+             {
+               if ( document->actions.do_one_file_per_header &&
+                    i_part->headers[0].htype->typeCharacter == 'h' )
+                   RB_HTML_Generate_TOC_Entries( document_file,
+                                                 document->headers,
+                                                 document->no_headers,
+                                                 i_part, docname );
+             }
+
             Generate_End_Content( document_file );
 
             RB_Generate_Doc_End( document_file, docname, srcname );
             Generate_End_Content( document_file );
 
             RB_Generate_Doc_End( document_file, docname, srcname );
@@ -1518,6 +1576,16 @@ void RB_Generate_SingleDoc(
         }
     }
 
         }
     }
 
+    if ( document->actions.do_header_toc && output_mode == HTML )
+    {
+        if ( i_part->headers[0].htype->typeCharacter == 'h' )
+           RB_HTML_Generate_TOC_Entries( document_file,
+                                         document->headers,
+                                         document->no_headers,
+                                         i_part,
+                                         document->parts->filename->name );
+    }
+
     RB_Generate_Doc_End( document_file, "singledoc",
                          document->srcroot->name );
     fclose( document_file );
     RB_Generate_Doc_End( document_file, "singledoc",
                          document->srcroot->name );
     fclose( document_file );
@@ -1721,7 +1789,6 @@ void RB_Generate_Part(
         RB_TROFF_Set_Param( document->compress, document->section );
     }
 
         RB_TROFF_Set_Param( document->compress, document->section );
     }
 
-
     for ( i_header = part->headers; i_header; i_header = i_header->next )
     {
         RB_Say( "generating documentation for header \"%s\"\n", SAY_INFO,
     for ( i_header = part->headers; i_header; i_header = i_header->next )
     {
         RB_Say( "generating documentation for header \"%s\"\n", SAY_INFO,
@@ -2487,7 +2554,7 @@ static void Generate_Item_Line(
             {
                 if ( utf8_isspace( c ) )
                 {
             {
                 if ( utf8_isspace( c ) )
                 {
-                    /* We found the end of the string, so we go 
+                    /* We found the end of the string, so we go
                      * back to the space skipping state
                      */
                     state = SKIP_SPACE;
                      * back to the space skipping state
                      */
                     state = SKIP_SPACE;
index 9edb766b0d774935b667ef3d9e1c3b55b7c92cd9..53ed7a3423386d477c98682f24f34260751d88e0 100644 (file)
@@ -49,7 +49,7 @@ char               *current_file = 0;
 
 /****v* Globals/document_title
  * NAME
 
 /****v* Globals/document_title
  * NAME
- *   documentat_title -- title for the documentation.
+ *   document_title -- title for the documentation.
  * PURPOSE
  *   Used as the title for master index files or for latex documentation.
  * SOURCE
  * PURPOSE
  *   Used as the title for master index files or for latex documentation.
  * SOURCE
@@ -60,6 +60,32 @@ char               *document_title = NULL;
 /******/
 
 
 /******/
 
 
+/****v* Globals/document_header
+ * NAME
+ *   document_header -- Header for the documentation.
+ * PURPOSE
+ *   Used as the header of generated files
+ * SOURCE
+ */
+
+char               *document_header = NULL;
+
+/******/
+
+
+/****v* Globals/document_footer
+ * NAME
+ *   document_footer -- Footer for the documentation.
+ * PURPOSE
+ *   Used as the footer of generated files
+ * SOURCE
+ */
+
+char               *document_footer = NULL;
+
+/******/
+
+
 /****v* Globals/output_mode [2.0]
  * NAME
  *   output_mode -- the mode of output
 /****v* Globals/output_mode [2.0]
  * NAME
  *   output_mode -- the mode of output
@@ -152,7 +178,7 @@ int                 line_number = 0;
 /*******/
 
 /*
 /*******/
 
 /*
- * Global variables 
+ * Global variables
  */
 /* TODO  Document these. */
 
  */
 /* TODO  Document these. */
 
index c86e17b066a0db0da5fa291998f8f4470341182a..b5de74a7af206b20027a6709c9a1b903e0ef3a9a 100644 (file)
@@ -57,8 +57,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // Default document title
 #define DEFAULT_DOCTITILE   "API Reference"
 
 // Default document title
 #define DEFAULT_DOCTITILE   "API Reference"
 
-// Document title
+// Document title, header and footer
 extern char        *document_title;
 extern char        *document_title;
+extern char        *document_header;
+extern char        *document_footer;
 
 extern char        *source_file;        /* DCD */
 
 
 extern char        *source_file;        /* DCD */
 
index 145d5e6d2a0178a33de20a10e9300d33adfa471f..e296f21833d2109e87255d4bff74e1fac830ad9b 100644 (file)
@@ -685,6 +685,48 @@ void RB_HTML_Generate_TOC_Section(
 /*******/
 
 
 /*******/
 
 
+void RB_HTML_Generate_TOC_Entries(
+    FILE *dest_doc,
+    struct RB_header **headers,
+    int count,
+    struct RB_Part *owner,
+    char *dest_name )
+{
+  struct RB_header *header;
+  char *object_name, *label_name, *file_name;
+  int i, j;
+
+//  fprintf( dest_doc, "<h3>Table of Contents</h3>\n" );
+  fprintf( dest_doc, "<p class=\"item_name\">TABLE OF CONTENTS</p>\n" );
+  fprintf( dest_doc, "<ul class=\"toc_entries\">\n" );
+
+  for ( i = count - 1; i >= 0; i-- )
+    {
+      header = headers[i];
+
+      if ( header->htype->typeCharacter != 'h' &&
+          !strcmp( owner->filename->name, header->owner->filename->name ) &&
+          Find_Link( header->function_name,
+                     &object_name, &label_name,
+                     &file_name ) )
+       {
+         for ( j = 0; j < header->no_names; j++ )
+           {
+             fprintf( dest_doc, "<li class=\"toc_entries\">" );
+             RB_HTML_Generate_Link( dest_doc,
+                                    dest_name,
+                                    file_name,
+                                    "",
+                                    object_name, 0);
+             fprintf( dest_doc, "</li>\n" );
+           }
+       }
+    }
+
+  fprintf( dest_doc, "</ul>\n" );
+}
+
+
 void RB_HTML_Generate_TOC_2(
     FILE *dest_doc,
     struct RB_header **headers,
 void RB_HTML_Generate_TOC_2(
     FILE *dest_doc,
     struct RB_header **headers,
@@ -939,7 +981,7 @@ void RB_HTML_Generate_Doc_Start(
 /*
  * INPUTS
  *   o dest_doc  --  the output file.
 /*
  * INPUTS
  *   o dest_doc  --  the output file.
- *   o src_name  --  The file or directoryname from which 
+ *   o src_name  --  The file or directoryname from which
  *                   this document is generated.
  *   o name      --  The title for this document
  *   o dest_name --  the name of the output file.
  *                   this document is generated.
  *   o name      --  The title for this document
  *   o dest_name --  the name of the output file.
@@ -1024,16 +1066,21 @@ void RB_HTML_Generate_Doc_Start(
 
 //    HTML_Generate_Div( dest_doc, "container" );
 
 
 //    HTML_Generate_Div( dest_doc, "container" );
 
-    /* Generate document title if available (Thuffir) */
-    HTML_Generate_Div( dest_doc, "logo" );
-    fprintf( dest_doc, "<a name=\"robo_top_of_doc\">" );
-    if ( document_title )
-        RB_HTML_Generate_String( dest_doc, document_title );
-    fprintf( dest_doc, "</a>\n" );
-    HTML_Generate_Div_End( dest_doc, "logo" );
-
-
-
+    /* Use user specified header if present */
+    if ( document_header )
+    {
+        fprintf ( dest_doc, document_header );
+    }
+    else
+    {
+        /* Generate document title if available (Thuffir) */
+        HTML_Generate_Div( dest_doc, "logo" );
+       fprintf( dest_doc, "<a name=\"robo_top_of_doc\">" );
+       if ( document_title )
+            RB_HTML_Generate_String( dest_doc, document_title );
+       fprintf( dest_doc, "</a>\n" );
+       HTML_Generate_Div_End( dest_doc, "logo" );
+    }
 }
 
 /******/
 }
 
 /******/
@@ -1056,26 +1103,35 @@ void RB_HTML_Generate_Doc_End(
 
     USE( name );
 
 
     USE( name );
 
-
-    HTML_Generate_Div( dest_doc, "footer" );
-    /* TODO This should be done with
-     * RB_Generate_Label() 
-     */
-    if ( course_of_action.do_nogenwith )
+    /* Use user specified footer if present */
+    if ( document_footer )
     {
     {
-        fprintf( dest_doc, "<p>Generated from %s on ", src_name );
-        RB_TimeStamp( dest_doc );
-        fprintf( dest_doc, "</p>\n" );
+        fprintf ( dest_doc, document_footer );
     }
     else
     {
     }
     else
     {
-        fprintf( dest_doc,
-                 "<p>Generated from %s with <a href=\"http://www.xs4all.nl/~rfsber/Robo/robodoc.html\">ROBODoc</a> V%s on ",
-                 src_name, VERSION );
-        RB_TimeStamp( dest_doc );
-        fprintf( dest_doc, "</p>\n" );
+      HTML_Generate_Div( dest_doc, "footer" );
+
+        /* TODO This should be done with
+        * RB_Generate_Label()
+        */
+        if ( course_of_action.do_nogenwith )
+       {
+           fprintf( dest_doc, "<p>Generated from %s on ", src_name );
+           RB_TimeStamp( dest_doc );
+           fprintf( dest_doc, "</p>\n" );
+       }
+       else
+       {
+            fprintf( dest_doc,
+                    "<p>Generated from %s with <a href=\"http://www.xs4all.nl/~rfsber/Robo/robodoc.html\">ROBODoc</a> V%s on ",
+                    src_name, VERSION );
+           RB_TimeStamp( dest_doc );
+           fprintf( dest_doc, "</p>\n" );
+       }
+
+       HTML_Generate_Div_End( dest_doc, "footer" );
     }
     }
-    HTML_Generate_Div_End( dest_doc, "footer" );
 
 //    HTML_Generate_Div_End( dest_doc, "container" );
 
 
 //    HTML_Generate_Div_End( dest_doc, "container" );
 
@@ -1206,7 +1262,7 @@ void RB_HTML_Generate_Header_Start(
 
     if ( cur_header->name && cur_header->function_name )
     {
 
     if ( cur_header->name && cur_header->function_name )
     {
-        fprintf( dest_doc, "<hr />\n" );
+/*        fprintf( dest_doc, "<hr />\n" ); */
         RB_HTML_Generate_Label( dest_doc, cur_header->name );
         fprintf( dest_doc, "</a><a name=\"%s\"></a><h2>",
                  cur_header->unique_name );
         RB_HTML_Generate_Label( dest_doc, cur_header->name );
         fprintf( dest_doc, "</a><a name=\"%s\"></a><h2>",
                  cur_header->unique_name );
@@ -1327,6 +1383,110 @@ void RB_HTML_Generate_IndexMenu(
     }
 }
 
     }
 }
 
+/****f* HTML_Generator/RB_HTML_Generate_Header_IndexMenu
+ * FUNCTION
+ *   Generates a menu to jump to the header's entries.  The menu is
+ *   generated for each entry file.
+ * SYNOPSIS
+ */
+void RB_HTML_Generate_Header_IndexMenu(
+    FILE *dest_doc,
+    char *filename,
+    struct RB_Document *document,
+    struct RB_Part *owner,
+    struct RB_HeaderType *cur_type )
+    /* TODO  Use cur_type */
+/*
+ * INPUTS
+ *   * dest_doc       -- the output file.
+ *   * filename       -- the name of the output file
+ *   * document       -- the gathered documention.
+ *   * cur_headertype -- the header type that is to be highlighted.
+ ******
+ */
+{
+    struct RB_header *header;
+    char *object_name, *label_name, *file_name;
+    int i, j;
+
+    for ( i = document->no_headers - 1; i >= 0; i-- )
+    {
+        header = document->headers[i];
+
+       if ( !strcmp( owner->filename->name, header->owner->filename->name ) &&
+            ( header->htype->typeCharacter == 'h' ||
+              Find_Link( header->function_name,
+                         &object_name, &label_name,
+                         &file_name ) ) )
+       {
+           for ( j = 0; j < header->no_names; j++ )
+           {
+               if ( header->htype->typeCharacter == 'h' )
+               {
+                   RB_HTML_Generate_Link( dest_doc,
+                                          filename,
+                                           header->owner->filename->docname,
+                                          NULL,
+                                           header->function_name,
+                                          "menuitem" );
+                   fprintf( dest_doc, "\n" );
+               }
+               else
+               {
+                   RB_HTML_Generate_Link( dest_doc,
+                                          filename,
+                                          file_name,
+                                          "",
+                                          object_name,
+                                          "menuitem" );
+                   fprintf( dest_doc, "\n" );
+               }
+           }
+       }
+    }
+}
+
+/****f* HTML_Generator/RB_HTML_Generate_Module_IndexMenu
+ * FUNCTION
+ *   Generates a menu to jump to the different modules.  The menu is
+ *   generated for each header file.
+ * SYNOPSIS
+ */
+void RB_HTML_Generate_Module_IndexMenu(
+    FILE *dest_doc,
+    char *filename,
+    struct RB_Document *document,
+    struct RB_HeaderType *cur_type )
+    /* TODO  Use cur_type */
+/*
+ * INPUTS
+ *   * dest_doc       -- the output file.
+ *   * filename       -- the name of the output file
+ *   * document       -- the gathered documention.
+ *   * cur_headertype -- the header type that is to be highlighted.
+ ******
+ */
+{
+    struct RB_Part *i_part;
+
+    for ( i_part = document->parts; i_part != NULL; i_part = i_part->next )
+    {
+      if ( !i_part->headers ||
+          i_part->headers[0].htype->typeCharacter != 'h' ||
+          !strcmp(i_part->headers[0].function_name,
+                  "ROBODoc Cascading Style Sheet") )
+           continue;
+        RB_HTML_Generate_Link( dest_doc,
+                              filename,
+                              i_part->filename->docname,
+                              NULL,
+                              i_part->headers[0].function_name,
+                              "menuitem" );
+       fprintf( dest_doc, "\n" );
+    }
+}
+
+
 /****f* HTML_Generator/RB_HTML_Generate_Index_Page
  * FUNCTION
  *   Generate a single file with a index table for headers
 /****f* HTML_Generator/RB_HTML_Generate_Index_Page
  * FUNCTION
  *   Generate a single file with a index table for headers
@@ -1362,7 +1522,7 @@ void RB_HTML_Generate_Index_Page(
     else
     {
         /* File opened, now we generate an index
     else
     {
         /* File opened, now we generate an index
-         * for the specified header type 
+         * for the specified header type
          */
         RB_HTML_Generate_Doc_Start( file,
                                     document->srcroot->name,
          */
         RB_HTML_Generate_Doc_Start( file,
                                     document->srcroot->name,
@@ -1712,21 +1872,26 @@ void RB_HTML_Generate_Link(
     {
         fprintf( cur_doc, "<a " );
     }
     {
         fprintf( cur_doc, "<a " );
     }
-    if ( filename && strcmp( filename, cur_name ) )
+    if ( filename && strcmp( filename, cur_name ) && labelname)
     {
         char               *r = RB_HTML_RelativeAddress( cur_name, filename );
 
         fprintf( cur_doc, "href=\"%s#%s\">", r, labelname );
         RB_HTML_Generate_String( cur_doc, linkname );
         fprintf( cur_doc, "</a>" );
     {
         char               *r = RB_HTML_RelativeAddress( cur_name, filename );
 
         fprintf( cur_doc, "href=\"%s#%s\">", r, labelname );
         RB_HTML_Generate_String( cur_doc, linkname );
         fprintf( cur_doc, "</a>" );
-
     }
     }
-    else
+    else if (labelname)
     {
         fprintf( cur_doc, "href=\"#%s\">", labelname );
         RB_HTML_Generate_String( cur_doc, linkname );
         fprintf( cur_doc, "</a>" );
     }
     {
         fprintf( cur_doc, "href=\"#%s\">", labelname );
         RB_HTML_Generate_String( cur_doc, linkname );
         fprintf( cur_doc, "</a>" );
     }
+    else
+    {
+        fprintf( cur_doc, "href=\"%s\">", filename);
+        RB_HTML_Generate_String( cur_doc, linkname );
+        fprintf( cur_doc, "</a>" );
+    }
 }
 
 /******/
 }
 
 /******/
@@ -1748,7 +1913,7 @@ char               *RB_HTML_RelativeAddress(
  *   The following two
  *     this /sub1/sub2/sub3/f.html
  *     that /sub1/sub2/g.html
  *   The following two
  *     this /sub1/sub2/sub3/f.html
  *     that /sub1/sub2/g.html
- *   result in 
+ *   result in
  *     ../g.html
  *
  *     this /sub1/f.html
  *     ../g.html
  *
  *     this /sub1/f.html
index f9b752e295a14db91023fc44e1c2e4ec0a9f66be..f95f6073d7ebeedf00ab59d8b91250867704e6fb 100644 (file)
@@ -38,6 +38,12 @@ void                RB_HTML_Generate_Item_Begin(
 void                RB_HTML_Generate_Item_End(
     FILE *dest_doc,
     char *name );
 void                RB_HTML_Generate_Item_End(
     FILE *dest_doc,
     char *name );
+void                RB_HTML_Generate_TOC_Entries(
+    FILE *dest_doc,
+    struct RB_header **headers,
+    int count,
+    struct RB_Part *owner,
+    char *dest_name );
 void                RB_HTML_Generate_TOC_2(
     FILE *dest_doc,
     struct RB_header **headers,
 void                RB_HTML_Generate_TOC_2(
     FILE *dest_doc,
     struct RB_header **headers,
@@ -163,5 +169,16 @@ void                RB_HTML_Generate_IndexMenu(
     char *filename,
     struct RB_Document *document,
     struct RB_HeaderType *cur_type );
     char *filename,
     struct RB_Document *document,
     struct RB_HeaderType *cur_type );
+void                RB_HTML_Generate_Header_IndexMenu(
+    FILE *dest_doc,
+    char *filename,
+    struct RB_Document *document,
+    struct RB_Part *owner,
+    struct RB_HeaderType *cur_type );
+void                RB_HTML_Generate_Module_IndexMenu(
+    FILE *dest_doc,
+    char *filename,
+    struct RB_Document *document,
+    struct RB_HeaderType *cur_type );
 
 #endif /* ROBODOC_HTML_GENERATOR_H */
 
 #endif /* ROBODOC_HTML_GENERATOR_H */
index db8b7e3d816d0145d07f51639fb6fbfb1419747a..97ff93fb34dcde7065c2182928bd2314524a4560 100644 (file)
@@ -30,7 +30,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *   In addition to the links derived from the headers links are
  *   also derived from the names of all the sourcefiles.
  * MODIFICATION HISTORY
  *   In addition to the links derived from the headers links are
  *   also derived from the names of all the sourcefiles.
  * MODIFICATION HISTORY
- *   ????-??-??   Frans Slothouber  V1.0 
+ *   ????-??-??   Frans Slothouber  V1.0
  *   2003-02-03   Frans Slothouber  Refactoring
  *******
  * $Header: /cvsroot/robodoc/robo/Source/links.c,v 1.43 2007/07/10 19:13:52 gumpu Exp $
  *   2003-02-03   Frans Slothouber  Refactoring
  *******
  * $Header: /cvsroot/robodoc/robo/Source/links.c,v 1.43 2007/07/10 19:13:52 gumpu Exp $
@@ -99,12 +99,12 @@ char * function_name( char * full_name )
  * SYNOPSIS
  */
 void
  * SYNOPSIS
  */
 void
-RB_CollectLinks( struct RB_Document *document, 
+RB_CollectLinks( struct RB_Document *document,
                  struct RB_header **headers,
                  unsigned long count )
 /*
  * INPUTS
                  struct RB_header **headers,
                  unsigned long count )
 /*
  * INPUTS
- *   * document -- 
+ *   * document --
  *   * headers  -- the array with headers.
  *   * count    -- number of headers in the array
  * OUTPUT
  *   * headers  -- the array with headers.
  *   * count    -- number of headers in the array
  * OUTPUT
@@ -118,7 +118,7 @@ RB_CollectLinks( struct RB_Document *document,
     int  k;
     struct RB_Part     *i_part;
 
     int  k;
     struct RB_Part     *i_part;
 
-    for ( i = j = 0; i < count; ++i ) 
+    for ( i = j = 0; i < count; ++i )
     {
         j += headers[i]->no_names - 1;
     }
     {
         j += headers[i]->no_names - 1;
     }
@@ -131,7 +131,7 @@ RB_CollectLinks( struct RB_Document *document,
     {
         for ( i_part = document->parts; i_part; i_part = i_part->next )
         {
     {
         for ( i_part = document->parts; i_part; i_part = i_part->next )
         {
-            if ( i_part->headers ) 
+            if ( i_part->headers )
             {
                 link_index_size++;
             }
             {
                 link_index_size++;
             }
@@ -155,8 +155,9 @@ RB_CollectLinks( struct RB_Document *document,
         assert( header->file_name );
         for( k = 0; k < header->no_names; j++, k++ )
         {
         assert( header->file_name );
         for( k = 0; k < header->no_names; j++, k++ )
         {
-            link = RB_Alloc_Link( header->unique_name, function_name(header->names[k]),
-                                  header->file_name );
+           link = RB_Alloc_Link( header->unique_name,
+                                 header->function_name,
+                                 header->file_name );
             link->htype = header->htype;
             link->is_internal = header->is_internal;
             link_index[j] = link;
             link->htype = header->htype;
             link->is_internal = header->is_internal;
             link_index[j] = link;
@@ -175,7 +176,7 @@ RB_CollectLinks( struct RB_Document *document,
     {
         for ( i_part = document->parts; i_part; i_part = i_part->next )
         {
     {
         for ( i_part = document->parts; i_part; i_part = i_part->next )
         {
-            if ( i_part->headers ) 
+            if ( i_part->headers )
             {
                 struct RB_link     *link;
 
             {
                 struct RB_link     *link;
 
@@ -273,18 +274,18 @@ int RB_Number_Of_Links( struct RB_HeaderType* header_type, char* file_name, int
  *   Searches for the given word in the list of links and
  *   headers.  There are three passes (or four, when the C option
  *   is selected). Each pass uses a different definition of "word":
  *   Searches for the given word in the list of links and
  *   headers.  There are three passes (or four, when the C option
  *   is selected). Each pass uses a different definition of "word":
- *   o In the first pass it is any thing that ends with a 'space', a '.' 
+ *   o In the first pass it is any thing that ends with a 'space', a '.'
  *     or a ','.
  *   o In the second pass it is any string that consists of alpha
  *     or a ','.
  *   o In the second pass it is any string that consists of alpha
- *     numerics, '_', ':', '.', or '-'.  
- *   o In the third pass (for C) it is any string that consists 
+ *     numerics, '_', ':', '.', or '-'.
+ *   o In the third pass (for C) it is any string that consists
  *     of alpha numerics or '_'.
  * SYNOPSIS
  */
 
 int
  *     of alpha numerics or '_'.
  * SYNOPSIS
  */
 
 int
-Find_Link( char *word_begin, 
-           char **object_name, 
+Find_Link( char *word_begin,
+           char **object_name,
            char **label_name,
            char **file_name )
 /*
            char **label_name,
            char **file_name )
 /*
@@ -335,7 +336,7 @@ Find_Link( char *word_begin,
         case 2:
             {
                 for ( cur_char = word_begin;
         case 2:
             {
                 for ( cur_char = word_begin;
-                      utf8_isalnum( *cur_char ) || ( *cur_char == '_'); 
+                      utf8_isalnum( *cur_char ) || ( *cur_char == '_');
                       cur_char++ );
                 break;
             }
                       cur_char++ );
                 break;
             }
@@ -348,7 +349,7 @@ Find_Link( char *word_begin,
 
         old_char = *cur_char;
         *cur_char = '\0';       /*
 
         old_char = *cur_char;
         *cur_char = '\0';       /*
-                                 * End the word with a '\0' 
+                                 * End the word with a '\0'
                                  */
         if ( strlen( word_begin ) == length )
         {
                                  */
         if ( strlen( word_begin ) == length )
         {
@@ -363,7 +364,7 @@ Find_Link( char *word_begin,
             length = strlen( word_begin );
             /* RB_Say ("Testing (pass %d) \"%s\"\n", SAY_INFO, pass, word_begin); */
             /*
             length = strlen( word_begin );
             /* RB_Say ("Testing (pass %d) \"%s\"\n", SAY_INFO, pass, word_begin); */
             /*
-             * Search case sensitive for a link 
+             * Search case sensitive for a link
              */
             for ( cur_index = 0, low_index = 0, high_index =
                     link_index_size - 1; high_index >= low_index; )
              */
             for ( cur_index = 0, low_index = 0, high_index =
                     link_index_size - 1; high_index >= low_index; )
@@ -394,7 +395,7 @@ Find_Link( char *word_begin,
              * Search case insensitive for a link.
              * But only when the user asks for this.
              */
              * Search case insensitive for a link.
              * But only when the user asks for this.
              */
-            if ( course_of_action.do_ignore_case_when_linking ) 
+            if ( course_of_action.do_ignore_case_when_linking )
             {
 
                 for ( cur_index = 0, low_index = 0, high_index =
             {
 
                 for ( cur_index = 0, low_index = 0, high_index =
@@ -443,7 +444,7 @@ Find_Link( char *word_begin,
  */
 static struct RB_link *
 RB_Alloc_Link( char *label_name, char *object_name, char *file_name )
  */
 static struct RB_link *
 RB_Alloc_Link( char *label_name, char *object_name, char *file_name )
-/* 
+/*
  * INPUTS
  *   char *label_name -- strings to copy into the link
  *   char *file_name
  * INPUTS
  *   char *label_name -- strings to copy into the link
  *   char *file_name
@@ -460,7 +461,6 @@ RB_Alloc_Link( char *label_name, char *object_name, char *file_name )
     struct RB_link     *new_link;
 
     assert( object_name );
     struct RB_link     *new_link;
 
     assert( object_name );
-    assert( label_name );
     assert( file_name );
     RB_Say( "Allocating a link (%s %s %s)\n", SAY_DEBUG, object_name, label_name, file_name );
     new_link = malloc( sizeof( struct RB_link ) );
     assert( file_name );
     RB_Say( "Allocating a link (%s %s %s)\n", SAY_DEBUG, object_name, label_name, file_name );
     new_link = malloc( sizeof( struct RB_link ) );
@@ -468,7 +468,7 @@ RB_Alloc_Link( char *label_name, char *object_name, char *file_name )
 
     new_link->file_name = RB_StrDup( file_name );
     new_link->object_name = RB_StrDup( object_name );
 
     new_link->file_name = RB_StrDup( file_name );
     new_link->object_name = RB_StrDup( object_name );
-    new_link->label_name = RB_StrDup( label_name );
+    new_link->label_name = label_name ? RB_StrDup( label_name ) : NULL;
     return ( new_link );
 }
 
     return ( new_link );
 }
 
@@ -508,4 +508,3 @@ void RB_Free_Link( struct RB_link *arg_link )
 }
 
 /******/
 }
 
 /******/
-
index 60672112f741d27fc2c7a7824122bd7bbbf7b748..6df842de4fbe5909dae93df82855b8af277e0d02 100644 (file)
@@ -48,7 +48,7 @@ void Print_Short_Use(
 
 /****t* UserInterface/Option_Test_Kind
  * FUNCTION
 
 /****t* UserInterface/Option_Test_Kind
  * FUNCTION
- *   Enumeration for the kind of tests that are carried out on the 
+ *   Enumeration for the kind of tests that are carried out on the
  *   options that the user specifies.
  * SOURCE
  */
  *   options that the user specifies.
  * SOURCE
  */
@@ -139,6 +139,8 @@ static char        *ok_options[] = {
     "--singlefile",
     "--multidoc",
     "--one_file_per_header",
     "--singlefile",
     "--multidoc",
     "--one_file_per_header",
+    "--module_index_menu",
+    "--header_toc",
     "--first_section_level",
     "--sections",
     "--internal",
     "--first_section_level",
     "--sections",
     "--internal",
@@ -181,6 +183,8 @@ static char        *ok_options[] = {
     "--masterindex",
     "--sourceindex",
     "--header_breaks",
     "--masterindex",
     "--sourceindex",
     "--header_breaks",
+    "--document_header",
+    "--document_footer",
     ( char * ) NULL
 };
 
     ( char * ) NULL
 };
 
@@ -226,7 +230,7 @@ static void Add_Option_Test(
 static void Add_Option_Name(
     struct RB_Option_Test *option_test,
     char *name )
 static void Add_Option_Name(
     struct RB_Option_Test *option_test,
     char *name )
-/* 
+/*
  * INPUTS
  *   option_test -- the option test
  *   name -- the name of the option
  * INPUTS
  *   option_test -- the option test
  *   name -- the name of the option
@@ -425,7 +429,7 @@ static int Do_Mutual_Exlcude_Test(
 /****f* UserInterface/Do_Option_Tests
  * FUNCTION
  *   Run a series of tests on the options that the user
 /****f* UserInterface/Do_Option_Tests
  * FUNCTION
  *   Run a series of tests on the options that the user
- *   specified.  These tests are specified in 
+ *   specified.  These tests are specified in
  *   option_tests.
  * SYNOPSIS
  */
  *   option_tests.
  * SYNOPSIS
  */
index 2cf53322059b0cc15016a34bd87d861c9ea7de2a..1299b0f58e3495daf8addfa6184fc739010eb654 100644 (file)
@@ -32,7 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *   The whole ROBODoc process consists of three steps: scanning,
  *   analysing, generating.
  *
  *   The whole ROBODoc process consists of three steps: scanning,
  *   analysing, generating.
  *
- *   Scanning 
+ *   Scanning
  *
  *   ROBODoc scans the source directory tree. This collects the names of
  *   all the source files.
  *
  *   ROBODoc scans the source directory tree. This collects the names of
  *   all the source files.
@@ -45,7 +45,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *   Generating
  *
  *   In this step the headers are written to one or more documentation files.
  *   Generating
  *
  *   In this step the headers are written to one or more documentation files.
- *   In addition 
+ *   In addition
  *
  *
  *   The data collected during scanning and analysing is stored in a
  *
  *
  *   The data collected during scanning and analysing is stored in a
@@ -59,14 +59,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *   another RB_Path structure that tells in which directory is a directory
  *   located (of which directory it is a subdirectory).  The only exception
  *   is the root directory.
  *   another RB_Path structure that tells in which directory is a directory
  *   located (of which directory it is a subdirectory).  The only exception
  *   is the root directory.
- *   
+ *
  *   Besides the name of the sourcefile, the RB_Filename also stores the
  *   name of the documentation file.
  *   Besides the name of the sourcefile, the RB_Filename also stores the
  *   name of the documentation file.
- *   
+ *
  *   For each sourcefile there is an RB_Part structure.  It contains a
  *   pointer (filename) to the RB_Filename and a list (headers) of
  *   RB_Header structure containing the headers found in the sourcefile.
  *   For each sourcefile there is an RB_Part structure.  It contains a
  *   pointer (filename) to the RB_Filename and a list (headers) of
  *   RB_Header structure containing the headers found in the sourcefile.
- *   
+ *
  *   Every RB_Header structure contains a pointer (owner) to the RB_Part
  *   structure to which it belongs.  Headers can form a hierarchy that is
  *   used to create sections and subsections in the documentation.  To
  *   Every RB_Header structure contains a pointer (owner) to the RB_Part
  *   structure to which it belongs.  Headers can form a hierarchy that is
  *   used to create sections and subsections in the documentation.  To
@@ -75,25 +75,25 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *   headers, SubModule is the parent of SubSubModule.
  *     ****h* TopModule/SubModule
  *     *
  *   headers, SubModule is the parent of SubSubModule.
  *     ****h* TopModule/SubModule
  *     *
- *     **** 
- *   
+ *     ****
+ *
  *     ****h* SubModule/SubSubModule
  *     *
  *     ****h* SubModule/SubSubModule
  *     *
- *     **** 
- *   
+ *     ****
+ *
  *   In the documentation this creates the sections
  *      1.TopModule
  *      1.1 SubModule
  *      1.1.1 SubSubModule
  *   In the documentation this creates the sections
  *      1.TopModule
  *      1.1 SubModule
  *      1.1.1 SubSubModule
- *   
+ *
  *   The RB_Directory and the linked list of RB_Part structures are
  *   stored in a RB_Document structure.
  *   The RB_Directory and the linked list of RB_Part structures are
  *   stored in a RB_Document structure.
- *   
+ *
  *   During the generation of the documentation ROBODoc tries to create
  *   cross links between the mention of a header's name (an object) and the
  *   documentation generated from that header (the documentation for the
  *   object).
  *   During the generation of the documentation ROBODoc tries to create
  *   cross links between the mention of a header's name (an object) and the
  *   documentation generated from that header (the documentation for the
  *   object).
- *   
+ *
  *   To aid this proces there is an array of RB_link structures.  This
  *   array is sorted for quick searching.  RB_link structures the name
  *   of a header and the name of the label under which the documentation
  *   To aid this proces there is an array of RB_link structures.  This
  *   array is sorted for quick searching.  RB_link structures the name
  *   of a header and the name of the label under which the documentation
@@ -291,8 +291,16 @@ char                use_options3[] =
     "                    Specify the tile and filename for master index page\n"
     "   --sourceindex title,filename\n"
     "                    Specify the tile and filename for source files index page\n"
     "                    Specify the tile and filename for master index page\n"
     "   --sourceindex title,filename\n"
     "                    Specify the tile and filename for source files index page\n"
+    "   --document_header filename\n"
+    "                    Read document header from specified file\n"
+    "   --document_footer filename\n"
+    "                    Read document footer from specified file\n"
     "   --one_file_per_header\n"
     "                    Create a separate documentation file for each header\n"
     "   --one_file_per_header\n"
     "                    Create a separate documentation file for each header\n"
+    "   --module_index_menu\n"
+    "                    Create a module menu when used with --one_file_per_header\n"
+    "   --header_toc\n"
+    "                    Create a header TOC when used with --one_file_per_header\n"
     "   --header_breaks NUMBER\n"
     "                    Insert a linebreak after every NUMBER header names\n"
     "                    (default value: 2, set to zero to disable)\n" "\n";
     "   --header_breaks NUMBER\n"
     "                    Insert a linebreak after every NUMBER header names\n"
     "                    (default value: 2, set to zero to disable)\n" "\n";
@@ -353,13 +361,17 @@ int main(
     struct RB_Directory *srctree = NULL;
     char               *optstr = NULL;
     char               *used_rc_file = NULL;
     struct RB_Directory *srctree = NULL;
     char               *optstr = NULL;
     char               *used_rc_file = NULL;
+    char               *doc_h = NULL;
+    char               *doc_f = NULL;
+    char               buffer[8192];
+    int                r_len;
     long                debug = 0;
 
 /*
    TODO, make setlocale work.
     char * loc;
 
     long                debug = 0;
 
 /*
    TODO, make setlocale work.
     char * loc;
 
-    if ( (loc = getenv("LC_CTYPE") ) != NULL ) 
+    if ( (loc = getenv("LC_CTYPE") ) != NULL )
     {
         printf( ".... %s\n", loc );
         setlocale( LC_ALL, loc);
     {
         printf( ".... %s\n", loc );
         setlocale( LC_ALL, loc);
@@ -429,6 +441,8 @@ int main(
     document->compress = Find_Parameterized_Option( "--compress" );
     document->section = Find_Parameterized_Option( "--mansection" );
     document_title = Find_Parameterized_Option( "--documenttitle" );
     document->compress = Find_Parameterized_Option( "--compress" );
     document->section = Find_Parameterized_Option( "--mansection" );
     document_title = Find_Parameterized_Option( "--documenttitle" );
+    doc_h = Find_Parameterized_Option( "--document_header" );
+    doc_f = Find_Parameterized_Option( "--document_footer" );
     optstr = Find_Parameterized_Option( "--first_section_level" );
     if ( optstr )
     {
     optstr = Find_Parameterized_Option( "--first_section_level" );
     if ( optstr )
     {
@@ -514,6 +528,46 @@ int main(
         return EXIT_FAILURE;
     }
 
         return EXIT_FAILURE;
     }
 
+    /* Open header and footer files */
+    if ( doc_h )
+    {
+        FILE *dh = fopen( doc_h, "r" );
+       if ( !dh )
+       {
+           printf( "Error: '%s' no such file or directory\n", doc_h );
+           Print_Short_Use(  );
+           return EXIT_FAILURE;
+       }
+
+       memset( buffer, 0, sizeof( buffer ) );
+       r_len = fread ( buffer, 1, sizeof( buffer ), dh );
+       if ( r_len > 0 )
+       {
+         document_header = calloc( r_len, sizeof( *document_header ) );
+         memcpy( document_header, buffer, r_len );
+       }
+       fclose( dh );
+    }
+    if ( doc_f )
+    {
+        FILE *df = fopen( doc_f, "r" );
+       if ( !df )
+       {
+           printf( "Error: '%s' no such file or directory\n", doc_f );
+           Print_Short_Use(  );
+           return EXIT_FAILURE;
+       }
+
+       memset( buffer, 0, sizeof( buffer ) );
+       r_len = fread ( buffer, 1, sizeof( buffer ), df );
+       if ( r_len > 0 )
+       {
+         document_footer = calloc( r_len, sizeof( *document_footer ) );
+         memcpy( document_footer, buffer, r_len );
+       }
+       fclose( df );
+    }
+
     /* What mode are we using? */
     if ( Find_Option( "--multidoc" ) )
     {
     /* What mode are we using? */
     if ( Find_Option( "--multidoc" ) )
     {
@@ -789,7 +843,7 @@ static char        *Find_And_Fix_Path(
  *   other function of robodoc that expect a '/'.
  *   So to prevent this we replace all the '\' in a path
  *   with '/'
  *   other function of robodoc that expect a '/'.
  *   So to prevent this we replace all the '\' in a path
  *   with '/'
- *    
+ *
  *   In addition people sometimes add a '/' at the
  *   end of the path. We remove it.
  *
  *   In addition people sometimes add a '/' at the
  *   end of the path. We remove it.
  *
@@ -1132,6 +1186,16 @@ actions_t Find_Actions(
         {
             actions.do_one_file_per_header = TRUE;
         }
         {
             actions.do_one_file_per_header = TRUE;
         }
+        else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
+                                    "--module_index_menu" ) )
+        {
+           actions.do_module_index_menu = TRUE;
+        }
+        else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
+                                    "--header_toc" ) )
+        {
+           actions.do_header_toc = TRUE;
+        }
         else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
                                     "--sections" ) )
         {
         else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
                                     "--sections" ) )
         {
@@ -1368,8 +1432,8 @@ char               *Find_Parameterized_Option(
  *   Search for an option of the form
  *     --a_option_name a_value
  *   in argv.   The function is used to look for the
  *   Search for an option of the form
  *     --a_option_name a_value
  *   in argv.   The function is used to look for the
- *     --rc  
- *   option that can be used to specify an 
+ *     --rc
+ *   option that can be used to specify an
  *   alternate robodoc configuration file.
  * SYNOPSIS
  */
  *   alternate robodoc configuration file.
  * SYNOPSIS
  */
index 086c904820229842e1c645bc6aa3964ab22f9321..573baf5d8f8f1ea0126e37c8beaf586d2cc3aa55 100644 (file)
@@ -66,6 +66,8 @@ typedef struct actions_s
     int                 do_singlefile:1;
     int                 do_one_file_per_header:1;
     int                 do_no_subdirectories:1;
     int                 do_singlefile:1;
     int                 do_one_file_per_header:1;
     int                 do_no_subdirectories:1;
+    int                 do_module_index_menu:1;
+    int                 do_header_toc:1;
 
     // Latex options
     int                 do_altlatex:1;
 
     // Latex options
     int                 do_altlatex:1;
@@ -93,7 +95,7 @@ typedef struct actions_s
  *   Enumeration for the various output formats that are
  *   supported by ROBODoc.
  * NOTES
  *   Enumeration for the various output formats that are
  *   supported by ROBODoc.
  * NOTES
- *   These should be prefixed with RB_ 
+ *   These should be prefixed with RB_
  * SOURCE
  */
 
  * SOURCE
  */
 
@@ -138,4 +140,3 @@ actions_t           No_Actions(
     void );
 
 #endif /* ROBODOC_ROBODOC_H */
     void );
 
 #endif /* ROBODOC_ROBODOC_H */
-