line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::ProjectDocs::Parser; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
28
|
use strict; |
|
4
|
|
|
|
|
79
|
|
|
4
|
|
|
|
|
135
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
178
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.53'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
76
|
use Moose; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
with 'Pod::ProjectDocs::Template'; |
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
26910
|
use Pod::ProjectDocs::Parser::XHTML; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
1665
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'local_modules' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
isa => 'HashRef', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub gen_html { |
19
|
5
|
|
|
5
|
0
|
30
|
my ( $self, %args ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
14
|
my $doc = $args{doc}; |
22
|
5
|
|
|
|
|
13
|
my $components = $args{components}; |
23
|
5
|
|
|
|
|
12
|
my $mgr_desc = $args{desc}; |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
50
|
my $parser = Pod::ProjectDocs::Parser::XHTML->new(); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Use HTML5 with UTF8. |
28
|
5
|
|
|
|
|
57
|
$parser->html_doctype('<!DOCTYPE html>'); |
29
|
5
|
|
|
|
|
43
|
$parser->html_charset('UTF-8'); |
30
|
5
|
|
|
|
|
40
|
$parser->html_encode_chars(q{&<>'"}); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Add our custom CSS file. |
33
|
5
|
|
|
|
|
49
|
$parser->html_css( $components->{css}->relative_url($doc) ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Generator options. |
36
|
5
|
|
|
|
|
80
|
$parser->index(1); |
37
|
5
|
|
|
|
|
169
|
$parser->title( $doc->name() . ' — ' . $doc->config()->title() ); |
38
|
5
|
|
|
|
|
62
|
$parser->anchor_items(1); |
39
|
5
|
|
|
|
|
48
|
$parser->no_errata_section(1); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Custom options. |
42
|
5
|
|
|
|
|
40
|
$parser->doc($doc); |
43
|
5
|
|
|
|
|
135
|
$parser->local_modules( $self->local_modules() ); |
44
|
5
|
|
|
|
|
17
|
$parser->current_files_output_path( $doc->get_output_path ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Close <div class="pod"> (injected below) and add "generated by" content. |
47
|
5
|
|
|
|
|
31
|
$parser->html_footer( |
48
|
|
|
|
|
|
|
'</div><div class="footer">generated by <a href="http://metacpan.org/module/Pod::ProjectDocs">Pod::ProjectDocs</a></div></body></html>' |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Start parsing/generation. |
52
|
5
|
|
|
|
|
30
|
my $output; |
53
|
5
|
|
|
|
|
38
|
$parser->output_string( \$output ); |
54
|
5
|
|
|
|
|
3773
|
$parser->parse_file( $doc->origin ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Add body header section and open <div class="pod">. |
57
|
5
|
|
|
|
|
1650
|
my $header_box = $self->_generate_header_box( $doc, $mgr_desc ); |
58
|
5
|
|
|
|
|
84
|
$output =~ s/(<body[^>]*>)/$1$header_box\n<div class="pod">/; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Add HTML language information. |
61
|
5
|
|
|
|
|
149
|
my $language = $doc->config()->lang(); |
62
|
5
|
|
|
|
|
62
|
$output =~ s/<html>/<html lang="$language" xml:lang="$language">/; |
63
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
35
|
return $output; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _generate_header_box { |
68
|
5
|
|
|
5
|
|
18
|
my ( $self, $doc, $mgr_desc ) = @_; |
69
|
5
|
|
|
|
|
182
|
my $text = $self->process( |
70
|
|
|
|
|
|
|
$doc, |
71
|
|
|
|
|
|
|
$doc->data, |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
title => $doc->config->title, |
74
|
|
|
|
|
|
|
desc => $doc->config->desc, |
75
|
|
|
|
|
|
|
name => $doc->name, |
76
|
|
|
|
|
|
|
outroot => $doc->config->outroot, |
77
|
|
|
|
|
|
|
src => $doc->get_output_src_path, |
78
|
|
|
|
|
|
|
mgr_desc => $mgr_desc, |
79
|
|
|
|
|
|
|
nosourcecode => $doc->config->nosourcecode, |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
); |
82
|
5
|
50
|
|
|
|
52
|
return $text if $^O ne 'MSWin32'; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
while ( $text =~ s|href="(.*?)\\(.*?)"|href="$1/$2"| ) { |
85
|
0
|
|
|
|
|
|
next; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
return $text; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
4
|
|
|
4
|
|
41
|
no Moose; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
37
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |