Icon for Dimension.orgIcon for TalentIcon for ToolsIcon for Doorways.org
Icon for ToolsIcon for Perl Tools

DoxyFilt: DoxyFilt.pl Source File

  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

DoxyFilt.pl

Go to the documentation of this file.
00001 #!/bin/perl
00002 
00003 =head1 NAME
00004 
00005 C<DoxyFilt.pl> Script for preparing non-C/C++ input documents for Doxygen.
00006 
00007 =head1 SYNOPSIS
00008 
00009 In Doxygen configuration file:
00010 
00011     INPUT_FILTER = DoxyFilt
00012 
00013 The C<DoxyFilt> entry will be a batch file or shell script that in turn
00014 invokes DoxyFilt.pl.  For example (DOS/Windows batch file):
00015 
00016     set doxpath=%~p0
00017     perl %doxpath%DoxyFilt.pl %1
00018 
00019 or (Linux shell script):
00020 
00021     #!/bin/sh
00022     perl DoxyFilt.pl $1
00023 
00024 Any command line parameters necessary to DoxyFilt.pl will be invoked in
00025 the batch file.
00026 
00027 Note that in more complex situations, where a number of languages are
00028 used, the batch file or shell script will need to choose the appropriate
00029 filter (DoxyFilt.pl or another program) and invoke it.
00030 
00031 =head1 ABSTRACT
00032 
00033 Provides an input filter for the Doxygen documentation generation tool
00034 to convert Perl/POD (and/or other source formats) into C/C++ with
00035 Doxygen-enabled comments.
00036 
00037 =head1 DESCRIPTION
00038 
00039 The Doxygen documentation processor collects information from source code
00040 files in C and C++ and generates nicely formatted source code documentation.
00041 This can be an important component of any fully documented software project.
00042 
00043 Unfortunately, Doxygen doesn't know anything about any other languages.
00044 It does, however, have an input filter setting that allows source files in
00045 other languages to be converted to something that Doxygen I<can> recognize.
00046 This means parsing the source files and converting them into a combination
00047 of C/C++ and Doxygen-enabled comments.
00048 
00049 =head1  Command-Line Arguments
00050 
00051 The following flags can be specified to affect the
00052 operation of <tt>DoxyFilt.pl</tt>:
00053 
00054 =over
00055 
00056 =item   C<--alias I<filter>=I<existing>>
00057 
00058 Specific a filter that will be handled by an existing filter.
00059 Use this when it is necessary to specify multiple
00060 filters that use the same filter module but have different
00061 characteristics.
00062 For example, C<Batch> and C<Shell> both link to the
00063 C<Script> filter by default, but use different comment
00064 patterns.
00065 
00066 =item   C<--comment I<filter>=I<comment>>
00067 
00068 Specify a comment pattern for a given filter.
00069 Only one comment pattern may be defined for a given filter,
00070 new ones with old filter names replace the old patterns.
00071 
00072 =item   C<--check I<filter>=I<recognition>>
00073 
00074 Specify a recognition pattern for a given filter.
00075 This is used for files without suffixes.  Any such file is
00076 tested with all registered patterns of this type and the
00077 specified filter(s) are applied.
00078 
00079 =item   C<--docs I<filter>=I<suffix>>
00080 
00081 Specify a suffix to be handled by a specific filter.
00082 Filters may be added by the user and specified in
00083 this manner.
00084 The default filters include C<Perl>, C<POD>, C<Batch>, and C<Shell>.
00085 More than one filter may be applied to the same file.
00086 Only one suffix pattern may be defined for a given filter,
00087 new ones with old filter names replace the old patterns.
00088 
00089 =item   C<--flag I<[docType::]name>=I<value>>
00090 
00091 Specify a named flag.
00092 Flags can be specified as global or per document type.
00093 More specific flags (per document type) override global flags
00094 for the specified document type and are invisible to other
00095 document types.
00096 
00097 =item   C<--noinfo>
00098 
00099 Deactivates informational messages such as those that specify what file is
00100 being processed.
00101 These are the C<[I]> messages.
00102 
00103 =item   C<--pass=I<suffix>>
00104 
00105 Specify a suffix to be passed through unchanged.
00106 This flag may be used multiple times.
00107 Defaults to C<dox> or C<doxy> (Doxygen source files).
00108 Flags are cumulative, and can't be removed,
00109 but may be overridden by C<--docs>.
00110 
00111 =item   C<--path=I<pathname>>
00112 
00113 Alternative way to specify pathname of file to be processed.
00114 Normally it is specified by the positional argument,
00115 but it can be set this way instead.
00116 This flag takes priority over the positional argument.
00117 
00118 =item   C<--spawn I<filter>=I<command>>
00119 
00120 Specify a command to be executed as a subprocess
00121 to implement a given filter.
00122 In this case there will be no matching Doxygen::Filter
00123 subclass, just specify a C<--docs> setting to 'declare'
00124 the filter name and its suffix and then use the
00125 C<--spawn> parameter to set the command to be executed.
00126 The pathname to be processed is appended after a space
00127 to the end of the command line, or it will replace the
00128 string C<'{}'> if these are present in the command.
00129 
00130 =item   C<--trace>
00131 
00132 Activates tracing and 'hacking' messages.
00133 The former are lower-level debugging messages.
00134 The latter are specific conditions that have been bypassed
00135 in possibly strange ways (if any).
00136 These are the C<[T]> and C<[H]> messages, respectively.
00137 
00138 =back
00139 
00140 Where the above flags specify C<suffix> the argument
00141 will be converted into a pattern.
00142 If a simple string or pattern fragment it will be embedded
00143 in the pattern C<qr(\.$string)i>.
00144 If it matches C</^qr\((.*)\)$/> it will be converted
00145 via C<qr($1)>.
00146 
00147 Arbitrarily complex patterns should be possible when
00148 appropriately quoted to get past the operating system's
00149 command line interpreter.
00150 The following appears to work on Linux:
00151 
00152     perl DoxyFilt.pl '--pass=qr(\.doxy?)i' --docs 'Batch=qr(\.bat)i' ...
00153 
00154 In a similar fashion, where flags specify C<suffix>
00155 the argument will be converted into a pattern.
00156 In this case, if it is a simple string it is embedded
00157 in the pattern C<qr(^\\s*$string(.*)$)m>.
00158 If the string matches the C<qr()> format it will be
00159 converted directly as with suffix patterns.
00160     
00161 =cut
00162 
00163 #=| \ingroup    scripts
00164 
00165 ###########################################################################
00166 ###########################################################################
00167 
00168 use     5.005;  # just to pick something, but not really tested
00169 use     strict;
00170 use     warnings;
00171 use     UNIVERSAL   qw(isa);
00172 
00173 use     Getopt::Long;
00174 
00175 use     Doxygen::Source;
00176 
00177 our $VERSION = '0.75';
00178 
00179 ###########################################################################
00180 # Command-line arguments:
00181 
00182 my  %flags = (
00183     info => 1,
00184     type => {
00185         alias => { },
00186         chck  => { },
00187         cmnt  => { },
00188         docs  => { },
00189         flag  => { },
00190         pass  => [ ],
00191         spawn => { }
00192     }
00193 );
00194 my  %pass  = ( );
00195 my  $opts = GetOptions('alias=s'    =>  $flags{type}->{alias},
00196                        'check=s'    =>  $flags{type}->{chck},
00197                        'comment=s'  =>  $flags{type}->{cmnt},
00198                        'docs=s'     =>  $flags{type}->{docs},
00199                        'flag=s'     =>  $flags{type}->{flag},
00200                        'help'       => \$flags{help},
00201                        'info!'      => \$flags{info},
00202                        'pass=s'     =>  $flags{type}->{pass},
00203                        'path=s'     => \$flags{path},
00204                        'spawn=s'    =>  $flags{type}->{spawn},
00205                        'trace'      => \$flags{trace});
00206 
00207 $flags{path} = shift
00208     unless $flags{path}
00209         || ! @ARGV;
00210 
00211 die <<USAGE if $flags{help} || ! $opts || ! $flags{path};
00212 usage:  $0 <flag>* [ <path> ]
00213         Process file specified by <path> (or via --path flag),
00214         generating faux C++ and Doxygen comments to standard output
00215     --alias     <docType>=<filter>
00216                     set an alias for a document type, so that
00217                     <docType> is handled by the <filter> filter
00218     --check     <docType>=<pattern>
00219                     set the file recognition pattern for
00220                     a document type
00221     --comment   <docType>=<pattern>
00222                     set the comment recognition pattern for
00223                     a document type
00224     --docs      <docType>=<suffix>
00225                     set the suffix pattern for a document type
00226     --flag      <[docType::]flag>=<value>
00227     --help          show this usage description
00228     --noinfo        deactivate informational logging ([I])
00229     --pass=<suffix> suffix to be passed through unchanged
00230     --path=<path>   specify file path (or use positional argument)
00231     --spawn     <docType>=<command>
00232                     set command to be spawned via system()
00233     --trace         activate trace logging ([T] and [H])
00234 USAGE
00235 
00236 ###########################################################################
00237 ###########################################################################
00238 #
00239 # Main Program:
00240 #
00241 
00242 my  $source = new Doxygen::Source(%flags);
00243 
00244 if (isa($source, 'Doxygen::Source')) {
00245 #   $source->log('T', 'Normal execution...')->pushLog;
00246     $source->massage;
00247     $source->generate;
00248 #   $source->popLog->log('T', 'Output generated!');
00249 } else {
00250     local   $/ = undef; # slurp entire file
00251 
00252     die "Unable to read (slurp) from file:\n    $flags{path}\n  $!\n"
00253         unless open FILE, '<', $flags{path};
00254 
00255     print <FILE>;
00256 }
00257 
00258 ###########################################################################
00259 ###########################################################################
00260 
00261 __END__
00262 
00263 =head1 SEE ALSO
00264 
00265 Doxygen::Filter, http://www.doxygen.org
00266 
00267 =head1 COPYRIGHT
00268 
00269 Copyright (C) 2004-2010  Marc M. Adkins
00270 
00271 This library is free software; you can redistribute it and/or
00272 modify it under the same terms as Perl itself.
00273 
00274 This program is distributed in the hope that it will be useful, but
00275 without any warranty; without even the implied warranty of
00276 merchantability or fitness for a particular purpose.
00277 
00278 =head1 AUTHOR
00279 
00280 Marc M. Adkins  L<mailto:Perl@Doorways.org>
00281 
00282 =cut

Generated on Mon Dec 27 2010 15:15:39 for DoxyFilt by  doxygen 1.7.1

www.dimension.org logo

(C)opyright 1998 - 2012 Dimension.org

WebMaster