lib/OODoc/Format/Pod3.pm

filter: Statementstmt 26.6% 28 / 105 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 26.9% 7 / 26 Podpod 33.3% 3 / 9 totaltotal 20.1% 38 / 189 CC 19 SCAR 28.1
CC
19
Cov
20%
chapters
42.0
subroutines
42.0
structure
30.0
CRAP 16.7
« lib/OODoc/Text/SubSubSection.pm ↑ Summary lib/OODoc/Text/Chapter.pm »
1 # Copyrights 2003-2015 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package OODoc::Format::Pod3;
9 1 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 $VERSION = '2.01';
11  
12 1 ▶use base 'OODoc::Format::Pod';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Log::Report 'oodoc';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use OODoc::Template ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use List::Util qw/first/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 1 my $default_template;
21 1 { local $/;
22 1 $default_template = <DATA>;
23 1 close DATA;
24 }
25  
26 sub createManual(@)
27 0 ▶{ my ($self, %args) = @_;
Subroutine createManual: not called CC=2 SCAR=17.9
Pod documented
28 0 ▶ $self->{O_template} = delete $args{template} || \$default_template;
Condition0%0/2
delete $args{'template'} || \$default_template
l!l
00
MC/DC0%0/1
delete $args{'template'} || \$default_template
delete $args{'template'}
Truth table0%0/2
A
A= delete $args{'template'}
Aresult
11
00
29 0 $self->SUPER::createManual(%args);
30 }
31  
32 sub formatManual(@)
33 0 ▶{ my ($self, %args) = @_;
Subroutine formatManual: not called CC=1 SCAR=6.9
Pod documented
34 0 my $output = delete $args{output};
35  
36 my $template = OODoc::Template->new
37 ( markers => [ '<{', '}>' ]
38 , manual_obj => delete $args{manual}
39 0 , chapter_order =>
40 [ qw/NAME INHERITANCE SYNOPSIS DESCRIPTION OVERLOADED METHODS
41 FUNCTIONS CONSTANTS EXPORTS DIAGNOSTICS DETAILS REFERENCES
42 COPYRIGHTS/
43 ]
44 , %args
45 );
46  
47 $output->print
48 ( scalar $template->process
49 ( $self->{O_template}
50 0 ▶ , manual => sub { shift; ( {}, @_ ) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 ▶ , chapters => sub { $self->chapters($template, @_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 ▶ , sections => sub { $self->sections($template, @_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 0 ▶ , subsections => sub { $self->subsections($template, @_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 ▶ , subsubsections => sub { $self->subsubsections($template, @_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 ▶ , subroutines => sub { $self->subroutines($template, @_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 ▶ , diagnostics => sub { $self->diagnostics($template, @_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 )
58 0 );
59 }
60  
61  
62 sub structure($$$)
63 0 ▶{ my ($self, $template, $type, $object) = @_;
Subroutine structure: not called CC=5 SCAR=34.0
Pod undocumented
64  
65 0 my $manual = $template->valueFor('manual_obj');
66 0 my $descr = $self->cleanup($manual, $object->description);
67 0 my $name = $object->name;
68  
69 0 ▶ $descr =~ s/\n*$/\n\n/
Branch: 1 branch
BranchTrueFalseTotal
if defined $descr and length $descr 0 0 0
Condition0%0/3
defined $descr and length $descr
!ll&&!rl&&r
000
MC/DC0%0/2
defined $descr and length $descr
defined $descr length $descr
Truth table0%0/3
A and B
A= defined $descrB= length $descr
ABresult
0X0
100
111
70 if defined $descr && length $descr;
71  
72 0 my @examples = $object->examples;
73 0 my @extends;
74  
75 0 ▶ unless($name eq 'NAME' || $name eq 'SYNOPSIS')
Branch: 1 branch
BranchTrueFalseTotal
unless ($name eq "NAME" or $name eq "SYNOPSIS") 0 0 0
Condition0%0/3
$name eq "NAME" or $name eq "SYNOPSIS"
l!l&&r!l&&!r
000
MC/DC0%0/2
$name eq "NAME" or $name eq "SYNOPSIS"
$name eq "NAME" $name eq "SYNOPSIS"
Truth table0%0/3
A or B
A= $name eq "NAME"B= $name eq "SYNOPSIS"
ABresult
1X1
011
000
76 0 { @extends = map +{manual => $_->manual, header => $name}
77 , $object->extends;
78 }
79  
80 0 +{ $type => $name
81 , $type.'_obj' => $object
82 , description => $descr
83 , examples => \@examples
84 , extends => \@extends
85 };
86 }
87  
88 sub chapters($$$$$)
89 0 ▶{ my ($self, $template, $tag, $attrs, $then, $else) = @_;
Subroutine chapters: not called CC=6 SCAR=37.4
Pod undocumented
90 0 my $manual = $template->valueFor('manual_obj');
91  
92 my @chapters
93 0 = map $self->structure($template, chapter => $_)
94 , $manual->chapters;
95  
96 0 ▶ if(my $order = $attrs->{order})
Branch: 1 branch
BranchTrueFalseTotal
if (my $order = $attrs->{"order"}) 0 0 0
97 0 ▶ { my @order = ref $order eq 'ARRAY' ? @$order : split( /\,\s*/, $order);
Branch: 1 branch
BranchTrueFalseTotal
ref $order eq 'ARRAY' ? : 0 0 0
98 0 my %order;
99  
100 # first the pre-defined names, then the other
101 0 my $count = 1;
102 0 $order{$_} = $count++ for @order;
103 0 ▶ $order{$_->{chapter}} ||= $count++ for @chapters;
Condition0%0/3
$order{$_->{"chapter"}} ||= $count++
l!l&&r!l&&!r
000
MC/DC0%0/2
$order{$_->{"chapter"}} ||= $count++
$order{$_->{"chapter"}} $count++
Truth table0%0/3
A ||= B
A= $order{$_->{"chapter"}}B= $count++
ABresult
1X1
011
000
104  
105 0 @chapters = sort { $order{$a->{chapter}} <=> $order{$b->{chapter}} }
106 @chapters;
107 }
108  
109 0 ( \@chapters, $attrs, $then, $else );
110 }
111  
112 sub sections($$$$$)
113 0 ▶{ my ($self, $template, $tag, $attrs, $then, $else) = @_;
Subroutine sections: not called CC=2 SCAR=17.9
Pod undocumented
114 0 my $chapter = $template->valueFor('chapter_obj');
115  
116 return ([], $attrs, $then, $else)
117 0 ▶ unless first {!$_->isEmpty} $chapter->sections;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless &first(sub { not $_->isEmpty; } , $chapter->sections) 0 0 0
118  
119 my @sections
120 0 = map { $self->structure($template, section => $_) }
121 $chapter->sections;
122  
123 0 ( \@sections, $attrs, $then, $else );
124 }
125  
126 sub subsections($$$$$)
127 0 ▶{ my ($self, $template, $tag, $attrs, $then, $else) = @_;
Subroutine subsections: not called CC=2 SCAR=17.9
Pod undocumented
128 0 my $section = $template->valueFor('section_obj');
129  
130 return ([], $attrs, $then, $else)
131 0 ▶ unless first {!$_->isEmpty} $section->subsections;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless &first(sub { not $_->isEmpty; } , $section->subsections) 0 0 0
132  
133 my @subsections
134 0 = map { $self->structure($template, subsection => $_) }
135 $section->subsections;
136  
137 0 ( \@subsections, $attrs, $then, $else );
138 }
139  
140 sub subsubsections($$$$$)
141 0 ▶{ my ($self, $template, $tag, $attrs, $then, $else) = @_;
Subroutine subsubsections: not called CC=2 SCAR=17.9
Pod undocumented
142 0 my $subsection = $template->valueFor('subsection_obj');
143  
144 return ([], $attrs, $then, $else)
145 0 ▶ unless first {!$_->isEmpty} $subsection->subsubsections;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless &first(sub { not $_->isEmpty; } , $subsection->subsubsections) 0 0 0
146  
147 my @subsubsections
148 0 = map { $self->structure($template, subsubsection => $_) }
149 $subsection->subsubsections;
150  
151 0 ( \@subsubsections, $attrs, $then, $else );
152 }
153  
154 sub subroutines($$$$$$)
155 0 ▶{ my ($self, $template, $tag, $attrs, $then, $else) = @_;
Subroutine subroutines: not called CC=6 SCAR=37.4
Pod documented
156  
157 0 ▶ my $parent
Condition0%0/9
$template->valueFor('subsubsection_obj') || $template->valueFor('subsection_obj') || $template->valueFor('section_obj') || $template->valueFor('chapter_obj')
l!l&&r!l&&!r
000
$template->valueFor("subsubsection_obj") or $template->valueFor("subsection_obj") or $template->valueFor("section_obj")
l!l&&r!l&&!r
000
$template->valueFor("subsubsection_obj") or $template->valueFor("subsection_obj")
l!l&&r!l&&!r
000
MC/DC0%0/4
$template->valueFor('subsubsection_obj') || $template->valueFor('subsection_obj') || $template->valueFor('section_obj') || $template->valueFor('chapter_obj')
$template->valueFor("subsubsection_obj") $template->valueFor("subsection_obj") $template->valueFor("section_obj") $template->valueFor('chapter_obj')
Truth table0%0/5
A or B or C || D
A= $template->valueFor("subsubsection_obj")B= $template->valueFor("subsection_obj")C= $template->valueFor("section_obj")D= $template->valueFor('chapter_obj')
ABCDresult
1XXX1
01XX1
001X1
00011
00000
158 = $template->valueFor('subsubsection_obj')
159 || $template->valueFor('subsection_obj')
160 || $template->valueFor('section_obj')
161 || $template->valueFor('chapter_obj');
162  
163 0 ▶ defined $parent
Branch: 1 branch
BranchTrueFalseTotal
defined $parent or return () 0 0 0
164 or return ();
165  
166 0 my $out = '';
167 0 open OUT, '>',\$out;
168  
169 0 my @show = map +($_ => scalar $template->valueFor($_)),
170 qw/show_described_options show_described_subs show_diagnostics
171 show_examples show_inherited_options show_inherited_subs
172 show_option_table show_subs_index/;
173  
174 # This is quite weak: the whole POD section for a sub description
175 # is produced outside the template. In the future, this may get
176 # changed: if there is a need for it: of course, we can do everything
177 # in the template system.
178  
179 0 $self->showSubroutines
180 ( subroutines => [ $parent->subroutines ]
181 , manual => $parent->manual
182 , output => \*OUT
183 , @show
184 );
185  
186 0 close OUT;
187 0 ▶ length $out or return;
Branch: 1 branch
BranchTrueFalseTotal
length $out or return 0 0 0
188  
189 0 $out =~ s/\n*$/\n\n/;
190 0 ($out);
191 }
192  
193 sub diagnostics($$$$$$)
194 0 ▶{ my ($self, $template, $tag, $attrs, $then, $else) = @_;
Subroutine diagnostics: not called CC=1 SCAR=6.9
Pod undocumented
195 0 my $manual = $template->valueFor('manual_obj');
196
197 0 my $out = '';
198 0 open OUT, '>',\$out;
199 0 $self->chapterDiagnostics(%$attrs, manual => $manual, output => \*OUT);
200 0 close OUT;
201  
202 0 $out =~ s/\n*$/\n\n/;
203 0 ($out);
204 }
205  
206 1 1;
207  
208 __DATA__
« lib/OODoc/Text/SubSubSection.pm ↑ Summary lib/OODoc/Text/Chapter.pm »