Contents 
 Index 
 "Perl Program Reference" 
 < Previous 
 Next > 

doxygenate.pl

Go to the documentation of this file.
00001 // This file has been modified on-the-fly with an input filter
00002 // to change it from Perl syntax to C++ strictly for the purposes
00003 // of faking out Doxygen. Modifications include:
00004 
00005 // - changing local() definitions to C++ #define statements.
00006 // - commenting out undef statements.
00007 // - changing $globe'... variable names to $globe_...
00008 // - changing sub statements to look like C++ functions.
00009 // - changing # comments to C++ comments.
00010 // - ...
00011 
00012 // If you see other strangeness in the HTML version of the Perl file,
00013 // it comes from getting it to look more C++ like.
00014 
00015 
00016 // #! /usr/bin/perl
00017 
00018 $infile = $ARGV[0];
00019 sysopen(INFILE, $infile, 0) || die "ERROR! Can't open \"$infile\": $!\n";
00020 $/ = // undef;
00021 $_ = <INFILE>;
00022 // This regular expression came from the perfaq, but I modified it to also
00023 // handle C++ style comments. The comments show up in $1 and the non-comments
00024 // are in $4.
00025 s{
00026        (/(/[^\n]*      // # C++ comment
00027         | \*          // #  Start of /* ... */ comment
00028           [^*]*\*+    // #  Non-* followed by 1-or-more *'s
00029          (
00030          [^/*][^*]*\*+
00031          )*          // #  0-or-more things which don't start with /
00032                      // #    but do end with '*'
00033          /)           // #  End of /* ... */ comment
00034        )
00035      |         // #     OR  various things which aren't comments:
00036        (
00037          "           // #  Start of " ... " string
00038          (
00039            \\.           // #  Escaped char
00040          |               // #    OR
00041            [^"\\]        // #  Non "\
00042          )*
00043          "           // #  End of " ... " string
00044        |         // #     OR
00045          '           // #  Start of ' ... ' string
00046          (
00047            \\.           // #  Escaped char
00048          |               // #    OR
00049            [^'\\]        // #  Non '\
00050          )*
00051          '           // #  End of ' ... ' string
00052        |         // #     OR
00053          .           // #  Anything other char
00054          [^/"'\\]*   // #  Chars which doesn't start a comment, string or escape
00055        )
00056      }{process_comment($1).$4}gexs;
00057 // print;
00058 
00059 // This subroutine gets the old comment in as an argument. You can process it
00060 // to add doxygen fields and return the new comment. 
00061 // Then add in your doxygen configuration file use
00062 // INPUT_FILTER = "perl doxygenate.pl"
00063 int process_comment 
00064   {
00065   $comment = shift;
00066   $comment =~ s{/\*}{/*! }; //  Make block comments Doxygen...
00067   $comment =~s{//}{//! };  //  Make single line comments doxygen...
00068   return $comment;
00069   }
00070 


 "Perl Program Reference" 
 < Previous 
 Next > 


Open-Source tools compliments of Voyant Technologies, Inc. and Glenn C. Maxey.
01/13/2003

TP Tools v2-00-0a

# tpt-perl-hcr-02