File Coverage

blib/lib/DhMakePerl/PodParser.pm
Criterion Covered Total %
statement 9 40 22.5
branch 0 12 0.0
condition 0 3 0.0
subroutine 3 11 27.2
pod 8 8 100.0
total 20 74 27.0


line stmt bran cond sub pod time code
1             package DhMakePerl::PodParser;
2              
3 1     1   307181 use strict;
  1         10  
  1         88  
4 1     1   15 use warnings;
  1         3  
  1         156  
5              
6             our $VERSION = '0.51';
7              
8 1     1   84 use base qw(Pod::Parser);
  1         8  
  1         1013  
9              
10             =head1 NAME
11              
12             DhMakePerl::PodParser - internal helper module for DhMakePerl
13              
14             =head1 SYNOPSIS
15              
16             DhMakePerl::PodParser is used by DhMakePerl to extract some
17             information from the module-to-be-packaged. It sub-classes from
18             L - Please refer to it for further documentation.
19              
20             =head1 METHODS
21              
22             =over
23              
24             =item set_names
25              
26             Defines the names of the sections that should be fetched from the POD
27              
28             =cut
29              
30             sub set_names {
31 0     0 1   my ( $parser, @names ) = @_;
32 0           foreach my $n (@names) {
33 0           $parser->{_deb_}->{$n} = undef;
34             }
35             }
36              
37             =item get
38              
39             Gets the contents for the specified POD section. The single argument should be
40             one of the values given to L.
41              
42             =cut
43              
44             sub get {
45 0     0 1   my ( $parser, $name ) = @_;
46 0           $parser->{_deb_}->{$name};
47             }
48              
49             =item cleanup
50              
51             Empties the information held by the parser object
52              
53             =cut
54              
55             sub cleanup {
56 0     0 1   my $parser = shift;
57 0           delete $parser->{_current_};
58 0           foreach my $k ( keys %{ $parser->{_deb_} } ) {
  0            
59 0           $parser->{_deb_}->{$k} = undef;
60             }
61             }
62              
63             =item command
64              
65             Overrides base class' L L method.
66              
67             Gets each of the POD's commands
68             (sections), and defines how it should react to each of them. In this
69             particular implementation, it basically filters out anything except
70             for the C<=head> sections defined in L.
71              
72             =cut
73              
74             sub command {
75 0     0 1   my ( $parser, $command, $paragraph, $line_num ) = @_;
76 0           $paragraph =~ s/\s+$//s;
77 0 0 0       if ( $command =~ /head/ && exists( $parser->{_deb_}->{$paragraph} ) ) {
78 0           $parser->{_current_} = $paragraph;
79 0           $parser->{_lineno_} = $line_num;
80             }
81             else {
82 0           delete $parser->{_current_};
83             }
84              
85             #print "GOT: $command -> $paragraph\n";
86             }
87              
88             =item add_text
89              
90             Hands back the text it received as it occurred in the input stream (see the
91             L's documentation for L,
92             L and
93             L).
94              
95             Content is ignored if more than 15 lines away from the section start.
96              
97             =cut
98              
99             sub add_text {
100 0     0 1   my ( $parser, $paragraph, $line_num ) = @_;
101 0 0         return unless exists $parser->{_current_};
102 0 0         return if ( $line_num - $parser->{_lineno_} > 15 );
103 0           $paragraph =~ s/^\s+//s;
104 0           $paragraph =~ s/\s+$//s;
105 0           $paragraph = $parser->interpolate( $paragraph, $line_num );
106 0           $parser->{_deb_}->{ $parser->{_current_} } .= "\n\n" . $paragraph;
107              
108             #print "GOT: $paragraph'\n";
109             }
110              
111             =item verbatim
112              
113             Called by L for verbatim paragraphs. Redirected to L.
114              
115             =cut
116              
117 0     0 1   sub verbatim { shift->add_text(@_) }
118              
119             =item textblock
120              
121             Called by L for ordinary text paragraphs. Redirected to
122             L.
123              
124             =cut
125              
126 0     0 1   sub textblock { shift->add_text(@_) }
127              
128             =item interior_sequence
129              
130             L is called by
131             L when, eh, an interior sequence occurs in the text. Interior
132             sequences are things like IE...E.
133              
134             This implementation decodes C, C, C, C and numeric
135             character codes, all used by C escape.
136              
137             =cut
138              
139             sub interior_sequence {
140 0     0 1   my ( $parser, $seq_command, $seq_argument ) = @_;
141 0 0         if ( $seq_command eq 'E' ) {
142 0           my %map = ( 'gt' => '>', 'lt' => '<', 'sol' => '/', 'verbar' => '|' );
143 0 0         return $map{$seq_argument} if exists $map{$seq_argument};
144 0 0         return chr($seq_argument) if ( $seq_argument =~ /^\d+$/ );
145              
146             # html names...
147             }
148 0           return $seq_argument;
149             }
150              
151             1;
152              
153             =back
154              
155             =head1 SEE ALSO
156              
157             L
158              
159             =head1 AUTHOR
160              
161             =over 4
162              
163             =item Paolo Molaro
164              
165             =item Documentation added by Gunnar Wolf and Damyan Ivanov
166              
167             =back
168              
169             =head1 COPYRIGHT & LICENSE
170              
171             =over 4
172              
173             =item Copyright (C) 2001, Paolo Molaro
174              
175             =item Copyright (C) 2008, Gunnar Wolf
176              
177             =item Copyright (C) 2008, Damyan Ivanov
178              
179             =back
180              
181             This program is free software; you can redistribute it and/or modify it under
182             the terms of the GNU General Public License version 2 as published by the Free
183             Software Foundation.
184              
185             This program is distributed in the hope that it will be useful, but WITHOUT ANY
186             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
187             PARTICULAR PURPOSE. See the GNU General Public License for more details.
188              
189             You should have received a copy of the GNU General Public License along with
190             this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
191             Street, Fifth Floor, Boston, MA 02110-1301 USA.
192              
193             =cut