ProjectDocs/Parser.pm

filter: Statementstmt 94.0% 47 / 50 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 88.7% 55 / 62 CC 3 SCAR 8.4
CC
3
Cov
89%
_generate_header_box
4.9
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« ProjectDocs/Parser/XHTML.pm ↑ Summary ProjectDocs/File.pm »
1 package Pod::ProjectDocs::Parser;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '0.53'; # VERSION
7  
8 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 with 'Pod::ProjectDocs::Template';
10  
11 4 ▶use Pod::ProjectDocs::Parser::XHTML;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 has 'local_modules' => (
14 is => 'rw',
15 isa => 'HashRef',
16 );
17  
18 5 ▶sub gen_html {
Subroutine gen_html: called CC=1 SCAR=0.0
Pod undocumented
19 5 my ( $self, %args ) = @_;
20  
21 5 my $doc = $args{doc};
22 5 my $components = $args{components};
23 5 my $mgr_desc = $args{desc};
24  
25 5 my $parser = Pod::ProjectDocs::Parser::XHTML->new();
26  
27 # Use HTML5 with UTF8.
28 5 $parser->html_doctype('<!DOCTYPE html>');
29 5 $parser->html_charset('UTF-8');
30 5 $parser->html_encode_chars(q{&<>'"});
31  
32 # Add our custom CSS file.
33 5 $parser->html_css( $components->{css}->relative_url($doc) );
34  
35 # Generator options.
36 5 $parser->index(1);
37 5 $parser->title( $doc->name() . ' &mdash; ' . $doc->config()->title() );
38 5 $parser->anchor_items(1);
39 5 $parser->no_errata_section(1);
40  
41 # Custom options.
42 5 $parser->doc($doc);
43 5 $parser->local_modules( $self->local_modules() );
44 5 $parser->current_files_output_path( $doc->get_output_path );
45  
46 # Close <div class="pod"> (injected below) and add "generated by" content.
47 5 $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 my $output;
53 5 $parser->output_string( \$output );
54 5 $parser->parse_file( $doc->origin );
55  
56 # Add body header section and open <div class="pod">.
57 5 my $header_box = $self->_generate_header_box( $doc, $mgr_desc );
58 5 $output =~ s/(<body[^>]*>)/$1$header_box\n<div class="pod">/;
59  
60 # Add HTML language information.
61 5 my $language = $doc->config()->lang();
62 5 $output =~ s/<html>/<html lang="$language" xml:lang="$language">/;
63  
64 5 return $output;
65 }
66  
67 5 ▶sub _generate_header_box {
Subroutine _generate_header_box: called CC=3 SCAR=16.0
68 5 my ( $self, $doc, $mgr_desc ) = @_;
69 5 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 ▶ return $text if $^O ne 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O ne "MSWin32" 5 0 5
83  
84 0 ▶ while ( $text =~ s|href="(.*?)\\(.*?)"|href="$1/$2"| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ s[href="(.*?)\\(.*?)"][href="$1/$2"]) 0 0 0
85 0 next;
86 }
87 0 return $text;
88 }
89  
90 4 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 4 1;
« ProjectDocs/Parser/XHTML.pm ↑ Summary ProjectDocs/File.pm »