lib/OODoc/Format/Pod.pm

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