| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PPI::Token::Pod; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PPI::Token::Pod - Sections of POD in Perl documents |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 INHERITANCE |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
PPI::Token::Pod |
|
12
|
|
|
|
|
|
|
isa PPI::Token |
|
13
|
|
|
|
|
|
|
isa PPI::Element |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
A single C object represents a complete section of POD |
|
18
|
|
|
|
|
|
|
documentation within a Perl document. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This class provides some additional methods beyond those provided by its |
|
23
|
|
|
|
|
|
|
L and L parent classes. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
65
|
|
|
65
|
|
508
|
use strict; |
|
|
65
|
|
|
|
|
133
|
|
|
|
65
|
|
|
|
|
2209
|
|
|
28
|
65
|
|
|
65
|
|
374
|
use Params::Util qw{_INSTANCE}; |
|
|
65
|
|
|
|
|
120
|
|
|
|
65
|
|
|
|
|
2767
|
|
|
29
|
65
|
|
|
65
|
|
380
|
use PPI::Token (); |
|
|
65
|
|
|
|
|
117
|
|
|
|
65
|
|
|
|
|
34914
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '1.277'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our @ISA = "PPI::Token"; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
##################################################################### |
|
40
|
|
|
|
|
|
|
# PPI::Token::Pod Methods |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 merge @podtokens |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The C constructor takes a number of C objects, |
|
47
|
|
|
|
|
|
|
and returns a new object that represents one combined POD block with |
|
48
|
|
|
|
|
|
|
the content of all of them. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Returns a new C object, or C on error. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub merge { |
|
55
|
1
|
50
|
|
1
|
1
|
1025
|
my $class = (! ref $_[0]) ? shift : return undef; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Check there are no bad arguments |
|
58
|
1
|
50
|
|
|
|
3
|
if ( grep { ! _INSTANCE($_, 'PPI::Token::Pod') } @_ ) { |
|
|
2
|
|
|
|
|
83
|
|
|
59
|
0
|
|
|
|
|
0
|
return undef; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Get the tokens, and extract the lines |
|
63
|
1
|
50
|
|
|
|
5
|
my @content = ( map { [ $_->lines ] } @_ ) or return undef; |
|
|
2
|
|
|
|
|
7
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Remove the leading =pod tags, trailing =cut tags, and any empty lines |
|
66
|
|
|
|
|
|
|
# between them and the pod contents. |
|
67
|
1
|
|
|
|
|
4
|
foreach my $pod ( @content ) { |
|
68
|
|
|
|
|
|
|
# Leading =pod tag |
|
69
|
2
|
50
|
33
|
|
|
14
|
if ( @$pod and $pod->[0] =~ /^=pod\b/o ) { |
|
70
|
2
|
|
|
|
|
4
|
shift @$pod; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Trailing =cut tag |
|
74
|
2
|
100
|
66
|
|
|
10
|
if ( @$pod and $pod->[-1] =~ /^=cut\b/o ) { |
|
75
|
1
|
|
|
|
|
3
|
pop @$pod; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Leading and trailing empty lines |
|
79
|
2
|
|
66
|
|
|
9
|
while ( @$pod and $pod->[0] eq '' ) { shift @$pod } |
|
|
2
|
|
|
|
|
8
|
|
|
80
|
2
|
|
66
|
|
|
9
|
while ( @$pod and $pod->[-1] eq '' ) { pop @$pod } |
|
|
1
|
|
|
|
|
4
|
|
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Remove any empty pod sections, and add the =pod and =cut tags |
|
84
|
|
|
|
|
|
|
# for the merged pod back to it. |
|
85
|
1
|
|
|
|
|
5
|
@content = ( [ '=pod' ], grep { @$_ } @content, [ '=cut' ] ); |
|
|
3
|
|
|
|
|
5
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Create the new object |
|
88
|
1
|
|
|
|
|
4
|
$class->new( join "\n", map { join( "\n", @$_ ) . "\n" } @content ); |
|
|
4
|
|
|
|
|
15
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=pod |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 lines |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The C method takes the string of POD and breaks it into lines, |
|
96
|
|
|
|
|
|
|
returning them as a list. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub lines { |
|
101
|
2
|
|
|
2
|
1
|
25
|
split /(?:\015{1,2}\012|\015|\012)/, $_[0]->{content}; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
##################################################################### |
|
110
|
|
|
|
|
|
|
# PPI::Element Methods |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
### XS -> PPI/XS.xs:_PPI_Token_Pod__significant 0.900+ |
|
113
|
|
|
|
|
|
|
sub significant() { '' } |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
##################################################################### |
|
120
|
|
|
|
|
|
|
# Tokenizer Methods |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub __TOKENIZER__on_line_start { |
|
123
|
16019
|
|
|
16019
|
|
21243
|
my $t = $_[1]; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# Add the line to the token first |
|
126
|
16019
|
|
|
|
|
32452
|
$t->{token}->{content} .= $t->{line}; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Check the line to see if it is a =cut line |
|
129
|
16019
|
100
|
|
|
|
33453
|
if ( $t->{line} =~ /^=(\w+)/ ) { |
|
130
|
|
|
|
|
|
|
# End of the token |
|
131
|
2578
|
100
|
|
|
|
7289
|
$t->_finalize_token if $1 eq 'cut'; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
16019
|
|
|
|
|
25418
|
0; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=pod |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SUPPORT |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
See the L in the main module. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright 2001 - 2011 Adam Kennedy. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
154
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
157
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |