in reply to Re^3: DoxygenFilter & DoxyFilt
in thread DoxygenFilter & DoxyFilt
Well, google wasn't being particularly helpful so I figured I'll just hack the goddamn doxygenfilter for my purpose. The doxyfilter perl script that you add as INPUT_FILTER calls PerlFilter->flter() method, which does the actual processing of each script. As suspected, it does not even look for POD syntax. All you gotta do is modify it to make it work with POD. In our case any all POD open tags (=head1, =head2 etc) are always closed (=cut). So this filter method handles that & dumps out what Doxygen will understand.
If someone wants to expand this to support full POD syntax, the following code snippet should be a good start.
sub filter { my($self, $infile) = @_; open(my $infh, $infile); my $current_class = ""; my $file = []; while( <$infh> ) { push( @$file, $_ ); } $self->file_contents( $file ); my $objcontext = grep( /^\s*use\s+base\s/, @$file ) || grep( /\@ISA/, @$file ) || grep( /^\s*bless/, @$file ) || grep( /^\s*sub\s+new\s/, @$file ) || grep( /\$self/, @$file ); push( @$file, "" ); # in order to have a delimiting empty line at + EOF for( my $line=0; $line <= $#$file; ) { $_ = $file->[$line++]; if (/^use\s+([\w:]+)/) { my $inc = $1; $inc =~ s/::/\//g; $self->print("#include \"$inc.pm\"\n"); } elsif (/^package\s+([\w:]+)/) { if ($current_class) { $self->flush; $self->print("};\n"); } next unless( $objcontext ); $current_class = $1; $self->emit_class( $current_class, $line ); } if (/^=head\d/) { my @more; while ($_ = $file->[$line++]) { if (/^=cut/s) { last; } else { #print "DOC ---- $_"; push @more, $_; } } $_ = $file->[$line++]; while ($_ =~ /^$/) { $_ = $file->[$line++]; } if (/^\s*sub\s+([\w:]+)/) { my( $proto, $name, @args ) = $self->analyze_sub($line-1); if( $current_class && @args && ($args[0] eq "\$self") ) { $self->push($self->protection($proto).' Object Methods'); $proto =~ s/\$self,*\s*//; } elsif( $current_class && ((@args && ($args[0] eq "\$class")) || ($name eq "new") +) ) { $self->push($self->protection($proto).' Class Methods'); } else { $self->push($self->protection($proto).' Functions'); } $proto = $self->munge_parameters($proto); $self->start("\@fn $proto")->more(@more)->end; $self->print($proto, ";\n"); $self->pop; } redo if defined $_; } } $self->flush(); if ($current_class) { $self->print("};\n"); } }
|
|---|