Menu

New Robodoc Features...

Thuffir
2006-05-05
2013-04-23
  • Thuffir

    Thuffir - 2006-05-05

    (Sorry for double posting this mail, but I have just noticed that the mailing list has removed my diff attachment..)

    Dear Robodoc Maintainers!

    As I recently promised to Petteri, I made a little patch for robodoc which could be useful for everyone (tell me if I am wrong).
    Basically it is the same patch I posted before, with some cosmetic and parametric changes.
    All features are tested with html and latex mode only!

    The main features are:

    --documenttitle  option to set the document title (now displayed in html and latex mode)
    --headertypes    option to display the header types in sectioning mode (html / latex only)
    --htmlheaderleft option to make the html headers left aligned (and the [header type] after the module/function)
    --altlatex       option for an alternate latex output (looks better with pdflatex and makes the document more clear) (for me :)
    - enabling DO_SECTIONNAMEONLY code in LaTeX output from FHA

    Minor bugfixes:
    - removing links in LaTeX \verbatim sections
    - minor fix in troff_generator.c to make robodoc compile with -D_XCOMPILE_MINGW

    Cheers
    Thuffir

    PS: Any critics are welcome!

    ----------------------------------------------------------------------------------------------
    Only in robodoc-4.99.21/Source: config.h
    diff -ru robodoc-4.99.21/Source/generator.c robodoc-4.99.21+THU/Source/generator.c
    --- robodoc-4.99.21/Source/generator.c    2005-12-15 21:29:38.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/generator.c    2006-05-04 14:14:32.070625000 +0200
    @@ -902,6 +902,41 @@
    /*********/

    +/****f* Generator/Generate_Header_Type
    + * NAME
    + *   Generate_Header_Type
    + * FUNCTION
    + *   Generates header type entry in sectioning mode
    + * INPUTS
    + *   o FILE* dest_doc      -- destination file
    + *   o char *name          -- the type of item
    + * AUTHOR
    + *   Thuffir
    + * TODO
    + *   Implement all document types...
    + * SOURCE
    + */
    +void
    +Generate_Header_Type( FILE * dest_doc, char *name )
    +{
    +    // Only generate Header Type entries if requested
    +    if ( !(course_of_action & DO_HEADERTYPES) )
    +        return;
    +
    +    switch ( output_mode )
    +    {
    +    case HTML:
    +        RB_HTML_Generate_Header_Type( dest_doc, name );
    +        break;
    +    case LATEX:
    +        RB_LaTeX_Generate_Header_Type( dest_doc, name );
    +        break;
    +    case UNKNOWN:
    +    default:
    +        assert( 0 );
    +    }
    +}
    +/*********/

    @@ -1318,6 +1353,7 @@

         RB_Generate_Nav_Bar( document, document_file, parent );
         RB_Generate_Index_Entry( document_file, document->doctype, parent );
    +    Generate_Header_Type( document_file, parent->htype->indexName );
         Generate_Header( document_file, document, parent, "dummy", "dummy" );
         for ( i = 0; i < document->no_headers; ++i )
         {
    diff -ru robodoc-4.99.21/Source/html_generator.c robodoc-4.99.21+THU/Source/html_generator.c
    --- robodoc-4.99.21/Source/html_generator.c    2005-12-15 21:29:38.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/html_generator.c    2006-05-04 14:15:13.664375000 +0200
    @@ -717,6 +717,12 @@
         }

    +    /* Generate document title if available (Thuffir) */
    +    fprintf( dest_doc, "<a name=\&quot;robo_top_of_doc\&quot;><h1>" );
    +    if ( document_title )
    +        RB_HTML_Generate_String( dest_doc, document_title );
    +    fprintf( dest_doc, "</h1></a>\n" );
    +
         /* handle folds bit differently */
         if ( ( extra_flags & FOLD ) && RB_Inside_Fold(  ) )
         {
    @@ -744,13 +750,15 @@
              */
             if ( course_of_action & DO_NOGENWITH )
             {
    -
    +            fprintf( dest_doc, "Generated from %s on ",src_name );
    +            RB_TimeStamp( dest_doc );
    +            fprintf( dest_doc, "<hr />\n" );
             }
             else
             {
                 fprintf( dest_doc,
    -                     "<a name=\&quot;%s\&quot;>Generated from %s</a> with <a href=\&quot;http://sourceforge.net/projects/robodoc/\&quot;>ROBODoc</a> v%s on ",
    -                     "robo_top_of_doc", src_name, VERSION );
    +                     "Generated from %s with <a href=\&quot;http://sourceforge.net/projects/robodoc/\&quot;>ROBODoc</a> v%s on ",
    +                     src_name, VERSION );
                 RB_TimeStamp( dest_doc );
                 fprintf( dest_doc, "<br />\n" );
             }
    @@ -842,13 +850,15 @@
             fprintf( dest_doc, "<hr />\n" );
             fprintf( dest_doc, "\n<h2><a name=\&quot;%s\&quot;>", cur_header->unique_name );

    -         header_type = RB_FindHeaderType( cur_header->htype->typeCharacter );
    -         if ( header_type )
    -         {
    -             fprintf( dest_doc, "[" );
    -             RB_HTML_Generate_String( dest_doc, header_type->indexName );
    -             fprintf( dest_doc, "]" );
    -         }
    +        header_type = RB_FindHeaderType( cur_header->htype->typeCharacter );
    +
    +        // If right justified headers, first headertype
    +        if ( header_type && !(course_of_action & DO_HEADERLEFT) )
    +        {
    +            fprintf( dest_doc, "[" );
    +            RB_HTML_Generate_String( dest_doc, header_type->indexName );
    +            fprintf( dest_doc, "]" );
    +        }

             RB_HTML_Generate_Label( dest_doc, cur_header->name );
             for( i = 1; i <= cur_header->no_names; i ++ )
    @@ -857,6 +867,15 @@
                 if( i < cur_header->no_names )
                     fprintf( dest_doc, i % 2 ? ", " : ",<br />" );
             }
    +
    +        // On left justified headers, headertype at the end
    +        if ( header_type && (course_of_action & DO_HEADERLEFT) )
    +        {
    +            fprintf( dest_doc, " [" );
    +            RB_HTML_Generate_String( dest_doc, header_type->indexName );
    +            fprintf( dest_doc, "]" );
    +        }
    +
             fprintf( dest_doc, "</a></h2>\n\n" );
         }
    }
    @@ -1556,7 +1575,7 @@
             css_file = fopen( css_name, "w" );
             if ( css_file )
             {
    -            fprintf( css_file, "%s",
    +            fprintf( css_file,
                         "body\n"
                         "{\n"
                         "    background-color: #ffffff;\n"
    @@ -1571,7 +1590,7 @@
                         "{\n"
                         "    background-color: #dddddd;\n"
                         "    color: #000000;\n"
    -                    "    text-align: right;\n"
    +                    "    text-align: %s;\n"
                         "    font-size: 11pt;\n"
                         "}\n"
                         "td.even, td.uneven\n"
    @@ -1592,7 +1611,9 @@
                         "    background-color: #ffffff;\n"
                         "    color: #000000;\n"
                         "    font-size: 10pt;\n"
    -                    "}\n" );
    +                    "}\n",
    +                    // check if header left or right justified (Thuffir)
    +                    ( course_of_action & DO_HEADERLEFT ) ? ("left") : ("right") );
                 fclose( css_file );
             }
             else
    @@ -1666,9 +1687,22 @@
         fprintf( dest_doc, "</li>\n" );
    }

    -
    -
    -
    -
    -
    -
    +/****f* HTML_Generator/RB_HTML_Generate_Header_Type
    + * NAME
    + *   RB_HTML_Generate_Header_Type
    + * FUNCTION
    + *   Generates header type entry in sectioning mode
    + * INPUTS
    + *   o FILE* dest_doc      -- destination file
    + *   o char *name          -- the type of item
    + * AUTHOR
    + *   Thuffir
    + * SOURCE
    + */
    +void RB_HTML_Generate_Header_Type( FILE *dest_doc, char *name )
    +{
    +    fprintf( dest_doc, "<p><strong>[");
    +    RB_HTML_Generate_String( dest_doc, name );
    +    fprintf( dest_doc, "]</strong></p>\n");
    +}
    +/*******/
    diff -ru robodoc-4.99.21/Source/html_generator.h robodoc-4.99.21+THU/Source/html_generator.h
    --- robodoc-4.99.21/Source/html_generator.h    2005-12-15 21:29:46.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/html_generator.h    2006-05-04 10:20:16.336250000 +0200
    @@ -68,4 +68,6 @@
    void HTML_Generate_Begin_List_Item( FILE* dest_doc );
    void HTML_Generate_End_List_Item( FILE* dest_doc );

    +void RB_HTML_Generate_Header_Type( FILE *dest_doc, char *name );
    +
    #endif /* ROBODOC_HTML_GENERATOR_H */
    diff -ru robodoc-4.99.21/Source/latex_generator.c robodoc-4.99.21+THU/Source/latex_generator.c
    --- robodoc-4.99.21/Source/latex_generator.c    2005-12-15 21:29:38.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/latex_generator.c    2006-05-04 14:11:48.617500000 +0200
    @@ -79,13 +79,22 @@
    {
         fprintf( dest_doc, "\\textbf{" );   
         RB_LaTeX_Generate_String( dest_doc, name );
    -    fprintf( dest_doc, ":}\\hspace{0.08in}" );
    +
    +    // In alternate format, item names stand alone (Thuffir)
    +    if ( course_of_action & DO_ALTLATEX )
    +        fprintf( dest_doc, "}\n" );
    +    else
    +        fprintf( dest_doc, ":}\\hspace{0.08in}" );
    }

    void
    RB_LaTeX_Generate_BeginSection( FILE * dest_doc, int depth, char *name )
    {
    +    // Generate a new page for every section in alternate format
    +    if ( course_of_action & DO_ALTLATEX )
    +        fprintf( dest_doc, "\\newpage\n" );
    +
         switch ( depth )
         {
             case 1:
    @@ -103,18 +112,19 @@
                 /* Too deep so just make it a subsubsection */
                 fprintf( dest_doc, "\\subsubsection{" );
         }
    -    //v FHA_2005_12_01 not sure if this is ok
    -    //    if ( course_of_action & DO_SECTIONNAMEONLY )
    -    //    {
    -    //        char*    cp;
    -    //        if ( ( cp = strrchr(name, '/') ) != NULL )
    -    //            RB_LaTeX_Generate_String( dest_doc, cp+1 );
    -    //    }
    -    //    else
    -    //    {
    -    //^ FHA_2005_12_01
    -    RB_LaTeX_Generate_String( dest_doc, name );
    -    //    }
    +
    +    // FHA_2005_12_01
    +    // If only section names are requested, strip module names
    +    if ( course_of_action & DO_SECTIONNAMEONLY )
    +    {
    +        char* cp;
    +            if ( ( cp = strrchr(name, '/') ) != NULL )
    +                RB_LaTeX_Generate_String( dest_doc, cp+1 );
    +    }
    +    else
    +    {
    +        RB_LaTeX_Generate_String( dest_doc, name );
    +    }

         fprintf( dest_doc, "}\n" );
    }
    @@ -165,13 +175,31 @@
         {
             fprintf( dest_doc, "\\documentclass{article}\n" );
             fprintf( dest_doc, "\\usepackage{makeidx}\n" );
    -        fprintf( dest_doc, "\\oddsidemargin  0.15 in\n" );
    -        fprintf( dest_doc, "\\evensidemargin 0.35 in\n" );
    -        fprintf( dest_doc, "\\marginparwidth 1 in   \n" );
    -        fprintf( dest_doc, "\\oddsidemargin 0.25 in \n" );
    -        fprintf( dest_doc, "\\evensidemargin 0.25 in\n" );
    -        fprintf( dest_doc, "\\marginparwidth 0.75 in\n" );
    -        fprintf( dest_doc, "\\textwidth 5.875 in\n" );
    +
    +        // Alternate mode, works better with pdflatex and DIN A4 sheets
    +        // At least for me :) (Thuffir)
    +        if ( course_of_action & DO_ALTLATEX )
    +        {
    +            fprintf( dest_doc, "\\oddsidemargin 0 cm\n" );
    +            fprintf( dest_doc, "\\evensidemargin 0 cm\n" );
    +            fprintf( dest_doc, "\\topmargin 0 cm\n" );
    +            fprintf( dest_doc, "\\textwidth 16 cm\n" );
    +            fprintf( dest_doc, "\\textheight 22 cm\n" );
    +        }
    +        else
    +        {
    +            /* I guess this is unecessarry (same definitions twice ?)
    +            fprintf( dest_doc, "\\oddsidemargin  0.15 in\n" );
    +            fprintf( dest_doc, "\\evensidemargin 0.35 in\n" );
    +            fprintf( dest_doc, "\\marginparwidth 1 in   \n" );
    +            */
    +
    +            fprintf( dest_doc, "\\oddsidemargin 0.25 in \n" );
    +            fprintf( dest_doc, "\\evensidemargin 0.25 in\n" );
    +            fprintf( dest_doc, "\\marginparwidth 0.75 in\n" );
    +            fprintf( dest_doc, "\\textwidth 5.875 in\n" );
    +        }
    +

             fprintf( dest_doc, "\\setlength{\\parindent}{0in}\n" );
             fprintf( dest_doc, "\\setlength{\\parskip}{.08in}\n\n" );
    @@ -204,7 +232,12 @@
             /* autogenerate table of contents! */
             fprintf( dest_doc, "\\printindex\n" );
             fprintf( dest_doc, "\\tableofcontents\n" );
    -        fprintf( dest_doc, "\\newpage\n" );
    +
    +        // We don't need this in alternate format, since every section begins
    +        // with a \newpage (Thuffir)
    +        if ( !(course_of_action & DO_ALTLATEX) )
    +            fprintf( dest_doc, "\\newpage\n" );
    +
             /* trick to disable the autogenerated \newpage */
             fprintf( dest_doc, "\n" );
         }
    @@ -558,6 +591,31 @@
    RB_LaTeX_Generate_Link( FILE * cur_doc, char *cur_name, char *filename,
                            char *labelname, char *linkname, int in_fold )
    {
    +    // Only generate links outside the verbatim sections
    +    // LaTeX does not seem to recognise them inside (Thuffir)
    +    if (verbatim == FALSE)
             fprintf( cur_doc, " (\\ref{ch:%s})", labelname );
    }
    /******/
    +
    +
    +/****f* LaTeX_Generator/RB_LaTeX_Generate_Header_Type
    + * NAME
    + *   RB_LaTeX_Generate_Header_Type --
    + * FUNCTION
    + *   Generate Header Type entry
    + * INPUTS
    + *   dest_doc  --  the file to which the text is written
    + *   name      --  the type of header
    + * AUTHOR
    + *   Thuffir
    + * SOURCE
    + */
    +void
    +RB_LaTeX_Generate_Header_Type( FILE *dest_doc, char *name )
    +{
    +    fprintf( dest_doc, "\\textsl{[" );   
    +    RB_LaTeX_Generate_String( dest_doc, name );
    +    fprintf( dest_doc, "]}\n\n" );
    +}
    +/******/
    diff -ru robodoc-4.99.21/Source/latex_generator.h robodoc-4.99.21+THU/Source/latex_generator.h
    --- robodoc-4.99.21/Source/latex_generator.h    2005-12-15 21:29:46.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/latex_generator.h    2006-05-02 21:37:38.000000000 +0200
    @@ -59,5 +59,6 @@
    RB_LaTeX_Generate_Link( FILE * cur_doc, char *cur_name, char *filename,
                            char *labelname, char *linkname, int in_fold );

    +void RB_LaTeX_Generate_Header_Type( FILE *dest_doc, char *name );

    #endif /* ROBODOC_LATEX_GENERATOR_H */
    Only in robodoc-4.99.21+THU/Source: makefile
    Only in robodoc-4.99.21/Source: makefile.in
    diff -ru robodoc-4.99.21/Source/robodoc.c robodoc-4.99.21+THU/Source/robodoc.c
    --- robodoc-4.99.21/Source/robodoc.c    2005-12-15 23:11:46.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/robodoc.c    2006-05-04 11:53:51.273750000 +0200
    @@ -221,7 +221,12 @@
         "   --sectionnameonly Generate section header with name only.\n"
         "   --compress       Only supported by TROFF output format. Defines by which\n"
         "                    program manpages will be compressed. Either bzip2 or gzip.\n"
    -    "   --mansection     Manual section where pages will be inserted (default: 3).\n";
    +    "   --mansection     Manual section where pages will be inserted (default: 3).\n"
    +    "   --documenttitle TITLE\n"
    +    "                    Set the document title\n"
    +    "   --headertypes    Print header types in sectioning mode (html/latex only)\n"
    +    "   --htmlheaderleft Use left aligned headers in html mode\n"
    +    "   --altlatex       Alternate LaTeX file format (bigger / clearer than normal)\n";
    char                use_authors[] =
         "Authors/Contributors: Frans Slothouber, Jacco van Weert,\n"
         " Petteri Kettunen, Bernd Koesling, Thomas Aglassinger, Anthon Pang,\n"
    @@ -292,6 +297,10 @@
         "--mansection",
         "--verbal",   /*FS TODO */
         "--ms_errors",
    +    "--headertypes",
    +    "--documenttitle",
    +    "--htmlheaderleft",
    +    "--altlatex",
         ( char * ) NULL
    };

    @@ -385,6 +394,7 @@
         document->css       = Find_Parameterized_Option( "--css" );
         document->compress  = Find_Parameterized_Option( "--compress" );
         document->section   = Find_Parameterized_Option( "--mansection" );
    +    document_title      = Find_Parameterized_Option( "--documenttitle" );
         course_of_action = document->actions; /* a global */
         debugmode = document->debugmode; /* a global */

    @@ -1052,6 +1062,21 @@
             {
                 actions |= DO_SECTIONNAMEONLY;
             }
    +        else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
    +                                    "--headertypes" ) )
    +        {
    +            actions |= DO_HEADERTYPES;
    +        }
    +        else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
    +                                    "--htmlheaderleft" ) )
    +        {
    +            actions |= DO_HEADERLEFT;
    +        }
    +        else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
    +                                    "--altlatex" ) )
    +        {
    +            actions |= DO_ALTLATEX;
    +        }
             else
             {
                 /* Not an action */
    diff -ru robodoc-4.99.21/Source/robodoc.h robodoc-4.99.21+THU/Source/robodoc.h
    --- robodoc-4.99.21/Source/robodoc.h    2005-12-15 21:29:46.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/robodoc.h    2006-05-04 11:20:39.258125000 +0200
    @@ -27,7 +27,7 @@
    #endif

    #ifndef VERSION
    -#define VERSION "4.99.21"
    +#define VERSION "4.99.21+THU"
    #endif

    #define COMMENT_ROBODOC \ @@ -61,6 +61,9 @@
    #define DO_SECTIONNAMEONLY  (1<<23)
    #define DO_VERBAL           (1<<24)
    #define DO_MS_ERRORS        (1<<25)
    +#define DO_HEADERTYPES      (1<<26)
    +#define DO_HEADERLEFT       (1<<27)
    +#define DO_ALTLATEX         (1<<28)

    /* RB_Say modes */
    #define SAY_DEBUG            (1<<0)
    Only in robodoc-4.99.21+THU/Source: robodoc.wsp
    diff -ru robodoc-4.99.21/Source/troff_generator.c robodoc-4.99.21+THU/Source/troff_generator.c
    --- robodoc-4.99.21/Source/troff_generator.c    2005-12-15 21:29:38.000000000 +0100
    +++ robodoc-4.99.21+THU/Source/troff_generator.c    2006-04-28 12:08:31.000000000 +0200
    @@ -9,6 +9,8 @@

    #if defined (RB_MSVC) || defined(_XCOMPILE_MINGW)

    +#include "items.h"
    +
    char*
    RB_TROFF_Get_Default_Extension( void )
    {
    ----------------------------------------------------------------------------------------------

     
    • Thuffir

      Thuffir - 2006-05-05

      Hm... As I see this forum removes embedded spaces so it is not the best way to contribute patches. Anyways if someone interested I can mail the patch.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.