| 1 | package Pod::ProjectDocs::Parser::XHTML; | ||||||||||||||||||||||||||||
| 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 base qw(Pod::Simple::XHTML); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use File::Basename(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use File::Spec(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use HTML::Entities() | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ; # Required for proper entity detection in Pod::Simple::XHTML. | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 5 | my $class = shift; | |||||||||||||||||||||||||||
| 17 | 5 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 5 | $self->perldoc_url_prefix('http://metacpan.org/module/'); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 5 | return $self; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 15 | ▶ | sub doc { | ||||||||||||||||||||||||||
|
Subroutine
doc: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 15 | my ( $self, $doc ) = @_; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 15 | ▶ | if ( defined $doc ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 5 | $self->{_doc} = $doc; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 15 | return $self->{_doc}; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 16 | ▶ | sub local_modules { | ||||||||||||||||||||||||||
|
Subroutine
local_modules: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 16 | my ( $self, $modules ) = @_; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 16 | ▶ | if ( defined $modules ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 5 | $self->{_local_modules} = $modules; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 16 | return $self->{_local_modules}; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 10 | ▶ | sub current_files_output_path { | ||||||||||||||||||||||||||
|
Subroutine
current_files_output_path: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 10 | my ( $self, $path ) = @_; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 10 | ▶ | if ( defined $path ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 5 | $self->{_current_files_output_path} = $path; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 10 | return $self->{_current_files_output_path}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 11 | ▶ | sub resolve_pod_page_link { | ||||||||||||||||||||||||||
|
Subroutine
resolve_pod_page_link: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 11 | my ( $self, $module, $section ) = @_; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 11 | ▶ | my %module_map = %{ $self->local_modules() || {} }; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->local_modules || {}
MC/DC0%0/1
$self->local_modules || {}
$self->local_modules
Truth table50%1/2
A
A= $self->local_modules
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 11 | ▶ | if ( $module && $module_map{$module} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$module and $module_map{$module}
MC/DC100%2/2
$module and $module_map{$module}
$module
$module_map{$module}
Truth table100%3/3
A and B
A= $moduleB= $module_map{$module}
| |||||||||||||||||||||||||||||
| 60 | 5 | ▶ | $section = defined $section ? '#' . $self->idify( $section, 1 ) : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 5 | my ( $filename, $directory ) = | |||||||||||||||||||||||||||
| 62 | File::Basename::fileparse( $self->current_files_output_path, | ||||||||||||||||||||||||||||
| 63 | qr/\.html/ ); | ||||||||||||||||||||||||||||
| 64 | 5 | return File::Spec->abs2rel( $module_map{$module}, $directory ) | |||||||||||||||||||||||||||
| 65 | . $section; | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 6 | 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 | 18 | ▶ | sub start_head1 { | ||||||||||||||||||||||||||
|
Subroutine
start_head1: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 18 | my ( $self, $attrs ) = @_; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 18 | $self->{_in_head1} = 1; | |||||||||||||||||||||||||||
| 85 | 18 | return $self->SUPER::start_head1($attrs); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 18 | ▶ | sub end_head1 { | ||||||||||||||||||||||||||
|
Subroutine
end_head1: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | 18 | my ( $self, $attrs ) = @_; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 18 | delete $self->{_in_head1}; | |||||||||||||||||||||||||||
| 92 | 18 | return $self->SUPER::end_head1($attrs); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 56 | ▶ | sub handle_text { | ||||||||||||||||||||||||||
|
Subroutine
handle_text: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 56 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # Are we after =head1 NAME? | ||||||||||||||||||||||||||||
| 99 | 56 | ▶ | if ( $self->{_titleflag} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # Remember the line number if not yet set - this means we just endered this line. | ||||||||||||||||||||||||||||
| 102 | 11 | ▶ | if ( !$self->{_titleline} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 5 | $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 | ▶ | if ( $self->{line_count} == $self->{_titleline} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 6 | $self->{_description} .= $text; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # Once we leave this line, turn off the title flag again. | ||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||
| 113 | 5 | delete $self->{_titleflag}; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | ▶ | elsif ( $self->{_in_head1} && $text eq 'NAME' ) { | |||||||||||||||||||||||||||
|
Condition100%3/3
$self->{"_in_head1"} and $text eq "NAME"
MC/DC100%2/2
$self->{"_in_head1"} and $text eq "NAME"
$self->{"_in_head1"}
$text eq "NAME"
Truth table100%3/3
A and B
A= $self->{"_in_head1"}B= $text eq "NAME"
| |||||||||||||||||||||||||||||
| 117 | 5 | $self->{_titleflag} = 1; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 56 | return $self->SUPER::handle_text($text); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 5 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||
| 124 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # At the end - process and store the description. | ||||||||||||||||||||||||||||
| 127 | 5 | ▶ | if ( $self->{_description} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | my ( $name, $description ) = | ||||||||||||||||||||||||||||
| 130 | 5 | $self->{_description} =~ m{ ^ \s* ([^-]*?) \s* - \s* (.*?) \s* $}x; | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 5 | ▶ | if ( $description && $self->doc() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$description and $self->doc
MC/DC0%0/2
$description and $self->doc
$description
$self->doc
Truth table33%1/3
A and B
A= $descriptionB= $self->doc
| |||||||||||||||||||||||||||||
| 133 | 5 | $self->doc()->title($description); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 5 | return; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 4 | 1; | |||||||||||||||||||||||||||