Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I am writing a script to convert my source code of old projects to doxygen format and then use doxygen to create documentation of those projects. So far i ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2006
    Posts
    2

    Adding Doxygen tags to source with a perl script


    Hi,

    I am writing a script to convert my source code of old projects to doxygen format and then use doxygen to create documentation of those projects. So far i have converted my functions headers to doxygen with following commands

    sed -i -e 's/^\*/ /g' *.c
    sed -i -e 's/^\/\*[\*]*/\/\** /g' *.c
    sed -i -e 's/\(FUNCTION\|DESCRIPTION\|INPUTS\|OUTPUTS\|DATA STRUCTURES\|FILE NAME\|COMPONENT\|FUNCTIONS\|DEPENDENCIES\)/\\par &/g' *.c

    sed -i -e '1 s/*/&****/g' *.c
    sed -i -e '/INPUTS/ a\ \\code' *.c
    sed -i -e '/OUTPUTS/ i\ \\endcode' *.c
    sed -i -e '/OUTPUTS/ a\ \\code' *.c
    sed -i -e '/OUTPUTS/,/\*\// s/^ [\*]*\// \\endcode \n&/g' *.c

    these commands convert my function header from


    /************************************************** ***********************
    *
    * FUNCTION
    *
    * Factorial
    *
    * DESCRIPTION
    *
    * This Factorial function calculates the factorial of a number.
    *
    * INPUTS
    *
    * number number for which the factorial is to be calculated.
    *
    * OUTPUTS
    *
    * factorial value factorial of the input number.
    * NVALID_PARM Invalid value of a parameter was
    * passed in to the function.
    *
    ************************************************** ***********************/

    TO

    /**

    \par FUNCTION

    DOT1X_Init

    \par DESCRIPTION

    This Factorial function calculates the factorial of a number.

    \par INPUTS
    \code

    number number for which the factorial is to be calculated.

    \endcode
    \par OUTPUTS
    \code

    factorial value factorial of the input number.
    INVALID_PARM Invalid value of a parameter was
    passed in to the function.
    \endcode
    ************************************************** **********************/


    That is working fine for me. but the problem I am getting is that the doxygen is generating very dirty documentation for #define preprocessors used in my code. Doxygen generates a separate documentation for each #define i have used. For example.

    doxygen will generate separate links and documentation for each of the following defines. that creates a mess.
    #define ONE 1
    #define TWO 2
    #define THREE 3
    #define FOUR 4
    #define FIVE 5



    The solution I thought about this problem is to group these macros together so that only one link and only one documentation will be generated for above macros. So i am looking for a perl script that will group continuous defines with a doxygen tag.

    so the input file from
    ------------BOF---------

    #define ONE 1
    #define TWO 2
    #define THREE 3
    #define FOUR 4
    #define FIVE 5


    #define TRUE 1
    #define FALSE 0

    ---------EOF---------


    will be converted to

    ---------BOF----------

    /*@{*/
    #define ONE 1
    #define TWO 2
    #define THREE 3
    #define FOUR 4
    #define FIVE 5
    /*@}*/

    /*@{*/
    #define TRUE 1
    #define FALSE 0
    /*@}*/

    ---------EOF--------

    (note that each physical continuous defines are grouped with the tag separately.)

    I tried writing sed and awk script for this purpose but found that sed and awk process one line at a time. then i went to do it with perl which can take a whole file as a single stream but i am facing problems doing this job. and i am also running out of time. can anyone help me in this regard? I know that will be a perl one liner for you people

    Thanks,
    Touseef

  2. #2
    Just Joined!
    Join Date
    Mar 2006
    Posts
    2

    got the solution

    I got the answer from Feherke(http://rootshell.be/~feherke/) from another forum who posted following solutions for the above problem

    SED solution

    /^#define/ {
    x
    /#define/!i/*@{*/
    g
    }

    /^$/ {
    x
    /#define/i/*@}*/
    s/.*//
    g
    }



    and AWK solution

    /^#define/ && !i {
    print "/*@{*/"
    i=1
    }

    !/^#define/ && i {
    print "/*@}*/"
    i=0
    }

    1




    Thanks all,
    Touseef Liaqat

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •