line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
145323
|
use 5; |
|
4
|
|
|
|
|
36
|
|
2
|
|
|
|
|
|
|
package Pod::Simple::JustPod; |
3
|
|
|
|
|
|
|
# ABSTRACT: Pod::Simple formatter that extracts POD from a file containing |
4
|
|
|
|
|
|
|
# other things as well |
5
|
4
|
|
|
4
|
|
27
|
use strict; |
|
4
|
|
|
|
|
21
|
|
|
4
|
|
|
|
|
99
|
|
6
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
151
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
1232
|
use Pod::Simple::Methody (); |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
7251
|
|
9
|
|
|
|
|
|
|
our @ISA = ('Pod::Simple::Methody'); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
21
|
|
|
21
|
1
|
53286
|
my $self = shift; |
13
|
21
|
|
|
|
|
140
|
my $new = $self->SUPER::new(@_); |
14
|
|
|
|
|
|
|
|
15
|
21
|
|
|
|
|
118
|
$new->accept_targets('*'); |
16
|
21
|
|
|
|
|
95
|
$new->keep_encoding_directive(1); |
17
|
21
|
|
|
|
|
76
|
$new->preserve_whitespace(1); |
18
|
21
|
|
|
|
|
78
|
$new->complain_stderr(1); |
19
|
21
|
|
|
|
|
82
|
$new->_output_is_for_JustPod(1); |
20
|
|
|
|
|
|
|
|
21
|
21
|
|
|
|
|
59
|
return $new; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_that_all_is_closed { |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Actually checks that the things we depend on being balanced in fact are, |
29
|
|
|
|
|
|
|
# so that we can continue in spit of pod errors |
30
|
|
|
|
|
|
|
|
31
|
1394
|
|
|
1394
|
0
|
2020
|
my $self = shift; |
32
|
1394
|
|
|
|
|
2904
|
while ($self->{inL}) { |
33
|
0
|
|
|
|
|
0
|
$self->end_L(@_); |
34
|
|
|
|
|
|
|
} |
35
|
1394
|
|
66
|
|
|
2910
|
while ($self->{fcode_end} && @{$self->{fcode_end}}) { |
|
1259
|
|
|
|
|
3597
|
|
36
|
0
|
|
|
|
|
0
|
$self->_end_fcode(@_); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub handle_text { |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Add text to the output buffer. This is skipped if within a L<>, as we use |
43
|
|
|
|
|
|
|
# the 'raw' attribute of that tag instead. |
44
|
|
|
|
|
|
|
|
45
|
4565
|
100
|
|
4565
|
0
|
12768
|
$_[0]{buffer} .= $_[1] unless $_[0]{inL} ; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub spacer { |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Prints the white space following things like =head1. This is normally a |
51
|
|
|
|
|
|
|
# blank, unless BlackBox has told us otherwise. |
52
|
|
|
|
|
|
|
|
53
|
407
|
|
|
407
|
0
|
596
|
my ($self, $arg) = @_; |
54
|
407
|
100
|
|
|
|
721
|
return unless $arg; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $spacer = ($arg->{'~orig_spacer'}) |
57
|
386
|
100
|
|
|
|
967
|
? $arg->{'~orig_spacer'} |
58
|
|
|
|
|
|
|
: " "; |
59
|
386
|
|
|
|
|
654
|
$self->handle_text($spacer); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _generic_start { |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Called from tags like =head1, etc. |
65
|
|
|
|
|
|
|
|
66
|
144
|
|
|
144
|
|
311
|
my ($self, $text, $arg) = @_; |
67
|
144
|
|
|
|
|
341
|
$self->check_that_all_is_closed(); |
68
|
144
|
|
|
|
|
373
|
$self->handle_text($text); |
69
|
144
|
|
|
|
|
292
|
$self->spacer($arg); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
21
|
|
|
21
|
0
|
74
|
sub start_Document { shift->_generic_start("=pod\n\n"); } |
73
|
59
|
|
|
59
|
0
|
177
|
sub start_head1 { shift->_generic_start('=head1', @_); } |
74
|
52
|
|
|
52
|
0
|
185
|
sub start_head2 { shift->_generic_start('=head2', @_); } |
75
|
2
|
|
|
2
|
0
|
7
|
sub start_head3 { shift->_generic_start('=head3', @_); } |
76
|
2
|
|
|
2
|
0
|
7
|
sub start_head4 { shift->_generic_start('=head4', @_); } |
77
|
2
|
|
|
2
|
0
|
8
|
sub start_head5 { shift->_generic_start('=head5', @_); } |
78
|
2
|
|
|
2
|
0
|
9
|
sub start_head6 { shift->_generic_start('=head6', @_); } |
79
|
4
|
|
|
4
|
0
|
17
|
sub start_encoding { shift->_generic_start('=encoding', @_); } |
80
|
|
|
|
|
|
|
# sub start_Para |
81
|
|
|
|
|
|
|
# sub start_Verbatim |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub start_item_bullet { # Handle =item * |
84
|
35
|
|
|
35
|
0
|
77
|
my ($self, $arg) = @_; |
85
|
35
|
|
|
|
|
94
|
$self->check_that_all_is_closed(); |
86
|
35
|
|
|
|
|
98
|
$self->handle_text('=item'); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# It can be that they said simply '=item', and it is inferred that it is to |
89
|
|
|
|
|
|
|
# be a bullet. |
90
|
35
|
100
|
|
|
|
87
|
if (! $arg->{'~orig_content'}) { |
91
|
2
|
|
|
|
|
5
|
$self->handle_text("\n\n"); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { |
94
|
33
|
|
|
|
|
97
|
$self->spacer($arg); |
95
|
33
|
100
|
|
|
|
75
|
if ($arg->{'~_freaky_para_hack'}) { |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# See Message Id <87y3gtcwa2.fsf@hope.eyrie.org> |
98
|
23
|
|
|
|
|
101
|
my $item_text = $arg->{'~orig_content'}; |
99
|
23
|
|
|
|
|
53
|
my $trailing = quotemeta $arg->{'~_freaky_para_hack'}; |
100
|
23
|
|
|
|
|
476
|
$item_text =~ s/$trailing$//; |
101
|
23
|
|
|
|
|
218
|
$self->handle_text($item_text); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
else { |
104
|
10
|
|
|
|
|
23
|
$self->handle_text("*\n\n"); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub start_item_number { # Handle '=item 2' |
110
|
4
|
|
|
4
|
0
|
10
|
my ($self, $arg) = @_; |
111
|
4
|
|
|
|
|
11
|
$self->check_that_all_is_closed(); |
112
|
4
|
|
|
|
|
11
|
$self->handle_text("=item"); |
113
|
4
|
|
|
|
|
12
|
$self->spacer($arg); |
114
|
4
|
|
|
|
|
10
|
$self->handle_text("$arg->{'~orig_content'}\n\n"); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub start_item_text { # Handle '=item foo bar baz' |
118
|
197
|
|
|
197
|
0
|
359
|
my ($self, $arg) = @_; |
119
|
197
|
|
|
|
|
435
|
$self->check_that_all_is_closed(); |
120
|
197
|
|
|
|
|
490
|
$self->handle_text('=item'); |
121
|
197
|
|
|
|
|
346
|
$self->spacer($arg); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _end_item { |
125
|
236
|
|
|
236
|
|
385
|
my $self = shift; |
126
|
236
|
|
|
|
|
499
|
$self->check_that_all_is_closed(); |
127
|
236
|
|
|
|
|
523
|
$self->emit; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
*end_item_bullet = *_end_item; |
131
|
|
|
|
|
|
|
*end_item_number = *_end_item; |
132
|
|
|
|
|
|
|
*end_item_text = *_end_item; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub _start_over { # Handle =over |
135
|
32
|
|
|
32
|
|
72
|
my ($self, $arg) = @_; |
136
|
32
|
|
|
|
|
90
|
$self->check_that_all_is_closed(); |
137
|
32
|
|
|
|
|
89
|
$self->handle_text("=over"); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# The =over amount is optional |
140
|
32
|
100
|
|
|
|
97
|
if ($arg->{'~orig_content'}) { |
141
|
29
|
|
|
|
|
78
|
$self->spacer($arg); |
142
|
29
|
|
|
|
|
78
|
$self->handle_text("$arg->{'~orig_content'}"); |
143
|
|
|
|
|
|
|
} |
144
|
32
|
|
|
|
|
87
|
$self->handle_text("\n\n"); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
*start_over_bullet = *_start_over; |
148
|
|
|
|
|
|
|
*start_over_number = *_start_over; |
149
|
|
|
|
|
|
|
*start_over_text = *_start_over; |
150
|
|
|
|
|
|
|
*start_over_block = *_start_over; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _end_over { |
153
|
32
|
|
|
32
|
|
68
|
my $self = shift; |
154
|
32
|
|
|
|
|
89
|
$self->check_that_all_is_closed(); |
155
|
32
|
|
|
|
|
91
|
$self->handle_text('=back'); |
156
|
32
|
|
|
|
|
65
|
$self->emit; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
*end_over_bullet = *_end_over; |
160
|
|
|
|
|
|
|
*end_over_number = *_end_over; |
161
|
|
|
|
|
|
|
*end_over_text = *_end_over; |
162
|
|
|
|
|
|
|
*end_over_block = *_end_over; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub end_Document { |
165
|
21
|
|
|
21
|
0
|
41
|
my $self = shift; |
166
|
21
|
|
|
|
|
66
|
$self->emit; # Make sure buffer gets flushed |
167
|
21
|
|
|
|
|
29
|
print {$self->{'output_fh'} } "=cut\n" |
|
21
|
|
|
|
|
184
|
|
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub _end_generic { |
171
|
714
|
|
|
714
|
|
1219
|
my $self = shift; |
172
|
714
|
|
|
|
|
1721
|
$self->check_that_all_is_closed(); |
173
|
714
|
|
|
|
|
1457
|
$self->emit; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
*end_head1 = *_end_generic; |
177
|
|
|
|
|
|
|
*end_head2 = *_end_generic; |
178
|
|
|
|
|
|
|
*end_head3 = *_end_generic; |
179
|
|
|
|
|
|
|
*end_head4 = *_end_generic; |
180
|
|
|
|
|
|
|
*end_head5 = *_end_generic; |
181
|
|
|
|
|
|
|
*end_head6 = *_end_generic; |
182
|
|
|
|
|
|
|
*end_encoding = *_end_generic; |
183
|
|
|
|
|
|
|
*end_Para = *_end_generic; |
184
|
|
|
|
|
|
|
*end_Verbatim = *_end_generic; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub _start_fcode { |
187
|
676
|
|
|
676
|
|
1219
|
my ($type, $self, $flags) = @_; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# How many brackets is set by BlackBox unless the count is 1 |
190
|
|
|
|
|
|
|
my $bracket_count = (exists $flags->{'~bracket_count'}) |
191
|
676
|
100
|
|
|
|
1206
|
? $flags->{'~bracket_count'} |
192
|
|
|
|
|
|
|
: 1; |
193
|
676
|
|
|
|
|
1939
|
$self->handle_text($type . ( "<" x $bracket_count)); |
194
|
|
|
|
|
|
|
|
195
|
676
|
|
|
|
|
1202
|
my $rspacer = ""; |
196
|
676
|
100
|
|
|
|
1264
|
if ($bracket_count > 1) { |
197
|
|
|
|
|
|
|
my $lspacer = (exists $flags->{'~lspacer'}) |
198
|
18
|
100
|
|
|
|
44
|
? $flags->{'~lspacer'} |
199
|
|
|
|
|
|
|
: " "; |
200
|
18
|
|
|
|
|
38
|
$self->handle_text($lspacer); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
$rspacer = (exists $flags->{'~rspacer'}) |
203
|
18
|
100
|
|
|
|
39
|
? $flags->{'~rspacer'} |
204
|
|
|
|
|
|
|
: " "; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# BlackBox doesn't output things for for the ending code callbacks, so save |
208
|
|
|
|
|
|
|
# what we need. |
209
|
676
|
|
|
|
|
790
|
push @{$self->{'fcode_end'}}, [ $bracket_count, $rspacer ]; |
|
676
|
|
|
|
|
2010
|
|
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
60
|
|
|
60
|
0
|
146
|
sub start_B { _start_fcode('B', @_); } |
213
|
359
|
|
|
359
|
0
|
795
|
sub start_C { _start_fcode('C', @_); } |
214
|
22
|
|
|
22
|
0
|
48
|
sub start_E { _start_fcode('E', @_); } |
215
|
53
|
|
|
53
|
0
|
120
|
sub start_F { _start_fcode('F', @_); } |
216
|
85
|
|
|
85
|
0
|
198
|
sub start_I { _start_fcode('I', @_); } |
217
|
3
|
|
|
3
|
0
|
12
|
sub start_S { _start_fcode('S', @_); } |
218
|
1
|
|
|
1
|
0
|
4
|
sub start_X { _start_fcode('X', @_); } |
219
|
4
|
|
|
4
|
0
|
14
|
sub start_Z { _start_fcode('Z', @_); } |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub _end_fcode { |
222
|
676
|
|
|
676
|
|
965
|
my $self = shift; |
223
|
676
|
|
|
|
|
817
|
my $fcode_end = pop @{$self->{'fcode_end'}}; |
|
676
|
|
|
|
|
1018
|
|
224
|
676
|
|
|
|
|
938
|
my $bracket_count = 1; |
225
|
676
|
|
|
|
|
881
|
my $rspacer = ""; |
226
|
|
|
|
|
|
|
|
227
|
676
|
50
|
|
|
|
1337
|
if (! defined $fcode_end) { # If BlackBox is working, this shouldn't |
228
|
|
|
|
|
|
|
# happen, but verify |
229
|
0
|
|
|
|
|
0
|
$self->whine($self->{line_count}, "Extra '>'"); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
else { |
232
|
676
|
|
|
|
|
1066
|
$bracket_count = $fcode_end->[0]; |
233
|
676
|
|
|
|
|
936
|
$rspacer = $fcode_end->[1]; |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
676
|
100
|
|
|
|
1119
|
$self->handle_text($rspacer) if $bracket_count > 1; |
237
|
676
|
|
|
|
|
1329
|
$self->handle_text(">" x $bracket_count); |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
*end_B = *_end_fcode; |
241
|
|
|
|
|
|
|
*end_C = *_end_fcode; |
242
|
|
|
|
|
|
|
*end_E = *_end_fcode; |
243
|
|
|
|
|
|
|
*end_F = *_end_fcode; |
244
|
|
|
|
|
|
|
*end_I = *_end_fcode; |
245
|
|
|
|
|
|
|
*end_S = *_end_fcode; |
246
|
|
|
|
|
|
|
*end_X = *_end_fcode; |
247
|
|
|
|
|
|
|
*end_Z = *_end_fcode; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub start_L { |
250
|
89
|
|
|
89
|
0
|
227
|
_start_fcode('L', @_); |
251
|
89
|
|
|
|
|
222
|
$_[0]->handle_text($_[1]->{raw}); |
252
|
89
|
|
|
|
|
179
|
$_[0]->{inL}++ |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub end_L { |
256
|
89
|
|
|
89
|
0
|
138
|
my $self = shift; |
257
|
89
|
|
|
|
|
128
|
$self->{inL}--; |
258
|
89
|
50
|
|
|
|
280
|
if ($self->{inL} < 0) { # If BlackBox is working, this shouldn't |
259
|
|
|
|
|
|
|
# happen, but verify |
260
|
0
|
|
|
|
|
0
|
$self->whine($self->{line_count}, "Extra '>' ending L<>"); |
261
|
0
|
|
|
|
|
0
|
$self->{inL} = 0; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
89
|
|
|
|
|
181
|
$self->_end_fcode(@_); |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub emit { |
268
|
1003
|
|
|
1003
|
0
|
1394
|
my $self = shift; |
269
|
|
|
|
|
|
|
|
270
|
1003
|
100
|
|
|
|
2193
|
if ($self->{buffer} ne "") { |
271
|
982
|
|
|
|
|
1253
|
print { $self->{'output_fh'} } "",$self->{buffer} ,"\n\n"; |
|
982
|
|
|
|
|
3494
|
|
272
|
|
|
|
|
|
|
|
273
|
982
|
|
|
|
|
1925
|
$self->{buffer} = ""; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
1003
|
|
|
|
|
1903
|
return; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
1; |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
__END__ |