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

DoxyFilt: Item/File/File.pm Source File

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

Item/File/File.pm

Go to the documentation of this file.
00001 package Doxygen::Item::File;
00002 
00003 =head1 NAME
00004 
00005 Doxygen::Item::File - Input file to Doxygen and its comments and contents.
00006 
00007 =head1 SYNOPSIS
00008 
00009     my  $cls = new Doxygen::Item::File;
00010 
00011 =head1 ABSTRACT
00012 
00013 A Doxygen::Item::File object represents an imaginary C/C++
00014 source file for processing by the Doxygen documentation system.
00015 These objects should be created by a specific source-language filter
00016 (subclass of Doxygen::Filter, named Doxygen::I<language>::Filter)
00017 when processing a source file.
00018 
00019 =head1 DESCRIPTION
00020 
00021 =head1 METHODS
00022 
00023 =over
00024 
00025 =cut
00026 
00027 use     5.005;  # just to pick something, but not really tested
00028 use     strict;
00029 use     warnings;
00030 use     UNIVERSAL   qw(isa);
00031 
00032 use     base qw(Doxygen::Item);
00033 
00034 our $VERSION = '0.01';
00035 
00036 ###########################################################################
00037 ###########################################################################
00038 
00039 =item   C<generate($self [ , $indent ])>
00040 
00041 Generate Doxygen comments to specify the name of the current file
00042 and any file-level comments.
00043 
00044 =cut
00045 
00046 sub generate    # $self, %flags
00047 {
00048     my  $self = shift;
00049     
00050     print "/**\n";
00051     print " * \\file $self->{path}\n";
00052     print " *\n";
00053     $self->genComment(@_);
00054     print " */\n\n";
00055     
00056     my  $macro = $self->{path};
00057     
00058     $macro =~ s|^.*:[/\\]||;
00059     $macro =~ s|\W|_|g;
00060     
00061     print "#ifndef $macro\n";
00062     print "#define $macro\n\n";
00063     
00064     if (isa($self->{includes}, 'ARRAY')) {
00065         print "#include <$_>\n"
00066             for @{$self->{includes}};
00067     }
00068     
00069     print "\n";
00070 
00071     my  $result = $self->SUPER::generate(@_);
00072     
00073     print "\n#endif $macro\n\n";
00074     
00075     if (my $pages = $self->text('pages')) {
00076         if (isa($pages, 'ARRAY')) {
00077             for (@$pages) {
00078                 Doxygen::Item::genThing("/**\n", @_);
00079                 Doxygen::Item::genThing
00080                     ($_, @_, comment => 1, which => 'comment');
00081                 Doxygen::Item::genThing(" */\n", @_);
00082             }
00083         } else {
00084             warn "*** pages items for $self not an array reference\n";
00085         }
00086     }
00087 }
00088 
00089 ###########################################################################
00090 ###########################################################################
00091 
00092 =item   C<massage($self, $source)>
00093 
00094 Make sure there is a brief message for the file,
00095 stealing it from a class if there is one.
00096 
00097 =cut
00098 
00099 sub massage     # $self, $source
00100 {
00101     my ($self, $source) = @_;
00102     
00103 #   $source->log('T', __PACKAGE__, '::massage(', $source, ')');
00104     
00105     return
00106         if $self->text('brief');
00107     
00108     my  @classes = $self->items('class');
00109     
00110     return
00111         unless @classes;
00112     
00113     my  $brief = undef;
00114     my  $clhdr = undef;
00115     
00116     for (@classes) {
00117         $_->massage($source);
00118         
00119         $self->textAppend('comment', <<CLASSHDR) unless $clhdr++;
00120 
00121 <h2 class='POD_head2'>Classes</h2>
00122 <ul>
00123 CLASSHDR
00124         
00125         $self->textAppend('comment', "<li>$_->{name}\n");
00126         
00127         next
00128             if $brief;
00129         
00130         undef $brief
00131             if ($brief = $_->text('brief'))
00132             && ! isa $brief, 'ARRAY';
00133         
00134         next
00135             if $brief;
00136         
00137         my  $cmnts = $_->text('comment');
00138         
00139         next
00140             unless $cmnts
00141                 && isa($cmnts, 'ARRAY')
00142                 && @$cmnts;
00143 
00144         undef $brief
00145             if ($brief = $cmnts->[0])
00146             && ! isa $brief, 'ARRAY';
00147     }
00148     
00149     $self->textAppend('comment', "</ul>\n")
00150         if $clhdr;
00151     
00152     $self->textAppend('brief', @$brief)
00153         if ! isa($self->text('brief'), 'ARRAY')
00154         && isa $brief, 'ARRAY';
00155 }
00156 
00157 ###########################################################################
00158 ###########################################################################
00159 
00160 =item   C<Include($self)>
00161 
00162 Add one or more 'include' file(s).
00163 
00164 =cut
00165 
00166 sub Include     # $self, @include
00167 {
00168     my  $self = shift;
00169     
00170 #   print STDERR __PACKAGE__, "::Include(", join(', ', @_), ")\n";
00171     
00172     push @{$self->{includes}}, @_
00173 }
00174 
00175 ###########################################################################
00176 
00177 =item   C<Includes($self)>
00178 
00179 Return pointer to array reference of 'include' files.
00180 
00181 =cut
00182 
00183 sub Includes    # $self
00184 {
00185     my  $self = shift;
00186     
00187     $self->{includes}
00188 }
00189 
00190 ###########################################################################
00191 ###########################################################################
00192 
00193 =item   C<focus($self)>
00194 
00195 Return the focus for the file.
00196 
00197 If there are classes, the first class is the focus.
00198 Otherwise the focus is the file itself.
00199 
00200 =cut
00201 
00202 sub focus
00203 {
00204     my  $self    = shift;
00205     my  @classes = $self->items('class');
00206     
00207     @classes ? $classes[0] : $self
00208 }
00209 
00210 ###########################################################################
00211 ###########################################################################
00212 
00213 # [EX-FOOTER]
00214 
00215 1
00216 
00217 __END__
00218 
00219 =back
00220 
00221 =head1 SEE ALSO
00222 
00223 DoxyFilt.pl, Doxygen::Item, Doxygen::Filter
00224 
00225 =head1 AUTHOR
00226 
00227 Marc M. Adkins, L<mailto:Perl@Doorways.org>
00228 
00229 =head1 COPYRIGHT AND LICENSE
00230 
00231 Copyright 2004-2010 by Marc M. Adkins
00232 
00233 This library is free software; you can redistribute it and/or modify
00234 it under the same terms as Perl itself.
00235 
00236 =cut
00237 
00238 =begin  doxygen
00239 
00240 @page   filePOD File-level POD Usage
00241 
00242 This page describes the way we tend to document our Perl files.
00243 
00244 Most of what we do begins with copying two sections of an existing
00245 file to the new file we're generating.
00246 Sometimes we copy an entire file and gut it,
00247 or rename all the functions,
00248 but the general approach is the same.
00249 
00250 We'll use the source file for Doxygen::Item::File as our example.
00251 
00252 @dontinclude    Item/File/File.pm
00253 
00254 @section header File Header
00255 
00256 The top of the file, the file's header, looks like:
00257 
00258 @until  $VERSION
00259 
00260 We begin with the package declaration.
00261 If we place any POD or doxygen comments before the package declaration
00262 it will be attached to the file as a whole, which isn't usually useful.
00263 After the package declaration we place the POD for the module.
00264 
00265 Note that at the end we define a <tt>=head1</tt> named
00266 <tt>METHODS</tt>, then an <tt>=over</tt>, then the <tt>=cut</tt>.
00267 This specific sequence is intended to work with POD as well as Doxygen.
00268 When processed by a normal POD tool the it generates a section,
00269 <tt>METHODS</tt>, which has items for each function.
00270 Using Doxygen and DoxyFilt the entire section (because of its
00271 specific name) is removed in favor of the Doxygen table of contents.
00272 
00273 After the package's POD we specify the normal beginning of the package
00274 source, <tt>use</tt> statements and so forth.
00275 Then comes the bulk of the source code.
00276 
00277 @section footer File Footer
00278 
00279 At the bottom of the file, the file's footer, we place:
00280 
00281 @skip   [EX-FOOTER]
00282 @skip   1
00283 @until  =cut
00284 
00285 The <tt>1</tt> is the return value for the package.
00286 Otherwise it won't compile properly.
00287 
00288 After that we use an <tt>__END__</tt> to break off compilation.
00289 This isn't strictly necessary because we're going to write more POD
00290 on the end, but it doesn't hurt either, and we just copy this stuff
00291 around so it doesn't much matter.
00292 
00293 The first piece of POD is the <tt>=back</tt> line.
00294 Remember the way we ended the header with <tt>=over</tt>
00295 even though we had just started the <tt>METHODS</tt> heading?
00296 Well, now that we've defined all of our functions or methods,
00297 it's time to end that list.
00298 
00299 Then we dump in whatever boilerplate we like at the end of each page.
00300 This varies from project to project.
00301 
00302 =end    doxygen

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