line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::TOC; |
2
|
2
|
|
|
2
|
|
10687
|
use strict; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
130
|
|
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
5811
|
use parent qw( Pod::Simple ); |
|
2
|
|
|
|
|
553
|
|
|
2
|
|
|
|
|
13
|
|
5
|
2
|
|
|
2
|
|
111832
|
use vars qw( $VERSION ); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
102
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
60
|
|
8
|
2
|
|
|
2
|
|
9
|
no warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
209
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.12'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
2
|
|
|
2
|
|
6
|
my @Head_levels = 0 .. 4; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
4
|
my %flags = map { ( "head$_", $_ ) } @Head_levels; |
|
10
|
|
|
|
|
35
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
12
|
foreach my $directive ( keys %flags ) { |
18
|
2
|
|
|
2
|
|
10
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
498
|
|
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
|
|
59
|
*{"_start_$directive"} = sub { |
21
|
9
|
|
|
9
|
|
32
|
$_[0]->_set_flag( "_start_$directive" ); |
22
|
9
|
|
|
|
|
11
|
print { $_[0]->output_fh } "\t" x ( $_[0]->_get_flag - 1 ) |
|
9
|
|
|
|
|
25
|
|
23
|
10
|
|
|
|
|
34
|
}; |
24
|
|
|
|
|
|
|
|
25
|
10
|
|
|
|
|
911
|
*{"_end_$directive"} = sub { |
26
|
9
|
|
|
9
|
|
27
|
$_[0]->_set_flag( "_end_$directive" ); |
27
|
9
|
|
|
|
|
11
|
print { $_[0]->output_fh } "\n" |
|
9
|
|
|
|
|
21
|
|
28
|
10
|
|
|
|
|
32
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
18
|
|
|
18
|
|
55
|
sub _is_valid_tag { exists $flags{ $_[1] } } |
32
|
9
|
|
|
9
|
|
31
|
sub _get_tag { $flags{ $_[1] } } |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _handle_element { |
36
|
42
|
|
|
42
|
|
64
|
my( $self, $element, $args ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
42
|
|
|
|
|
157
|
my $caller_sub = ( caller(1) )[3]; |
39
|
42
|
50
|
|
|
|
299
|
return unless $caller_sub =~ s/.*_(start|end)$/_${1}_$element/; |
40
|
|
|
|
|
|
|
|
41
|
42
|
|
|
|
|
145
|
my $sub = $self->can( $caller_sub ); |
42
|
|
|
|
|
|
|
|
43
|
42
|
100
|
|
|
|
141
|
$sub->( $self, $args ) if $sub; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _handle_element_start { |
47
|
21
|
|
|
21
|
|
9502
|
my $self = shift; |
48
|
21
|
|
|
|
|
46
|
$self->_handle_element( @_ ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _handle_element_end { |
52
|
21
|
|
|
21
|
|
217
|
my $self = shift; |
53
|
21
|
|
|
|
|
42
|
$self->_handle_element( @_ ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _handle_text { |
57
|
20
|
100
|
|
20
|
|
149
|
return unless $_[0]->_get_flag; |
58
|
|
|
|
|
|
|
|
59
|
9
|
|
|
|
|
12
|
print { $_[0]->output_fh } $_[1]; |
|
9
|
|
|
|
|
21
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
my $Flag; |
65
|
|
|
|
|
|
|
|
66
|
29
|
|
|
29
|
|
163
|
sub _get_flag { $Flag } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _set_flag { |
69
|
18
|
|
|
18
|
|
26
|
my( $self, $caller ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
18
|
50
|
|
|
|
34
|
return unless $caller; |
72
|
|
|
|
|
|
|
|
73
|
18
|
100
|
|
|
|
47
|
my $on = $caller =~ m/^_start_/ ? 1 : 0; |
74
|
18
|
100
|
|
|
|
47
|
my $off = $caller =~ m/^_end_/ ? 1 : 0; |
75
|
|
|
|
|
|
|
|
76
|
18
|
50
|
66
|
|
|
57
|
unless( $on or $off ) { return }; |
|
0
|
|
|
|
|
0
|
|
77
|
|
|
|
|
|
|
|
78
|
18
|
|
|
|
|
77
|
my( $tag ) = $caller =~ m/^_.*?_(.*)/g; |
79
|
|
|
|
|
|
|
|
80
|
18
|
50
|
|
|
|
36
|
return unless $self->_is_valid_tag( $tag ); |
81
|
|
|
|
|
|
|
|
82
|
18
|
|
|
|
|
25
|
$Flag = do { |
83
|
18
|
100
|
|
|
|
52
|
if( $on ) { $self->_get_tag( $tag ) } # set the flag if we're on |
|
9
|
50
|
|
|
|
17
|
|
84
|
9
|
|
|
|
|
29
|
elsif( $off ) { undef } # clear if we're off |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Pod::TOC - Extract a table of contents from a Pod file |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This is a C subclass, so it can do the same things. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
use Pod::TOC; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $parser = Pod::TOC->new; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $toc; |
103
|
|
|
|
|
|
|
open my($output_fh), ">", \$toc; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$parser->output_fh( $output_fh ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$parser->parse_file( $input_file ); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 DESCRIPTION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is a C subclass to extract a table of contents |
112
|
|
|
|
|
|
|
from a pod file. It has the same interface as C, and |
113
|
|
|
|
|
|
|
only changes the internal bits. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SEE ALSO |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L, L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This source is in Github: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
https://github.com/briandfoy/pod-perldoc-totoc |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHOR |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
brian d foy, C<< >> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright (c) 2006-2013, brian d foy, All Rights Reserved. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You may redistribute this under the same terms as Perl itself. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |