line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Tree::PerlFunc; |
2
|
1
|
|
|
1
|
|
2938274
|
use 5.006; |
|
1
|
|
|
|
|
11
|
|
3
|
1
|
|
|
1
|
|
14
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
80
|
|
5
|
1
|
|
|
1
|
|
457
|
use Pod::Tree; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
551
|
use Pod::Tree::HTML; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
535
|
use Pod::Tree::PerlUtil; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.31'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
42
|
use base qw(Pod::Tree::PerlUtil); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1536
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
0
|
|
|
0
|
1
|
|
my ( $class, $perl_dir, $html_dir, $link_map, %options ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my %defaults = ( |
17
|
|
|
|
|
|
|
bgcolor => '#ffffff', |
18
|
|
|
|
|
|
|
text => '#000000' |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $options = { %defaults, %options, link_map => $link_map }; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $perl_func = { |
24
|
|
|
|
|
|
|
perl_dir => $perl_dir, |
25
|
|
|
|
|
|
|
html_dir => $html_dir, |
26
|
|
|
|
|
|
|
pod_dir => 'pod', |
27
|
|
|
|
|
|
|
func_dir => 'func', |
28
|
|
|
|
|
|
|
page => 'perlfunc', |
29
|
|
|
|
|
|
|
options => $options |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
bless $perl_func, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub scan { |
36
|
0
|
|
|
0
|
1
|
|
my $perl_func = shift; |
37
|
0
|
|
|
|
|
|
$perl_func->report1("scan"); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$perl_func->load_tree; |
40
|
0
|
|
|
|
|
|
$perl_func->scan_tree; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub load_tree { |
44
|
0
|
|
|
0
|
0
|
|
my $perl_func = shift; |
45
|
0
|
|
|
|
|
|
my $perl_dir = $perl_func->{perl_dir}; |
46
|
0
|
|
|
|
|
|
my $pod_dir = $perl_func->{pod_dir}; |
47
|
0
|
|
|
|
|
|
my $page = $perl_func->{page}; |
48
|
0
|
|
|
|
|
|
my $source = "$perl_dir/$pod_dir/$page.pod"; |
49
|
0
|
|
|
|
|
|
my $win_source = "$perl_dir/lib/$pod_dir/$page.pod"; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $tree = Pod::Tree->new; |
52
|
0
|
0
|
0
|
|
|
|
$tree->load_file($source) or # for building the doc set from a Perl distribution |
53
|
|
|
|
|
|
|
$tree->load_file($win_source) or # for building the doc set from a Windows installation |
54
|
|
|
|
|
|
|
die "Pod::Tree::PerlFunc::scan: Can't find $source or $win_source\n"; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $node = $tree->pop; |
57
|
0
|
|
|
|
|
|
my $funcs = $node->get_children; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$perl_func->{tree} = $tree; |
60
|
0
|
|
|
|
|
|
$perl_func->{funcs} = $funcs; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub scan_tree { |
64
|
0
|
|
|
0
|
0
|
|
my $perl_func = shift; |
65
|
0
|
|
|
|
|
|
my $funcs = $perl_func->{funcs}; |
66
|
0
|
|
|
|
|
|
my @funcs = @$funcs; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $link_map = $perl_func->{options}{link_map}; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
while (@funcs) { |
71
|
0
|
|
|
|
|
|
my @items = Shift_Items( \@funcs ); |
72
|
0
|
|
|
|
|
|
my ( $func0, $file0 ) = Parse_Name( $items[0] ); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
for my $item (@items) { |
75
|
0
|
|
|
|
|
|
my ( $func, $file ) = Parse_Name($item); |
76
|
0
|
|
|
|
|
|
$perl_func->report2($func); |
77
|
0
|
|
|
|
|
|
$perl_func->{index}{$func} = $file0; |
78
|
0
|
|
|
|
|
|
$link_map->add_func( $file, $file0 ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub index { |
84
|
0
|
|
|
0
|
1
|
|
my $perl_func = shift; |
85
|
0
|
|
|
|
|
|
$perl_func->report1("index"); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$perl_func->add_links; |
88
|
0
|
|
|
|
|
|
$perl_func->add_index; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $tree = $perl_func->{tree}; |
91
|
0
|
|
|
|
|
|
my $html_dir = $perl_func->{html_dir}; |
92
|
0
|
|
|
|
|
|
my $pod_dir = $perl_func->{pod_dir}; |
93
|
0
|
|
|
|
|
|
my $page = $perl_func->{page}; |
94
|
0
|
|
|
|
|
|
my $options = $perl_func->{options}; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
$perl_func->mkdir("$html_dir/$pod_dir/"); |
97
|
0
|
|
|
|
|
|
$options->{link_map}->set_depth(1); |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $dest = "$html_dir/$pod_dir/$page.html"; |
100
|
0
|
|
|
|
|
|
my $html = Pod::Tree::HTML->new( $tree, $dest, %$options ); |
101
|
0
|
|
|
|
|
|
$html->translate; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub add_links { |
105
|
0
|
|
|
0
|
0
|
|
my $perl_func = shift; |
106
|
0
|
|
|
|
|
|
my $tree = $perl_func->{tree}; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
0
|
|
|
$tree->walk( sub { $perl_func->_add_links(shift) } ); |
|
0
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _add_links { |
112
|
0
|
|
|
0
|
|
|
my ( $perl_func, $node ) = @_; |
113
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
|
$node->is_sequence or return 1; |
115
|
0
|
0
|
|
|
|
|
$node->get_letter eq 'C' or return 1; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my ($func) = Parse_Name($node); |
118
|
0
|
|
|
|
|
|
my $file = $perl_func->{index}{$func}; |
119
|
0
|
0
|
|
|
|
|
$file or return 1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# :TRICKY: *replaces* the node in the tree |
122
|
0
|
|
|
|
|
|
my $page = $perl_func->{page}; |
123
|
0
|
|
|
|
|
|
$_[1] = Pod::Tree::Node->link( $node, $page, $file ); |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
0; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub add_index { |
129
|
0
|
|
|
0
|
0
|
|
my $perl_func = shift; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my %funcs; |
132
|
0
|
|
|
|
|
|
my $index = $perl_func->{index}; |
133
|
0
|
|
|
|
|
|
for my $func ( sort keys %$index ) { |
134
|
0
|
|
|
|
|
|
my $file = $index->{$func}; |
135
|
0
|
|
|
|
|
|
my $letter = substr( $func, 0, 1 ); |
136
|
0
|
|
|
|
|
|
push @{ $funcs{$letter} }, [ $func, $file ]; |
|
0
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $page = $perl_func->{page}; |
140
|
0
|
|
|
|
|
|
my @lines; |
141
|
0
|
|
|
|
|
|
for my $letter ( sort keys %funcs ) { |
142
|
0
|
|
|
|
|
|
my $funcs = $funcs{$letter}; |
143
|
0
|
|
|
|
|
|
my @links = map {"L[0]>|$page/$_->[1]>"} @$funcs; |
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my $line = join ", ", @links; |
145
|
0
|
|
|
|
|
|
push @lines, $line; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my $pod = join "\n\n", @lines; |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
my $tree = Pod::Tree->new; |
151
|
0
|
|
|
|
|
|
$tree->load_string($pod); |
152
|
0
|
|
|
|
|
|
my $children = $tree->get_root->get_children; |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
$perl_func->{tree}->push(@$children); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub translate { |
158
|
0
|
|
|
0
|
1
|
|
my $perl_func = shift; |
159
|
0
|
|
|
|
|
|
$perl_func->report1("translate"); |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
my $html_dir = $perl_func->{html_dir}; |
162
|
0
|
|
|
|
|
|
my $pod_dir = $perl_func->{pod_dir}; |
163
|
0
|
|
|
|
|
|
my $func_dir = $perl_func->{func_dir}; |
164
|
0
|
|
|
|
|
|
$perl_func->mkdir("$html_dir/$pod_dir/$func_dir"); |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $perl_dir = $perl_func->{perl_dir}; |
167
|
0
|
|
|
|
|
|
my $funcs = $perl_func->{funcs}; |
168
|
0
|
|
|
|
|
|
my $options = $perl_func->{options}; |
169
|
0
|
|
|
|
|
|
my $link_map = $options->{link_map}; |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
$link_map->set_depth(2); |
172
|
0
|
|
|
|
|
|
$link_map->force_func(1); |
173
|
0
|
|
|
|
|
|
$options->{toc} = 0; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
while (@$funcs) { |
176
|
0
|
|
|
|
|
|
my @items = Shift_Items($funcs); |
177
|
0
|
|
|
|
|
|
my ( $func, $file ) = Parse_Name( $items[0] ); |
178
|
0
|
|
|
|
|
|
$perl_func->report2("func/$file"); |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
my $tree = Pod::Tree->new; |
181
|
0
|
|
|
|
|
|
$tree->load_string("=head1 $func\n\n=over 4\n\n=back"); |
182
|
0
|
|
|
|
|
|
my $list = $tree->get_root->get_children->[1]; |
183
|
0
|
|
|
|
|
|
$list->set_children( \@items ); |
184
|
0
|
|
|
|
|
|
$list->_set_list_type; |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
$options->{title} = $func; |
187
|
0
|
|
|
|
|
|
my $dest = "$html_dir/$pod_dir/$func_dir/$file.html"; |
188
|
0
|
|
|
|
|
|
my $html = Pod::Tree::HTML->new( $tree, $dest, %$options ); |
189
|
0
|
|
|
|
|
|
$html->translate; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
$link_map->force_func(0); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub Shift_Items { |
196
|
0
|
|
|
0
|
0
|
|
my $funcs = shift; |
197
|
0
|
|
|
|
|
|
my @items; |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
while (@$funcs) { |
200
|
0
|
|
|
|
|
|
my $item = shift @$funcs; |
201
|
0
|
|
|
|
|
|
push @items, $item; |
202
|
|
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
@$funcs or last; |
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
my ($func0) = Parse_Name($item); |
206
|
0
|
|
|
|
|
|
my ($func1) = Parse_Name( $funcs->[0] ); |
207
|
0
|
|
|
|
|
|
my $sibs0 = $item->get_siblings; |
208
|
0
|
0
|
0
|
|
|
|
$func0 eq $func1 or @$sibs0 == 0 or last; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
@items; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub Parse_Name { |
215
|
0
|
|
|
0
|
0
|
|
my $item = shift; |
216
|
0
|
|
|
|
|
|
my $text = $item->get_deep_text; |
217
|
0
|
|
|
|
|
|
my @words = split m([^\w\-]+), $text; |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
my $func = $words[0]; |
220
|
0
|
|
|
|
|
|
my $file = $func; |
221
|
0
|
|
|
|
|
|
$file =~ tr(A-Za-z0-9_-)()cd; |
222
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
( $func, $file ); |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
1 |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
__END__ |