1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/bin/sh
# -*- perl -*-
exec perl -w -x $0 ${1+"$@"}
#!perl
#line 6
# If Windows barfs at line 3 here, you will need to run perl -x vxl_doxy.pl
# You can set up as a permanent file association using the following commands
# >assoc .pl-PerlScript
# >ftype PerlScript=Perl=C:\Perl\bin\Perl.exe -x "%1" %*
# Script to change the perceps documentation format to Doxygen (JavaDoc) format
# Authors:
# Dave Cooper
# Maarten Vergauwen
# Date:
# 17/02/2000
# Modified:
# 11 April 2001 Ian Scott. Remove support for old perceps commands
# 5 May 2001 Geoff Cross. Correctly handle end of verbatim blocks. Allow two contiguous comments
# 10 May 2001 Ian Scott. Merged Geoffs and my changes
# patterns to be matched
$verbpatt = '\\\\verbatim';
$endverbpatt = '\\\\endverbatim';
$slashslashpatt = '^\\s*//';
$slashslashcolonpatt = '^\\s*//:';
$slashstarstarpatt = '/**';
$spacespacepatt = ' ';
$starpatt = '*';
$starslashpatt = '*/';
# variables that keep state:
# comment found -> first line should start with /**, next lines with *, last line with */
$comment = 0;
# verbatim found -> lines should not start with * (visible in Doxygen)
$verbatim = 0;
# finish verbatim mode at the end of this line.
$should_end_verbatim = 0;
$debug = 0;
# mainloop
while (<>)
{
# preprocessing
s/\bVCL_SUNPRO_CLASS_SCOPE_HACK\s*\([^()]*\)//g;
s/\bVCL_SUNPRO_ALLOCATOR_HACK\s*\(([^()]*)\)/$1/g;
s/\bVCL_CAN_STATIC_CONST_INIT_(INT|FLOAT)\b/1/g;
s/\bVCL_STATIC_CONST_INIT_(INT|FLOAT)\s*\(([^()]*)\)/= $2/g;
s/\bVCL_DFL_TYPE_PARAM_STLDECL\s*\(([^,()]*),([^,()]*)\)/class $1 = $2 /g;
s/\bDECLARE_DYNCREATE\s*\([^()]*\)//g; # for MFC
if ( $should_end_verbatim )
{
$verbatim = 0;
$should_end_verbatim = 0;
}
# found verbatim ?
if ( m/$verbpatt/ ) { $verbatim = 1; };
# found endverbatim ?
if ( m/$endverbpatt/ ) { $should_end_verbatim = 1; };
# found start of comment: "//:" ?
if ( s!$slashslashcolonpatt!$slashstarstarpatt! )
{
chomp; s/\s*$//;
# escape a space following a dot, add a dot at the end,
# # and finish brief doc, unless the line is empty or only has '\file':
unless (m!^\s*\/\*\*\s*(\\file)?\s*$!) {
# s/\. /.\\ /g; s/(\.)?\s*$/. \*\/\n\/\*/;
s/\. /.\\ /g; s/(\.)?\s*$/.\n/;
}
else { s/$/\n/; }
if ($comment)
{
# Previous comment hasn't ended--two contiguous comment blocks.
# (Should not happen.)
print STDERR "Two contiguous comment blocks -- this should not happen\n";
print "*/\n";
}
$comment = 1;
print; next;
}
# Replace '$' with '\f$' (TeX math mode)
s/(\\f)?\$(.+?)(\\f)?\$/\\f\$$2\\f\$/g if ($comment);
# found continuation of comment WITH verbatim -> no "*"
if ( m!$slashslashpatt! && $verbatim && $comment)
{
s!$slashslashpatt!$spacespacepatt!;
# # Make 'Modifications' a section title:
# s!\b(Modifications?)\b\:?!\<H2\>$1\<\/H2\>!;
# remove lines of the form ========= or +-+-+-+-+ or ********* or longer:
print unless m/^\s*[*=+-]{9,}\s*$/; next;
}
# found continuation of comment WITHOUT verbatim -> start line with "*"
if ( m!$slashslashpatt! && $comment )
{
s!$slashslashpatt!$starpatt!;
# remove lines of the form ========= or +-+-+-+-+ or ********* or longer:
print unless m/^\s*[*=+-]{9,}\s*$/; next;
}
# found end of comment -> start line with */
# NOTE that *every* line within a comment (also empty lines) *must* start with // !
# (In an earlier version of this script, empty lines were allowed inside comments.)
if ( $comment && ! m!$slashslashpatt! )
{
print "$starslashpatt\n";
$comment = 0;
print; next;
}
# just print line if not in comment or in file
if ( !$comment ) { print; next; }
# debug - print unprocessed lines (s.b. none)
if ($debug) { print "LNP:\t"; print; }
}
|