| DhMakePerl documentation | Contained in the DhMakePerl distribution. |
DhMakePerl::PodParser - internal helper module for DhMakePerl
DhMakePerl::PodParser is used by DhMakePerl to extract some information from the module-to-be-packaged. It subclasses from Pod::Parser - Please refer to it for further documentation.
Defines the names of the sections that should be fetched from the POD
Gets the contents for the specified POD section. The single argument should be one of the values given to set_names.
Empties the information held by the parser object
Overrides base class' Pod::Parser command method.
Gets each of the POD's commands
(sections), and defines how it should react to each of them. In this
particular implementation, it basically filters out anything except
for the =head sections defined in set_names.
Hands back the text it received as it ocurred in the input stream (see the Pod::Parser's documentation for verbatim, textblock and interior_sequence).
Content is ignored if more than 15 lines away from the section start.
Called by Pod::Parser for verbatim paragraphs. Redirected to add_text.
Called by Pod::Parser for ordinary text paragraphs. Redirected to add_text.
interior_sequence() is called by Pod::Parser when, eh, an interiorsquence occureds in the text. Interior sequences are things like I<...>.
This implementation decodes gt, lt, sol, verbar and numeric
character codes, all used by E escape.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
| DhMakePerl documentation | Contained in the DhMakePerl distribution. |
package DhMakePerl::PodParser; use strict; use warnings; use base qw(Pod::Parser);
sub set_names { my ( $parser, @names ) = @_; foreach my $n (@names) { $parser->{_deb_}->{$n} = undef; } }
sub get { my ( $parser, $name ) = @_; $parser->{_deb_}->{$name}; }
sub cleanup { my $parser = shift; delete $parser->{_current_}; foreach my $k ( keys %{ $parser->{_deb_} } ) { $parser->{_deb_}->{$k} = undef; } }
sub command { my ( $parser, $command, $paragraph, $line_num ) = @_; $paragraph =~ s/\s+$//s; if ( $command =~ /head/ && exists( $parser->{_deb_}->{$paragraph} ) ) { $parser->{_current_} = $paragraph; $parser->{_lineno_} = $line_num; } else { delete $parser->{_current_}; } #print "GOT: $command -> $paragraph\n"; }
sub add_text { my ( $parser, $paragraph, $line_num ) = @_; return unless exists $parser->{_current_}; return if ( $line_num - $parser->{_lineno_} > 15 ); $paragraph =~ s/^\s+//s; $paragraph =~ s/\s+$//s; $paragraph = $parser->interpolate( $paragraph, $line_num ); $parser->{_deb_}->{ $parser->{_current_} } .= "\n\n" . $paragraph; #print "GOT: $paragraph'\n"; }
sub verbatim { shift->add_text(@_) }
sub textblock { shift->add_text(@_) }
sub interior_sequence { my ( $parser, $seq_command, $seq_argument ) = @_; if ( $seq_command eq 'E' ) { my %map = ( 'gt' => '>', 'lt' => '<', 'sol' => '/', 'verbar' => '|' ); return $map{$seq_argument} if exists $map{$seq_argument}; return chr($seq_argument) if ( $seq_argument =~ /^\d+$/ ); # html names... } return $seq_argument; } 1;