line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Tree::PerlDist; |
2
|
1
|
|
|
1
|
|
7025481
|
use 5.006; |
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
4
|
1
|
|
|
1
|
|
34
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
105
|
|
5
|
1
|
|
|
1
|
|
816
|
use HTML::Stream; |
|
1
|
|
|
|
|
4361
|
|
|
1
|
|
|
|
|
59
|
|
6
|
1
|
|
|
1
|
|
497
|
use Pod::Tree; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
530
|
use Pod::Tree::HTML; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
9
|
|
8
|
1
|
|
|
1
|
|
596
|
use Pod::Tree::PerlUtil; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
14
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.31'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
46
|
use base qw(Pod::Tree::PerlUtil); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1518
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
0
|
|
|
0
|
1
|
|
my ( $class, $perl_dir, $html_dir, $link_map, %options ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my %defaults = ( |
18
|
|
|
|
|
|
|
bgcolor => '#ffffff', |
19
|
|
|
|
|
|
|
text => '#000000' |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my @stop_base = qw(Configure |
23
|
|
|
|
|
|
|
configpm configure |
24
|
|
|
|
|
|
|
installhtml installman installperl |
25
|
|
|
|
|
|
|
mv-if-diff |
26
|
|
|
|
|
|
|
perlsh); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $options = { %defaults, %options, link_map => $link_map }; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $perl_dist = { |
31
|
|
|
|
|
|
|
perl_dir => $perl_dir, |
32
|
|
|
|
|
|
|
html_dir => $html_dir, |
33
|
|
|
|
|
|
|
top_page => 'dist.html', |
34
|
|
|
|
|
|
|
stop_ext => [qw(SH c diff fixer h pl sym y)], |
35
|
|
|
|
|
|
|
stop_base => [@stop_base], |
36
|
|
|
|
|
|
|
depth => 0, |
37
|
|
|
|
|
|
|
options => $options |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
bless $perl_dist, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub scan { |
44
|
0
|
|
|
0
|
1
|
|
my $perl_dist = shift; |
45
|
0
|
|
|
|
|
|
$perl_dist->report1("scan"); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $perl_dir = $perl_dist->{perl_dir}; |
48
|
0
|
|
|
|
|
|
my $html_dir = $perl_dist->{html_dir}; |
49
|
0
|
0
|
|
|
|
|
opendir( DIR, $perl_dir ) or die "Can't opendir $perl_dir: $!\n"; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $stop_ext = $perl_dist->{stop_ext}; |
52
|
0
|
|
|
|
|
|
my %stop_ext = map { $_ => 1 } @$stop_ext; |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $stop_base = $perl_dist->{stop_base}; |
55
|
0
|
|
|
|
|
|
my %stop_base = map { $_ => 1 } @$stop_base; |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
for my $file ( readdir(DIR) ) { |
58
|
0
|
0
|
0
|
|
|
|
-f "$perl_dir/$file" and -T "$perl_dir/$file" or next; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my ( $base, $ext ) = split m(\.), $file; |
61
|
0
|
0
|
|
|
|
|
$stop_ext{$ext} and next; |
62
|
0
|
0
|
|
|
|
|
$stop_base{$base} and next; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$perl_dist->report2($file); |
65
|
0
|
|
|
|
|
|
$perl_dist->scan_file($file); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub scan_file { |
70
|
0
|
|
|
0
|
0
|
|
my ( $perl_dist, $file ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $perl_dir = $perl_dist->{perl_dir}; |
73
|
0
|
|
|
|
|
|
my $html_dir = $perl_dist->{html_dir}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $source = "$perl_dir/$file"; |
76
|
0
|
|
|
|
|
|
my $dest = "$html_dir/$file.html"; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $entry = { |
79
|
|
|
|
|
|
|
file => $file, |
80
|
|
|
|
|
|
|
source => $source, |
81
|
|
|
|
|
|
|
dest => $dest |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$perl_dist->{index}{$file} = $entry; |
85
|
0
|
|
|
|
|
|
$perl_dist->{options}{link_map}->add_page( $file, $file ); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my ( $base, $ext ) = split m(\.), $file; |
88
|
|
|
|
|
|
|
$base eq 'README' |
89
|
|
|
|
|
|
|
and $ext |
90
|
0
|
0
|
0
|
|
|
|
and $perl_dist->{options}{link_map}->add_page( "perl$ext", $file ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub index { |
94
|
0
|
|
|
0
|
1
|
|
my $perl_dist = shift; |
95
|
0
|
|
|
|
|
|
$perl_dist->report1("index"); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $html_dir = $perl_dist->{html_dir}; |
98
|
0
|
|
|
|
|
|
my $top_page = $perl_dist->{top_page}; |
99
|
0
|
|
|
|
|
|
my $dest = "$html_dir/$top_page"; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $fh = IO::File->new(">$dest"); |
102
|
0
|
0
|
|
|
|
|
defined $fh or die "Pod::Tree::PerlDist::index: Can't open $dest: $!\n"; |
103
|
0
|
|
|
|
|
|
my $stream = HTML::Stream->new($fh); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $options = $perl_dist->{options}; |
106
|
0
|
|
|
|
|
|
my $bgcolor = $options->{bgcolor}; |
107
|
0
|
|
|
|
|
|
my $text = $options->{text}; |
108
|
0
|
|
|
|
|
|
my $title = "Perl Distribution Documents"; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$stream->HTML->HEAD; |
111
|
0
|
|
|
|
|
|
$stream->TITLE->text($title)->_TITLE; |
112
|
0
|
|
|
|
|
|
$stream->_HEAD->BODY( BGCOLOR => $bgcolor, TEXT => $text ); |
113
|
0
|
|
|
|
|
|
$stream->H1->t($title)->_H1; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$perl_dist->_emit_entries($stream); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$stream->_BODY->_HTML; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_top_entry { |
121
|
0
|
|
|
0
|
1
|
|
my $perl_dist = shift; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
+{ |
124
|
|
|
|
|
|
|
URL => $perl_dist->{top_page}, |
125
|
0
|
|
|
|
|
|
description => 'distribution documents' |
126
|
|
|
|
|
|
|
}; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _emit_entries { |
130
|
0
|
|
|
0
|
|
|
my ( $perl_dist, $stream ) = @_; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $index = $perl_dist->{index}; |
133
|
0
|
|
|
|
|
|
my $options = $perl_dist->{options}; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
$stream->PRE; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
for my $name ( sort keys %$index ) { |
138
|
0
|
|
|
|
|
|
$stream->A( HREF => "$name.html" )->t($name)->_A->nl; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
$stream->_PRE; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub translate { |
145
|
0
|
|
|
0
|
1
|
|
my $perl_dist = shift; |
146
|
0
|
|
|
|
|
|
$perl_dist->report1("translate"); |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my $depth = $perl_dist->{depth}; |
149
|
0
|
|
|
|
|
|
my $index = $perl_dist->{index}; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
$perl_dist->{options}{link_map}->set_depth($depth); |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
for my $name ( sort keys %$index ) { |
154
|
0
|
|
|
|
|
|
$perl_dist->report2($name); |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
my $entry = $index->{$name}; |
157
|
0
|
|
|
|
|
|
my $source = $entry->{source}; |
158
|
0
|
0
|
|
|
|
|
open( my $FILE, '<', $source ) |
159
|
|
|
|
|
|
|
or die "Pod::Tree::PerlDist::translate: Can't open $source: $!\n"; |
160
|
0
|
|
|
|
|
|
my @file = <$FILE>; |
161
|
0
|
|
|
|
|
|
close $FILE; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $translate |
164
|
0
|
0
|
|
|
|
|
= ( grep {/^=\w+/} @file ) |
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
? 'translate_pod' |
166
|
|
|
|
|
|
|
: 'translate_text'; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$perl_dist->$translate($entry); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub translate_pod { |
173
|
0
|
|
|
0
|
0
|
|
my ( $perl_dist, $entry ) = @_; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my $source = $entry->{source}; |
176
|
0
|
|
|
|
|
|
my $dest = $entry->{dest}; |
177
|
0
|
|
|
|
|
|
my $options = $perl_dist->{options}; |
178
|
0
|
|
|
|
|
|
my $html = Pod::Tree::HTML->new( $source, $dest, %$options ); |
179
|
0
|
|
|
|
|
|
$html->translate; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub translate_text { |
183
|
0
|
|
|
0
|
0
|
|
my ( $perl_dist, $entry ) = @_; |
184
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
my $source = $entry->{source}; |
186
|
0
|
|
|
|
|
|
my $dest = $entry->{dest}; |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
my $fh = IO::File->new(">$dest"); |
189
|
0
|
0
|
|
|
|
|
defined $fh |
190
|
|
|
|
|
|
|
or die "Pod::Tree::PerlDist::translate_text: Can't open $dest: $!\n"; |
191
|
0
|
|
|
|
|
|
my $stream = HTML::Stream->new($fh); |
192
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
|
my $options = $perl_dist->{options}; |
194
|
0
|
|
|
|
|
|
my $bgcolor = $options->{bgcolor}; |
195
|
0
|
|
|
|
|
|
my $text = $options->{text}; |
196
|
0
|
|
|
|
|
|
my $title = $entry->{file}; |
197
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
$stream->HTML->HEAD; |
199
|
0
|
|
|
|
|
|
$stream->TITLE->text($title)->_TITLE; |
200
|
0
|
|
|
|
|
|
$stream->_HEAD->BODY( BGCOLOR => $bgcolor, TEXT => $text ); |
201
|
0
|
|
|
|
|
|
$stream->H1->t($title)->_H1; |
202
|
0
|
|
|
|
|
|
$stream->PRE; |
203
|
|
|
|
|
|
|
|
204
|
0
|
0
|
|
|
|
|
open( my $SOURCE, '<', $source ) |
205
|
|
|
|
|
|
|
or die "Pod::Tree::PerlDist::translate_text: Can't open $source: $!\n"; |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
while ( my $line = <$SOURCE> ) { |
208
|
0
|
|
|
|
|
|
$stream->t($line); |
209
|
|
|
|
|
|
|
} |
210
|
0
|
|
|
|
|
|
close $SOURCE; |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
$stream->_PRE; |
213
|
0
|
|
|
|
|
|
$stream->_BODY->_HTML; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1 |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
__END__ |