line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::ProjectDocs::Parser::XHTML; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
122
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
174
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.53'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
20
|
use base qw(Pod::Simple::XHTML); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2367
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
162772
|
use File::Basename(); |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
68
|
|
11
|
4
|
|
|
4
|
|
20
|
use File::Spec(); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
60
|
|
12
|
|
|
|
|
|
|
use HTML::Entities() |
13
|
4
|
|
|
4
|
|
31
|
; # Required for proper entity detection in Pod::Simple::XHTML. |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
2510
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
5
|
|
|
5
|
1
|
14
|
my $class = shift; |
17
|
5
|
|
|
|
|
55
|
my $self = $class->SUPER::new(@_); |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
849
|
$self->perldoc_url_prefix('http://metacpan.org/module/'); |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
40
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub doc { |
25
|
15
|
|
|
15
|
0
|
35
|
my ( $self, $doc ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
15
|
100
|
|
|
|
38
|
if ( defined $doc ) { |
28
|
5
|
|
|
|
|
12
|
$self->{_doc} = $doc; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
15
|
|
|
|
|
176
|
return $self->{_doc}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub local_modules { |
35
|
16
|
|
|
16
|
0
|
37
|
my ( $self, $modules ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
16
|
100
|
|
|
|
41
|
if ( defined $modules ) { |
38
|
5
|
|
|
|
|
23
|
$self->{_local_modules} = $modules; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
16
|
|
|
|
|
79
|
return $self->{_local_modules}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub current_files_output_path { |
45
|
10
|
|
|
10
|
0
|
26
|
my ( $self, $path ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
10
|
100
|
|
|
|
27
|
if ( defined $path ) { |
48
|
5
|
|
|
|
|
17
|
$self->{_current_files_output_path} = $path; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
10
|
|
|
|
|
181
|
return $self->{_current_files_output_path}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub resolve_pod_page_link { |
55
|
11
|
|
|
11
|
1
|
3621
|
my ( $self, $module, $section ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
11
|
50
|
|
|
|
19
|
my %module_map = %{ $self->local_modules() || {} }; |
|
11
|
|
|
|
|
31
|
|
58
|
|
|
|
|
|
|
|
59
|
11
|
100
|
100
|
|
|
40
|
if ( $module && $module_map{$module} ) { |
60
|
5
|
100
|
|
|
|
205
|
$section = defined $section ? '#' . $self->idify( $section, 1 ) : ''; |
61
|
5
|
|
|
|
|
256
|
my ( $filename, $directory ) = |
62
|
|
|
|
|
|
|
File::Basename::fileparse( $self->current_files_output_path, |
63
|
|
|
|
|
|
|
qr/\.html/ ); |
64
|
5
|
|
|
|
|
28
|
return File::Spec->abs2rel( $module_map{$module}, $directory ) |
65
|
|
|
|
|
|
|
. $section; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
6
|
|
|
|
|
187
|
return $self->SUPER::resolve_pod_page_link( $module, $section ); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# |
73
|
|
|
|
|
|
|
# Function overrides to extract the Pod page description, e.g. |
74
|
|
|
|
|
|
|
# |
75
|
|
|
|
|
|
|
# =head1 Name |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
# Package::Name - Description line. |
78
|
|
|
|
|
|
|
# |
79
|
|
|
|
|
|
|
# The code also takes into account complex POD in the description line, like L<> tags. |
80
|
|
|
|
|
|
|
# |
81
|
|
|
|
|
|
|
sub start_head1 { |
82
|
18
|
|
|
18
|
0
|
10583
|
my ( $self, $attrs ) = @_; |
83
|
|
|
|
|
|
|
|
84
|
18
|
|
|
|
|
48
|
$self->{_in_head1} = 1; |
85
|
18
|
|
|
|
|
97
|
return $self->SUPER::start_head1($attrs); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub end_head1 { |
89
|
18
|
|
|
18
|
0
|
1450
|
my ( $self, $attrs ) = @_; |
90
|
|
|
|
|
|
|
|
91
|
18
|
|
|
|
|
42
|
delete $self->{_in_head1}; |
92
|
18
|
|
|
|
|
62
|
return $self->SUPER::end_head1($attrs); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub handle_text { |
96
|
56
|
|
|
56
|
1
|
10763
|
my ( $self, $text ) = @_; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Are we after =head1 NAME? |
99
|
56
|
100
|
100
|
|
|
249
|
if ( $self->{_titleflag} ) { |
|
|
100
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Remember the line number if not yet set - this means we just endered this line. |
102
|
11
|
100
|
|
|
|
29
|
if ( !$self->{_titleline} ) { |
103
|
5
|
|
|
|
|
14
|
$self->{_titleline} = $self->{line_count}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# All nodes within this line will be processed, and their text added to the final description. |
107
|
11
|
100
|
|
|
|
37
|
if ( $self->{line_count} == $self->{_titleline} ) { |
108
|
6
|
|
|
|
|
20
|
$self->{_description} .= $text; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Once we leave this line, turn off the title flag again. |
112
|
|
|
|
|
|
|
else { |
113
|
5
|
|
|
|
|
24
|
delete $self->{_titleflag}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif ( $self->{_in_head1} && $text eq 'NAME' ) { |
117
|
5
|
|
|
|
|
16
|
$self->{_titleflag} = 1; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
56
|
|
|
|
|
143
|
return $self->SUPER::handle_text($text); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub DESTROY { |
124
|
5
|
|
|
5
|
|
13
|
my $self = shift; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# At the end - process and store the description. |
127
|
5
|
50
|
|
|
|
19
|
if ( $self->{_description} ) { |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my ( $name, $description ) = |
130
|
5
|
|
|
|
|
51
|
$self->{_description} =~ m{ ^ \s* ([^-]*?) \s* - \s* (.*?) \s* $}x; |
131
|
|
|
|
|
|
|
|
132
|
5
|
50
|
33
|
|
|
32
|
if ( $description && $self->doc() ) { |
133
|
5
|
|
|
|
|
16
|
$self->doc()->title($description); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
5
|
|
|
|
|
180
|
return; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |