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