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