| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pod::Section; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16516
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
16
|
|
|
5
|
1
|
|
|
1
|
|
421
|
use IO::String; |
|
|
1
|
|
|
|
|
2608
|
|
|
|
1
|
|
|
|
|
22
|
|
|
6
|
1
|
|
|
1
|
|
416
|
use Pod::Abstract; |
|
|
1
|
|
|
|
|
18486
|
|
|
|
1
|
|
|
|
|
26
|
|
|
7
|
1
|
|
|
1
|
|
640
|
use Pod::Perldoc; |
|
|
1
|
|
|
|
|
20666
|
|
|
|
1
|
|
|
|
|
32
|
|
|
8
|
1
|
|
|
1
|
|
469
|
use Pod::Perldoc::ToPod; |
|
|
1
|
|
|
|
|
2106
|
|
|
|
1
|
|
|
|
|
25
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use base qw/Exporter/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
78
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use Carp qw/croak/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
635
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw/select_podsection/; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub select_podsection { |
|
15
|
0
|
|
|
0
|
1
|
|
my ($module, @functions) = @_; |
|
16
|
0
|
|
|
|
|
|
my $pod = Pod::Perldoc->new; |
|
17
|
0
|
0
|
|
|
|
|
my @path = $pod->grand_search_init([$module]) or croak "Cannot find $module"; |
|
18
|
0
|
|
|
|
|
|
my $parser = Pod::Perldoc::ToPod->new; |
|
19
|
0
|
|
|
|
|
|
my $fh = IO::String->new; |
|
20
|
0
|
|
|
|
|
|
$parser->parse_from_file(@path, $fh); |
|
21
|
0
|
|
|
|
|
|
seek $fh, 0, 0; |
|
22
|
0
|
|
|
|
|
|
my $pa = Pod::Abstract->load_file($fh); |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my @function_node; |
|
25
|
0
|
|
|
|
|
|
my $func_regexp = join "|", @functions; |
|
26
|
0
|
|
|
|
|
|
$func_regexp = qr{((^($func_regexp))|[^a-zA-Z_0-9_\$]($func_regexp)|(\->($func_regexp))|(\s($func_regexp)))\b}; |
|
27
|
0
|
|
|
|
|
|
my @try = ($pa, $func_regexp); |
|
28
|
0
|
0
|
|
|
|
|
if ($module eq 'Carp') { |
|
29
|
0
|
|
|
|
|
|
@function_node = _try_from_carp(@try); |
|
30
|
|
|
|
|
|
|
} else { |
|
31
|
|
|
|
|
|
|
CHECK: { |
|
32
|
0
|
0
|
|
|
|
|
@function_node = _try_head(2, @try) and last; |
|
|
0
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
@function_node = _try_head_item(2, @try) and last; |
|
34
|
0
|
0
|
|
|
|
|
@function_node = _try_head_item(1, @try) and last; |
|
35
|
0
|
0
|
|
|
|
|
@function_node = _try_head(3, @try) and last; |
|
36
|
0
|
0
|
|
|
|
|
@function_node = _try_head_item(3, @try) and last; |
|
37
|
0
|
0
|
|
|
|
|
@function_node = _try_head(4, @try) and last; |
|
38
|
0
|
0
|
|
|
|
|
@function_node = _try_head_item(4, @try) and last; |
|
39
|
0
|
0
|
|
|
|
|
@function_node = _try_head(1, @try) and last; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
0
|
|
|
|
|
|
my @pod; |
|
43
|
0
|
|
|
|
|
|
foreach my $pod (@function_node) { |
|
44
|
0
|
|
|
|
|
|
$pod =~s{L(.+?)>}{L<$module/$1>}gs; |
|
45
|
0
|
|
|
|
|
|
push @pod, $pod; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
0
|
0
|
|
|
|
|
return wantarray ? @pod : join "", @pod; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _try_head_item { |
|
51
|
0
|
|
|
0
|
|
|
my ($n, $pa, $regexp) = @_; |
|
52
|
0
|
|
|
|
|
|
my @target; |
|
53
|
0
|
|
|
|
|
|
push @target, "/head$_" for 1 .. $n; |
|
54
|
0
|
|
|
|
|
|
my $target = join '', @target; |
|
55
|
0
|
|
|
|
|
|
my @nodes = $pa->select("$target/over/item"); |
|
56
|
0
|
|
|
|
|
|
my @function_node; |
|
57
|
0
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
58
|
0
|
|
|
|
|
|
foreach my $f ($node->param('label')->children) { |
|
59
|
0
|
0
|
|
|
|
|
if ($f->text =~ $regexp) { |
|
60
|
0
|
|
|
|
|
|
push @function_node, $node->pod; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
0
|
|
|
|
|
|
return @function_node; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _try_head { |
|
68
|
0
|
|
|
0
|
|
|
my ($n, $pa, $regexp) = @_; |
|
69
|
0
|
|
|
|
|
|
my @target; |
|
70
|
0
|
|
|
|
|
|
push @target, "/head$_" for 1 .. $n; |
|
71
|
0
|
|
|
|
|
|
my $target = join '', @target; |
|
72
|
0
|
|
|
|
|
|
my @nodes = $pa->select($target); |
|
73
|
0
|
|
|
|
|
|
my @function_node; |
|
74
|
0
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
75
|
0
|
|
|
|
|
|
foreach my $f ($node->param('heading')->children) { |
|
76
|
0
|
0
|
|
|
|
|
if ($f->text =~ $regexp) { |
|
77
|
0
|
|
|
|
|
|
push @function_node, $node->pod; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
|
|
|
|
|
return @function_node; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _try_from_carp { |
|
85
|
0
|
|
|
0
|
|
|
my ($pa, $regexp) = @_; |
|
86
|
0
|
|
|
|
|
|
my @nodes = $pa->select('/head1'); |
|
87
|
0
|
|
|
|
|
|
my @function_node; |
|
88
|
0
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
89
|
0
|
|
|
|
|
|
foreach my $f ($node->param('heading')->children) { |
|
90
|
0
|
0
|
|
|
|
|
if ($f->text =~ m{NAME}) { |
|
91
|
0
|
|
|
|
|
|
my $pod = $node->pod; |
|
92
|
0
|
|
|
|
|
|
$pod =~ s{=head1 NAME}{}; |
|
93
|
0
|
|
|
|
|
|
$pod =~ s{^(\w+)[\s\t]*(.+)$}{=head2 $1\n\n$2}gm; |
|
94
|
0
|
0
|
|
|
|
|
if ($pod =~ $regexp) { |
|
95
|
0
|
|
|
|
|
|
push @function_node, $pod; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
0
|
|
|
|
|
|
return @function_node; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Pod::Section - select specified section from Module's POD |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 VERSION |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Version 0.02 |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
use Pod::Section qw/select_podsection/; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my @function_pods = select_podsection($module, @functions); |
|
121
|
|
|
|
|
|
|
my @section_pods = select_podsection($module, @sections); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
In scalar context, pod is joined as one scalar. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $function_pods = select_podsection($module, @functions); |
|
126
|
|
|
|
|
|
|
my $section_pods = select_podsection($module, @sections); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
use podsection on shell |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
% podsection Catalyst req res |
|
131
|
|
|
|
|
|
|
$c->req |
|
132
|
|
|
|
|
|
|
Returns the current Catalyst::Request object, giving access to |
|
133
|
|
|
|
|
|
|
information about the current client request (including parameters, |
|
134
|
|
|
|
|
|
|
cookies, HTTP headers, etc.). See Catalyst::Request. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$c->res |
|
137
|
|
|
|
|
|
|
Returns the current Catalyst::Response object, see there for details. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 EXPORT |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 select_podsection |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
See SYNOPSIS. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Ktat, C<< >> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 BUGS |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The way to search section is poor. This cannot find section correctly in some modules. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
154
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
155
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SUPPORT |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
perldoc Pod::Section |
|
162
|
|
|
|
|
|
|
perldoc podsection |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
You can also look for information at: |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over 4 |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
L |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * Search CPAN |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=back |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 Pod::Select |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This also select section, but cannot search function/method explanation. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Copyright 2010 Ktat. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
199
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
200
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; # End of Pod::Section |