lib/OODoc/Format/Pod3.pm

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