lib/OODoc/Format/Pod.pm

filter: Statementstmt 18.4% 53 / 288 Branchbran 10.2% 21 / 204 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 29.4% 10 / 34 Podpod 68.0% 17 / 25 totaltotal 17.8% 101 / 565 SCAR 90.6
CC
117
Cov
15%
writeTable
182.0
subroutineUse
110.0
link
90.0
CRAP 8592.0
« lib/OODoc/Parser/Markov.pm ↑ Summary blib/lib/OODoc/Parser/Markov.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 package OODoc::Format::Pod;
9 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 $VERSION = '2.02';
11  
12 2 ▶use base 'OODoc::Format';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use Log::Report 'oodoc';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 2 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use List::Util qw/max/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Pod::Escapes qw/e2char/;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23  
24 sub link($$;$)
25 0 ▶{ my ($self, $manual, $object, $text) = @_;
Subroutine link: not called CC=9 SCAR=45.0
Pod documented
26  
27 0 ▶ $object = $object->subroutine if $object->isa('OODoc::Text::Option');
Branch: 1 branch
BranchTrueFalseTotal
if $object->isa("OODoc::Text::Option") 0 0 0
28 0 ▶ $object = $object->subroutine if $object->isa('OODoc::Text::Default');
Branch: 1 branch
BranchTrueFalseTotal
if $object->isa("OODoc::Text::Default") 0 0 0
29 0 ▶ $object = $object->container if $object->isa('OODoc::Text::Example');
Branch: 1 branch
BranchTrueFalseTotal
if $object->isa("OODoc::Text::Example") 0 0 0
30 0 ▶ $object = $object->container if $object->isa('OODoc::Text::Subroutine');
Branch: 1 branch
BranchTrueFalseTotal
if $object->isa("OODoc::Text::Subroutine") 0 0 0
31 0 ▶ $text = defined $text ? "$text|" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $text ? : 0 0 0
32  
33 0 ▶ return "L<$text$object>"
Branch: 1 branch
BranchTrueFalseTotal
if $object->isa("OODoc::Manual") 0 0 0
34 if $object->isa('OODoc::Manual');
35  
36 0 ▶ $object->isa('OODoc::Text::Structure')
Branch: 1 branch
BranchTrueFalseTotal
$object->isa("OODoc::Text::Structure") or &error(&__x("cannot link to a {pkg}", "pkg", ref $object)) 0 0 0
37 or error __x"cannot link to a {pkg}", pkg => ref $object;
38  
39 0 ▶ my $manlink = defined $manual ? $object->manual.'/' : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $manual ? : 0 0 0
40 0 qq(L<$text$manlink"$object">);
41 }
42  
43  
44 sub createManual($@)
45 0 ▶{ my ($self, %args) = @_;
Subroutine createManual: not called CC=4 SCAR=30.0
Pod documented
46 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
47 0 ▶ my $options = $args{format_options} || [];
Condition0%0/2
$args{'format_options'} || []
l!l
00
MC/DC0%0/1
$args{'format_options'} || []
$args{'format_options'}
Truth table0%0/2
A
A= $args{'format_options'}
Aresult
11
00
48  
49 0 my $podname = $manual->source;
50 0 $podname =~ s/\.pm$/.pod/;
51 0 my $tmpname = $podname . 't';
52  
53 0 my $tmpfile = File::Spec->catfile($self->workdir, $tmpname);
54 0 my $podfile = File::Spec->catfile($self->workdir, $podname);
55  
56 0 ▶ my $output = IO::File->new($tmpfile, "w")
Branch: 1 branch
BranchTrueFalseTotal
my $output = "IO::File"->new($tmpfile, "w") or &fault(&__x("cannot write prelimary pod manual to {file}", "file", $tmpfile)) 0 0 0
57 or fault __x"cannot write prelimary pod manual to {file}"
58 , file => $tmpfile;
59  
60 $self->formatManual
61 ( manual => $manual
62 , output => $output
63 , append => $args{append}
64 0 , @$options
65 );
66  
67 0 $output->close;
68  
69 0 $self->cleanupPOD($tmpfile, $podfile);
70 0 unlink $tmpfile;
71  
72 0 $self->manifest->add($podfile);
73  
74 0 $self;
75 }
76  
77  
78 sub formatManual(@)
79 0 ▶{ my $self = shift;
Subroutine formatManual: not called CC=1 SCAR=6.9
Pod documented
80 0 $self->chapterName(@_);
81 0 $self->chapterInheritance(@_);
82 0 $self->chapterSynopsis(@_);
83 0 $self->chapterDescription(@_);
84 0 $self->chapterOverloaded(@_);
85 0 $self->chapterMethods(@_);
86 0 $self->chapterExports(@_);
87 0 $self->chapterDetails(@_);
88 0 $self->chapterDiagnostics(@_);
89 0 $self->chapterReferences(@_);
90 0 $self->chapterCopyrights(@_);
91 0 $self->showAppend(@_);
92 0 $self;
93 }
94  
95 sub showAppend(@)
96 0 ▶{ my ($self, %args) = @_;
Subroutine showAppend: not called CC=4 SCAR=30.0
Pod undocumented
97 0 my $append = $args{append};
98  
99 0 ▶ if(!defined $append) { ; }
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $append) { } 0 0 0
elsif (ref $append eq 'CODE') { } 0 0 0
100 0 elsif(ref $append eq 'CODE') { $append->(formatter => $self, %args) }
101 else
102 0 ▶ { my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
103 0 $output->print($append);
104 }
105  
106 0 $self;
107 }
108  
109 sub showStructureExpand(@)
110 0 ▶{ my ($self, %args) = @_;
Subroutine showStructureExpand: not called CC=6 SCAR=37.4
Pod undocumented
111  
112 0 ▶ my $examples = $args{show_chapter_examples} || 'EXPAND';
Condition0%0/2
$args{'show_chapter_examples'} || 'EXPAND'
l!l
00
MC/DC0%0/1
$args{'show_chapter_examples'} || 'EXPAND'
$args{'show_chapter_examples'}
Truth table0%0/2
A
A= $args{'show_chapter_examples'}
Aresult
11
00
113 0 ▶ my $text = $args{structure} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $text = $args{"structure"} or &panic() 0 0 0
114  
115 0 my $name = $text->name;
116 0 my $level = $text->level;
117 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
118 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
119  
120 0 my $descr = $self->cleanup($manual, $text->description);
121 0 $output->print("\n=head$level $name\n\n$descr");
122  
123 0 $self->showSubroutines(%args, subroutines => [$text->subroutines]);
124 0 ▶ $self->showExamples(%args, examples => [$text->examples])
Branch: 1 branch
BranchTrueFalseTotal
if $examples eq "EXPAND" 0 0 0
125 if $examples eq 'EXPAND';
126  
127 0 return $self;
128 }
129  
130 sub showStructureRefer(@)
131 0 ▶{ my ($self, %args) = @_;
Subroutine showStructureRefer: not called CC=4 SCAR=30.0
Pod documented
132  
133 0 ▶ my $text = $args{structure} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $text = $args{"structure"} or &panic() 0 0 0
134  
135 0 my $name = $text->name;
136 0 my $level = $text->level;
137 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
138 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
139  
140 0 my $link = $self->link($manual, $text);
141 0 $output->print("\n=head$level $name\n\nSee $link.\n");
142 0 $self;
143 }
144  
145 sub chapterDescription(@)
146 0 ▶{ my ($self, %args) = @_;
Subroutine chapterDescription: not called CC=4 SCAR=30.0
Pod undocumented
147  
148 0 $self->showRequiredChapter(DESCRIPTION => %args);
149  
150 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
151 0 my $details = $manual->chapter('DETAILS');
152  
153 0 ▶ return $self unless defined $details;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $details 0 0 0
154  
155 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
156 0 $output->print("\nSee L</DETAILS> chapter below\n");
157 0 $self->showChapterIndex($output, $details, " ");
158 }
159  
160 sub chapterDiagnostics(@)
161 0 ▶{ my ($self, %args) = @_;
Subroutine chapterDiagnostics: not called CC=6 SCAR=37.4
Pod undocumented
162 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
163  
164 0 my $diags = $manual->chapter('DIAGNOSTICS');
165 0 ▶ $self->showChapter(chapter => $diags, %args)
Branch: 1 branch
BranchTrueFalseTotal
if defined $diags 0 0 0
166 if defined $diags;
167  
168 0 my @diags = map {$_->diagnostics} $manual->subroutines;
169 0 ▶ return unless @diags;
Branch: 1 branch
BranchTrueFalseTotal
unless @diags 0 0 0
170  
171 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
172 0 ▶ $diags
Branch: 1 branch
BranchTrueFalseTotal
$diags or $output->print("\n=head1 DIAGNOSTICS\n") 0 0 0
173 or $output->print("\n=head1 DIAGNOSTICS\n");
174  
175 0 $output->print("\n=over 4\n\n");
176 0 $self->showDiagnostics(%args, diagnostics => \@diags);
177 0 $output->print("\n=back\n\n");
178 0 $self;
179 }
180  
181  
182 sub showChapterIndex($$;$)
183 0 ▶{ my ($self, $output, $chapter, $indent) = @_;
Subroutine showChapterIndex: not called CC=4 SCAR=30.0
Pod documented
184 0 ▶ $indent = '' unless defined $indent;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $indent 0 0 0
185  
186 0 foreach my $section ($chapter->sections)
187 0 { $output->print($indent, $section->name, "\n");
188 0 foreach my $subsection ($section->subsections)
189 0 { $output->print($indent, $indent, $subsection->name, "\n");
190 }
191 }
192 0 $self;
193 }
194  
195 sub showExamples(@)
196 0 ▶{ my ($self, %args) = @_;
Subroutine showExamples: not called CC=6 SCAR=37.4
Pod documented
197 0 ▶ my $examples = $args{examples} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $examples = $args{"examples"} or &panic() 0 0 0
198 0 ▶ return unless @$examples;
Branch: 1 branch
BranchTrueFalseTotal
unless @$examples 0 0 0
199  
200 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
201 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
202  
203 0 foreach my $example (@$examples)
204 0 { my $name = $self->cleanup($manual, $example->name);
205 0 $output->print("\nexample: $name\n\n");
206 0 $output->print($self->cleanup($manual, $example->description));
207 0 $output->print("\n");
208 }
209 0 $self;
210 }
211  
212 sub showDiagnostics(@)
213 0 ▶{ my ($self, %args) = @_;
Subroutine showDiagnostics: not called CC=6 SCAR=37.4
Pod undocumented
214 0 ▶ my $diagnostics = $args{diagnostics} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $diagnostics = $args{"diagnostics"} or &panic() 0 0 0
215 0 ▶ return unless @$diagnostics;
Branch: 1 branch
BranchTrueFalseTotal
unless @$diagnostics 0 0 0
216  
217 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
218 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
219  
220 0 foreach my $diag (sort @$diagnostics)
221 0 { my $name = $self->cleanup($manual, $diag->name);
222 0 my $type = $diag->type;
223 0 $output->print("\n=item $type: $name\n\n");
224 0 $output->print($self->cleanup($manual, $diag->description));
225 0 $output->print("\n");
226 }
227 0 $self;
228 }
229  
230 sub showSubroutines(@)
231 0 ▶{ my ($self, %args) = @_;
Subroutine showSubroutines: not called CC=4 SCAR=30.0
Pod documented
232 0 ▶ my $subs = $args{subroutines} || [];
Condition0%0/2
$args{'subroutines'} || []
l!l
00
MC/DC0%0/1
$args{'subroutines'} || []
$args{'subroutines'}
Truth table0%0/2
A
A= $args{'subroutines'}
Aresult
11
00
233 0 ▶ @$subs or return;
Branch: 1 branch
BranchTrueFalseTotal
@$subs or return 0 0 0
234  
235 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
236  
237 0 $output->print("\n=over 4\n\n");
238 0 $self->SUPER::showSubroutines(%args);
239 0 $output->print("\n=back\n\n");
240 }
241  
242 sub showSubroutine(@)
243 0 ▶{ my $self = shift;
Subroutine showSubroutine: not called CC=2 SCAR=17.9
Pod documented
244 0 $self->SUPER::showSubroutine(@_);
245  
246 0 my %args = @_;
247 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
248 0 $output->print("\n");
249 0 $self;
250 }
251  
252 sub showSubroutineUse(@)
253 0 ▶{ my ($self, %args) = @_;
Subroutine showSubroutineUse: not called CC=5 SCAR=34.0
Pod documented
254 0 ▶ my $subroutine = $args{subroutine} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $subroutine = $args{"subroutine"} or &panic() 0 0 0
255 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
256 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
257  
258 0 my $use = $self->subroutineUse($manual, $subroutine);
259 0 $use =~ s/(.+)/=item $1\n\n/gm;
260  
261 0 $output->print($use);
262 0 ▶ $output->print("Inherited, see ". $self->link($manual, $subroutine)."\n\n")
Branch: 1 branch
BranchTrueFalseTotal
if $manual->inherited($subroutine) 0 0 0
263 if $manual->inherited($subroutine);
264  
265 0 $self;
266 }
267  
268 sub subroutineUse($$)
269 0 ▶{ my ($self, $manual, $subroutine) = @_;
Subroutine subroutineUse: not called CC=10 SCAR=47.0
Pod undocumented
270 0 my $type = $subroutine->type;
271 0 my $name = $self->cleanup($manual, $subroutine->name);
272 0 my $paramlist = $self->cleanup($manual, $subroutine->parameters);
273 0 ▶ my $params
Branch: 2 branches
BranchTrueFalseTotal
!length($paramlist) ? : 0 0 0
$paramlist =~ /^[\[<]|[\]>]$/ ? : 0 0 0
274 = !length $paramlist ? '()'
275 : $paramlist =~ m/^[\[<]|[\]>]$/ ? "( $paramlist )"
276 : "($paramlist)";
277  
278 0 my $class = $manual->package;
279 0 ▶ my $use
Branch: 6 branches
BranchTrueFalseTotal
$type eq 'i_method' ? : 0 0 0
$type eq 'c_method' ? : 0 0 0
$type eq 'ci_method' ? : 0 0 0
$type eq 'function' ? : 0 0 0
$type eq 'overload' ? : 0 0 0
$type eq 'tie' ? : 0 0 0
280 = $type eq 'i_method' ? qq[\$obj-E<gt>B<$name>$params]
281 : $type eq 'c_method' ? qq[$class-E<gt>B<$name>$params]
282 : $type eq 'ci_method'? qq[\$obj-E<gt>B<$name>$params\n]
283 . qq[$class-E<gt>B<$name>$params]
284 : $type eq 'function' ? qq[B<$name>$params]
285 : $type eq 'overload' ? qq[overload: B<$name>]
286 : $type eq 'tie' ? qq[B<$name>$params]
287 : '';
288  
289 0 ▶ length $use
Branch: 1 branch
BranchTrueFalseTotal
length $use or warn "WARNING: unknown subroutine type $type for $name in $manual" 0 0 0
290 or warn "WARNING: unknown subroutine type $type for $name in $manual";
291  
292 0 $use;
293 }
294  
295 sub showSubroutineName(@)
296 0 ▶{ my ($self, %args) = @_;
Subroutine showSubroutineName: not called CC=6 SCAR=37.4
Pod documented
297 0 ▶ my $subroutine = $args{subroutine} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $subroutine = $args{"subroutine"} or &panic() 0 0 0
298 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
299 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
300 0 my $name = $subroutine->name;
301  
302 0 ▶ my $url
Branch: 1 branch
BranchTrueFalseTotal
$manual->inherited($subroutine) ? : 0 0 0
303 = $manual->inherited($subroutine)
304 ? "M<".$subroutine->manual."::$name>"
305 : "M<$name>";
306  
307 $output->print
308 ( $self->cleanup($manual, $url)
309 0 ▶ , ($args{last} ? ".\n" : ",\n")
Branch: 1 branch
BranchTrueFalseTotal
$args{'last'} ? : 0 0 0
310 );
311 }
312  
313 sub showOptions(@)
314 0 ▶{ my ($self, %args) = @_;
Subroutine showOptions: not called CC=2 SCAR=17.9
Pod documented
315 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
316 0 $output->print("\n=over 2\n\n");
317 0 $self->SUPER::showOptions(%args);
318 0 $output->print("\n=back\n\n");
319 }
320  
321 sub showOptionUse(@)
322 0 ▶{ my ($self, %args) = @_;
Subroutine showOptionUse: not called CC=5 SCAR=34.0
Pod documented
323 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
324 0 ▶ my $option = $args{option} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $option = $args{"option"} or &panic() 0 0 0
325 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
326  
327 0 my $params = $option->parameters;
328 0 $params =~ s/\s+$//;
329 0 $params =~ s/^\s+//;
330 0 ▶ $params = " => ".$self->cleanup($manual, $params) if length $params;
Branch: 1 branch
BranchTrueFalseTotal
if length $params 0 0 0
331  
332 0 $output->print("=item $option$params\n\n");
333 0 $self;
334 }
335  
336 sub showOptionExpand(@)
337 0 ▶{ my ($self, %args) = @_;
Subroutine showOptionExpand: not called CC=6 SCAR=37.4
Pod documented
338 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
339 0 ▶ my $option = $args{option} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $option = $args{"option"} or &panic() 0 0 0
340 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
341  
342 0 $self->showOptionUse(%args);
343  
344 0 ▶ my $where = $option->findDescriptionObject or return $self;
Branch: 1 branch
BranchTrueFalseTotal
my $where = $option->findDescriptionObject or return $self 0 0 0
345 0 my $descr = $self->cleanup($manual, $where->description);
346 0 ▶ $output->print("\n$descr\n\n")
Branch: 1 branch
BranchTrueFalseTotal
if length $descr 0 0 0
347 if length $descr;
348  
349 0 $self;
350 }
351  
352  
353 sub writeTable($@)
354 0 ▶{ my ($self, %args) = @_;
Subroutine writeTable: not called CC=13 SCAR=52.0
Pod documented
355  
356 0 ▶ my $head = $args{header} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $head = $args{"header"} or &panic() 0 0 0
357 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
358 0 ▶ my $rows = $args{rows} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $rows = $args{"rows"} or &panic() 0 0 0
359 0 ▶ return unless @$rows;
Branch: 1 branch
BranchTrueFalseTotal
unless @$rows 0 0 0
360  
361 # Convert all elements to plain text, because markup is not
362 # allowed in verbatim pod blocks.
363 0 my @rows;
364 0 foreach my $row (@$rows)
365 0 { push @rows, [ map {$self->removeMarkup($_)} @$row ];
366 }
367  
368 # Compute column widths
369 0 my @w = (0) x @$head;
370  
371 0 foreach my $row ($head, @rows)
372 { $w[$_] = max $w[$_], length($row->[$_])
373 0 foreach 0..$#$row;
374 }
375  
376 0 ▶ if(my $widths = $args{widths})
Branch: 1 branch
BranchTrueFalseTotal
if (my $widths = $args{"widths"}) 0 0 0
377 { defined $widths->[$_] && $widths->[$_] > $w[$_] && ($w[$_] = $widths->[$_])
378 0 ▶ for 0..$#$rows;
Branch: 1 branch
BranchTrueFalseTotal
defined $widths->[$_] and $widths->[$_] > $w[$_] and $w[$_] = $widths->[$_] 0 0 0
Condition0%0/3
defined $widths->[$_] and $widths->[$_] > $w[$_]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $widths->[$_] and $widths->[$_] > $w[$_]
defined $widths->[$_] $widths->[$_] > $w[$_]
Truth table0%0/3
A and B
A= defined $widths->[$_]B= $widths->[$_] > $w[$_]
ABresult
0X0
100
111
379 }
380  
381 0 pop @w; # ignore width of last column
382  
383 # Table head
384 0 my $headf = " -".join("--", map { "\%-${_}s" } @w)."--%s\n";
385 0 $output->printf($headf, @$head);
386  
387 # Table body
388 0 my $format = " ".join(" ", map { "\%-${_}s" } @w)." %s\n";
389 $output->printf($format, @$_)
390 0 for @rows;
391 }
392  
393  
394 sub removeMarkup($)
395 20 ▶{ my ($self, $string) = @_;
Subroutine removeMarkup: called CC=2 SCAR=6.9
Pod documented
396 20 my $out = $self->_removeMarkup($string);
397 20 for($out)
398 20 { s/^\s+//gm;
399 20 s/\s+$//gm;
400 20 s/\s{2,}/ /g;
401 20 s/\[NB\]/ /g;
402 }
403 20 $out;
404 }
405  
406 sub _removeMarkup($)
407 37 ▶{ my ($self, $string) = @_;
Subroutine _removeMarkup: called CC=14 SCAR=27.7
408  
409 37 my $out = '';
410 37 ▶ while($string =~ s/(.*?) # before
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/(.*?) # before ([BCEFILSXZ]) # known formatting codes ([<]+) # capture ALL starters //x) 27 37 64
411 ([BCEFILSXZ]) # known formatting codes
412 ([<]+) # capture ALL starters
413 //x)
414 27 { $out .= $1;
415 27 my ($tag, $bracks, $brack_count) = ($2, $3, length($3));
416  
417 27 ▶ if($string !~ s/^(|.*?[^>]) # contained
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ s/^(|.*?[^>]) # contained [>]{$brack_count} (?![>]) //sx) 0 27 27
418 [>]{$brack_count}
419 (?![>])
420 //xs)
421 0 { $out .= "$tag$bracks";
422 0 next;
423 }
424  
425 27 my $container = $1;
426 27 ▶ if($tag =~ m/[XZ]/) { ; } # ignore container content
Branch: 6 branches
BranchTrueFalseTotal
if ($tag =~ /[XZ]/) { } 3 24 27
elsif ($tag =~ /[BCI]/) { } 13 11 24
elsif ($tag eq 'E') { } 3 8 11
elsif ($tag eq 'F') { } 0 8 8
elsif ($tag eq 'L') { } 8 0 8
elsif ($tag eq 'S') { } 0 0 0
427 elsif($tag =~ m/[BCI]/) # cannot display, but can be nested
428 13 { $out .= $self->_removeMarkup($container);
429 }
430 3 elsif($tag eq 'E') { $out .= e2char($container) }
431 0 elsif($tag eq 'F') { $out .= $container }
432 elsif($tag eq 'L')
433 8 ▶ { if($container =~ m!^\s*([^/|]*)\|!)
Branch: 1 branch
BranchTrueFalseTotal
if ($container =~ m[^\s*([^/|]*)\|]) 4 4 8
434 4 { $out .= $self->_removeMarkup($1);
435 4 next;
436 }
437  
438 4 my ($man, $chapter) = ($container, '');
439 4 ▶ if($container =~ m!^\s*([^/]*)/\"([^"]*)\"\s*$!)
Branch: 2 branches
BranchTrueFalseTotal
if ($container =~ m[^\s*([^/]*)/\"([^"]*)\"\s*$]) { } 2 2 4
elsif ($container =~ m[^\s*([^/]*)/(.*?)\s*$]) { } 1 1 2
440 2 { ($man, $chapter) = ($1, $2);
441 }
442 elsif($container =~ m!^\s*([^/]*)/(.*?)\s*$!)
443 1 { ($man, $chapter) = ($1, $2);
444 }
445  
446 $out .=
447 4 ▶ ( !length $man ? "section $chapter"
Branch: 2 branches
BranchTrueFalseTotal
!length($man) ? : 1 3 4
!length($chapter) ? : 1 2 3
448 : !length $chapter ? $man
449 : "$man section $chapter"
450 );
451 }
452 elsif($tag eq 'S')
453 0 { my $clean = $self->_removeMarkup($container);
454 0 $clean =~ s/ /[NB]/g;
455 0 $out .= $clean;
456 }
457 }
458  
459 37 $out . $string;
460 }
461  
462 sub showSubroutineDescription(@)
463 0 ▶{ my ($self, %args) = @_;
Subroutine showSubroutineDescription: not called CC=7 SCAR=40.3
Pod documented
464 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
465 0 ▶ my $subroutine = $args{subroutine} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $subroutine = $args{"subroutine"} or &panic() 0 0 0
466  
467 0 my $text = $self->cleanup($manual, $subroutine->description);
468 0 ▶ return $self unless length $text;
Branch: 1 branch
BranchTrueFalseTotal
unless length $text 0 0 0
469  
470 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
471 0 $output->print("\n", $text);
472  
473 0 ▶ my $extends = $self->extends or return $self;
Branch: 1 branch
BranchTrueFalseTotal
my $extends = $self->extends or return $self 0 0 0
474 0 ▶ my $refer = $extends->findDescriptionObject or return $self;
Branch: 1 branch
BranchTrueFalseTotal
my $refer = $extends->findDescriptionObject or return $self 0 0 0
475 0 $self->showSubroutineDescriptionRefer(%args, subroutine => $refer);
476 }
477  
478 sub showSubroutineDescriptionRefer(@)
479 0 ▶{ my ($self, %args) = @_;
Subroutine showSubroutineDescriptionRefer: not called CC=4 SCAR=30.0
Pod undocumented
480 0 ▶ my $manual = $args{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args{"manual"} or &panic() 0 0 0
481 0 ▶ my $subroutine = $args{subroutine} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $subroutine = $args{"subroutine"} or &panic() 0 0 0
482 0 ▶ my $output = $args{output} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $output = $args{"output"} or &panic() 0 0 0
483 0 $output->print("\nInherited, see ",$self->link($manual, $subroutine),"\n");
484 }
485  
486 ▶sub showSubsIndex() {;}
Subroutine showSubsIndex: not called CC=1 SCAR=0.0
Pod undocumented
487  
488  
489 sub cleanupPOD($$)
490 0 ▶{ my ($self, $infn, $outfn) = @_;
Subroutine cleanupPOD: not called CC=7 SCAR=40.3
Pod documented
491 0 ▶ my $in = IO::File->new($infn, 'r')
Branch: 1 branch
BranchTrueFalseTotal
my $in = "IO::File"->new($infn, "r") or &fault(&__x("cannot read prelimary pod from {file}", "file", $infn)) 0 0 0
492 or fault __x"cannot read prelimary pod from {file}", file => $infn;
493  
494 0 ▶ my $out = IO::File->new($outfn, 'w')
Branch: 1 branch
BranchTrueFalseTotal
my $out = "IO::File"->new($outfn, "w") or &fault(&__x("cannot write final pod to {file}", "file", $outfn)) 0 0 0
495 or fault __x"cannot write final pod to {file}", file => $outfn;
496  
497 0 my $last_is_blank = 1;
498 LINE:
499 0 ▶ while(my $l = $in->getline)
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = $in->getline) 0 0 0
500 0 ▶ { if($l =~ m/^\s*$/s)
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /^\s*$/s) { } 0 0 0
501 0 ▶ { next LINE if $last_is_blank;
Branch: 1 branch
BranchTrueFalseTotal
if $last_is_blank 0 0 0
502 0 $last_is_blank = 1;
503 }
504 else
505 0 { $last_is_blank = 0;
506 }
507  
508 0 $out->print($l);
509 }
510  
511 0 $in->close;
512 0 ▶ $out->close
Branch: 1 branch
BranchTrueFalseTotal
$out->close or &fault(&__x("write to {file} failed", "file", $outfn)) 0 0 0
513 or fault __x"write to {file} failed", file => $outfn;
514  
515 0 $self;
516 }
517  
518  
519 2 1;
« lib/OODoc/Parser/Markov.pm ↑ Summary blib/lib/OODoc/Parser/Markov.pm »