line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::POM::View::TOC; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
29986
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
123
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Pod::POM::View::TOC - Generate the TOC of a POD with Pod::POM |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.02 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $source = "TOC.pm"; |
22
|
|
|
|
|
|
|
my $toc; |
23
|
|
|
|
|
|
|
my $parser = Pod::POM->new( warn => 0 ); |
24
|
|
|
|
|
|
|
Pod::POM->default_view("Pod::POM::View::TOC"); |
25
|
|
|
|
|
|
|
my $pom = $parser->parse_file( $source ); |
26
|
|
|
|
|
|
|
$toc = $view->print($pom); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 Format of C<$toc> for this document: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
NAME |
31
|
|
|
|
|
|
|
VERSION |
32
|
|
|
|
|
|
|
SYNOPSIS |
33
|
|
|
|
|
|
|
Format of $toc |
34
|
|
|
|
|
|
|
AUTHOR |
35
|
|
|
|
|
|
|
SUPPORT |
36
|
|
|
|
|
|
|
ACKNOWLEDGEMENTS |
37
|
|
|
|
|
|
|
COPYRIGHT & LICENSE |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
There is a line break after each section. Subsections begin with tabulars |
40
|
|
|
|
|
|
|
to represent their depth. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 AUTHOR |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Moritz Onken, C<< <onken at houseofdesign.de> >> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SUPPORT |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
perldoc Pod::POM::View::TOC |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
You can also look for information at: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Pod-POM-View-TOC> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Pod-POM-View-TOC> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * CPAN Ratings |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Pod-POM-View-TOC> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * Search CPAN |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Pod-POM-View-TOC> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Thanks to Andy Wardley and his great L<Pod::Pom> module. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Copyright 2008 Moritz Onken, all rights reserved. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
86
|
|
|
|
|
|
|
under the same terms as Perl itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
require 5.004; |
92
|
|
|
|
|
|
|
|
93
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
52
|
|
94
|
2
|
|
|
2
|
|
735
|
use Pod::POM::Nodes; |
|
2
|
|
|
|
|
23228
|
|
|
2
|
|
|
|
|
112
|
|
95
|
2
|
|
|
2
|
|
835
|
use Pod::POM::View; |
|
2
|
|
|
|
|
857
|
|
|
2
|
|
|
|
|
59
|
|
96
|
2
|
|
|
2
|
|
11
|
use base qw( Pod::POM::View ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
190
|
|
97
|
2
|
|
|
2
|
|
12
|
use vars qw( $VERSION $DEBUG $ERROR $AUTOLOAD $MARKUP ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1505
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/); |
100
|
|
|
|
|
|
|
$DEBUG = 0 unless defined $DEBUG; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# create reverse lookup table mapping method name to original sequence |
103
|
|
|
|
|
|
|
$MARKUP = { |
104
|
|
|
|
|
|
|
map { ( $Pod::POM::Node::Sequence::NAME{ $_ } => $_ ) } |
105
|
|
|
|
|
|
|
keys %Pod::POM::Node::Sequence::NAME, |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub view_head1 { |
110
|
7
|
|
|
7
|
0
|
167
|
my ($self, $head1) = @_; |
111
|
7
|
|
|
|
|
26
|
my $title = $head1->title->present($self); |
112
|
7
|
|
|
|
|
58
|
return "$title\n". $head1->content->present($self);; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub view_head2 { |
117
|
2
|
|
|
2
|
0
|
50
|
my ($self, $head2) = @_; |
118
|
2
|
|
|
|
|
37
|
my $title = $head2->title->present($self); |
119
|
2
|
|
|
|
|
20
|
return "\t$title\n". $head2->content->present($self);; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub view_head3 { |
124
|
1
|
|
|
1
|
0
|
29
|
my ($self, $head3) = @_; |
125
|
1
|
|
|
|
|
9
|
my $title = $head3->title->present($self); |
126
|
1
|
|
|
|
|
14
|
return "\t\t$title\n". $head3->content->present($self);; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub view_head4 { |
131
|
0
|
|
|
0
|
0
|
0
|
my ($self, $head4) = @_; |
132
|
0
|
|
|
|
|
0
|
my $title = $head4->title->present($self); |
133
|
0
|
|
|
|
|
0
|
return "\t\t\t$title\n". $head4->content->present($self);; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub view { |
139
|
26
|
|
|
26
|
1
|
751
|
my ($self, $type, $item) = @_; |
140
|
|
|
|
|
|
|
|
141
|
26
|
50
|
|
|
|
72
|
if ($type =~ s/^seq_//) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
142
|
26
|
100
|
|
|
|
52
|
if ($type eq 'text') { |
143
|
24
|
|
|
|
|
103
|
return "$item"; |
144
|
|
|
|
|
|
|
} |
145
|
2
|
50
|
|
|
|
13
|
if ($type = $MARKUP->{ $type }) { |
146
|
2
|
|
|
|
|
17
|
return "$item"; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
elsif (ref $item eq 'HASH') { |
150
|
0
|
0
|
|
|
|
0
|
if (defined $item->{ content }) { |
|
|
0
|
|
|
|
|
|
151
|
0
|
|
|
|
|
0
|
return $item->{ content }->present($self); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
elsif (defined $item->{ text }) { |
154
|
0
|
|
|
|
|
0
|
my $text = $item->{ text }; |
155
|
0
|
0
|
|
|
|
0
|
return ref $text ? $text->present($self) : $text; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else { |
158
|
0
|
|
|
|
|
0
|
return ''; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
elsif (! ref $item) { |
162
|
0
|
|
|
|
|
0
|
return $item; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
else { |
165
|
0
|
|
|
|
|
0
|
return ''; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub view_pod { |
171
|
5
|
|
|
5
|
0
|
5006
|
my ($self, $pod) = @_; |
172
|
5
|
|
|
|
|
45
|
return $pod->content->present($self); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
*view_over = *view_item = *view_for = *view_begin = *view_meta = \&view_pod; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub view_textblock { |
181
|
11
|
|
|
11
|
0
|
83
|
my ($self, $text) = @_; |
182
|
11
|
|
|
|
|
44
|
return ""; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub view_verbatim { |
187
|
2
|
|
|
2
|
0
|
26
|
my ($self, $text) = @_; |
188
|
2
|
|
|
|
|
9
|
return ""; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $entities = { |
192
|
|
|
|
|
|
|
gt => '>', |
193
|
|
|
|
|
|
|
lt => '<', |
194
|
|
|
|
|
|
|
amp => '&', |
195
|
|
|
|
|
|
|
quot => '"', |
196
|
|
|
|
|
|
|
}; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub view_seq_entity { |
200
|
1
|
|
|
1
|
0
|
9
|
my ($self, $entity) = @_; |
201
|
1
|
|
33
|
|
|
9
|
return $entities->{ $entity } || $entity; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|