lib/Pod/Classdoc.pm

filter: Statementstmt 79.0% 377 / 477 Branchbran 59.6% 161 / 270 Conditioncond 55.1% 54 / 98 MC/DCmcdc 36.5% 19 / 52 Subroutinesub 87.8% 29 / 33 Podpod 0.0% 0 / 13 totaltotal 67.8% 640 / 943 CC 199 SCAR 42.6
CC
199
Cov
70%
_generateDoc
214.2
openProject
72.0
_getSubDirs
42.0
CRAP 71.0
« lib/Pod/Classdoc/Project.pm ↑ Summary lib/Pod/mkprojdocs.pl »
1 =pod
2  
3 =begin classdoc
4  
5 Generate javadoc-like class documentation from embedded POD.
6 Uses <cpan>PPI::Find</cpan> to locate POD, packages, and methods, then
7 processes the extracted POD into a javadoc-ish HTML format. Classdoc POD
8 is defined within <code>=begin classdoc</code> and
9 <code>=end classdoc</code> sections. Each such section is associated
10 with its immediately succeding package or method statement, unless
11 the <code>@xs</code> directive is specified, in which case
12 the classdoc is assumed to be for an external (e.g., XS) method.
13 Multiple external method classdoc sections may be specified within a single
14 <code>=pod ... =cut</code> section, with the final such classdoc section
15 associated with any trailing method definition.
16  
17 @author Dean Arnold
18 @see <cpan>PPI</cpan>
19 @see <cpan>PPI::Find</cpan>
20 @see <a href='http://java.sun.com/j2se/javadoc/writingdoccomments/'>"How to Write Doc Comments for the Javadoc Tool"</a>
21 @since 2007-Jun-10
22 @instance hash
23 @self $self
24  
25 =end classdoc
26  
27 =cut
28  
29 package Pod::Classdoc;
30  
31 3 ▶use PPI;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 3 ▶use PPI::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 3 ▶use PPI::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 3 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 3 our $VERSION = '1.01';
40  
41 3 my %validpkgtags = (qw(
42 author 2
43 deprecated 1
44 exports 1
45 ignore 1
46 imports 1
47 instance 1
48 member 1
49 see 2
50 self 1
51 since 1
52 ));
53  
54 3 my %validsubtags = (qw(
55 author 2
56 constructor 1
57 deprecated 1
58 ignore 1
59 param 1
60 optional 1
61 return 1
62 returnlist 1
63 see 2
64 self 1
65 simplex 1
66 since 1
67 static 1
68 urgent 1
69 ));
70  
71 3 my %secttags = (
72 'export' => '_e_',
73 'import' => '_i_',
74 'member' => '_m_',
75 'method' => '_f_',
76 'package' => '_p_'
77 );
78 #
79 # our default color theme; change these
80 # for different look
81 #
82 3 my $aqua = '#98B5EB';
83  
84 #
85 # our database:
86 # key is class name
87 # contents are
88 # author => '',
89 # since => '',
90 # version => '',
91 # InheritsFrom => {},
92 # SubclassedBy => {},
93 # Description => '',
94 # File => '',
95 # Line => '',
96 # see => [],
97 # deprecated => undef|1,
98 # exports => [],
99 # imports => [],
100 # members => [],
101 # instance => '',
102 # self => '',
103 # Methods =>
104 # {
105 # $name =>
106 # {
107 # Description => '',
108 # File => '',
109 # Line => '',
110 # static => undef|1,
111 # self => '',
112 # deprecated => undef|1,
113 # see => [],
114 # since => '',
115 # param => [ 'name', 'description', ... ],
116 # return => 'description',
117 # returnlist => 'description',
118 # simplex => undef|1,
119 # urgent => undef|1,
120 # constructor => 1|undef
121 # }
122 # }
123 #
124  
125 =pod
126  
127 =begin classdoc
128  
129 Creates a new empty Pod::Classdoc object.
130  
131 @constructor
132  
133 @optional $path directory path for output documents; default is './classdocs'
134 @optional $title title string to use for head of classdocs
135 @optional $verbose if true, enables diagnostic output (default false)
136  
137 @return a new Pod::Classdoc object
138  
139 =end classdoc
140  
141 =cut
142  
143 1 ▶sub new {
Subroutine new: called CC=4 SCAR=14.6
Pod undocumented
144 1 my ($class, $path, $title, $verbose) = @_;
145 1 ▶ $path ||= './classdocs';
Condition50%1/2
$path ||= "./classdocs"
l!l
10
MC/DC0%0/1
$path ||= "./classdocs"
$path
Truth table50%1/2
A
A= $path
Aresult
11
00
146 1 ▶ $path=~s/\/+$// unless ($path eq '/');
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "/" 1 0 1
147 1 ▶ my $self = {
Condition50%1/2
$verbose || 0
l!l
10
MC/DC0%0/1
$verbose || 0
$verbose
Truth table50%1/2
A
A= $verbose
Aresult
11
00
148 _path => $path,
149 _classes => {},
150 _title => $title,
151 _verbose => $verbose || 0,
152 };
153 1 return bless $self, $class;
154 }
155  
156 =pod
157  
158 =begin classdoc
159  
160 Scan the provided text for Perl packages, adding the packages
161 to the current collection of classes. When a package is located,
162 it is scanned for its inherited classes and classdoc'd methods.
163  
164 @param $txt the package text as either a scalar string, or an arrayref of
165 the lines of the package
166 @optional $file full path of source file
167  
168 @return the PPI::Document object generated from the input text
169  
170 =end classdoc
171  
172 =cut
173  
174 1 ▶sub add {
Subroutine add: called CC=13 SCAR=30.4
Pod undocumented
175 1 my ($self, $txt, $file) = @_;
176 1 ▶ $txt = join("\n", @$txt)
Branch: 1 branch
BranchTrueFalseTotal
if ref $txt 0 1 1
177 if ref $txt;
178 #
179 # grab version as for MakeMaker;
180 # note only one version per source file
181 #
182 1 my $version;
183 1 ▶ if ($txt=~/\n\s*((my|our|local)\s+)?\$[\w\:\']*?\bVERSION\s*?\=([^;]+?);/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($txt =~ /\n\s*((my|our|local)\s+)?\$[\w\:\']*?\bVERSION\s*?\=([^;]+?);/) 1 0 1
184 1 eval "\$version = $3;";
185 }
186  
187 1 $self->{_state} = 0;
188 1 $self->{_currpkg} = '';
189 1 $self->{_currpod} = '';
190 1 $self->{_currsub} = '';
191 1 $self->{_currloc} = undef;
192 1 $self->{_currtext} = $txt;
193 1 $self->{_currfile} = $file;
194 1 $self->{_nosubs} = 0;
195  
196 1 ▶ my $Document = PPI::Document->new(\$txt) or die "Can't process into PPI::Document";
Branch: 1 branch
BranchTrueFalseTotal
my $Document = "PPI::Document"->new(\$txt) or die "Can't process into PPI::Document" 1 0 1
197  
198 # Create the Find object
199 1 ▶ my $Finder = PPI::Find->new( sub { $self->_wanted(@_); } ) or die "Can't create PPI::Find";
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
my $Finder = "PPI::Find"->new(sub { $self->_wanted(@_); } ) or die "Can't create PPI::Find" 1 0 1
200 # Use the object as an iterator
201 1 ▶ $Finder->start($Document) or die "Failed to execute search";
Branch: 1 branch
BranchTrueFalseTotal
$Finder->start($Document) or die "Failed to execute search" 1 0 1
202 #
203 # process any trailing classdoc section
204 #
205 $self->{_nosubs} += _processClassdocs(undef, $self->{_currpod}, $self->{_currloc}, $self->{_currloc}, $file, $self->{_classes}, $self->{_currpkg})
206 1 ▶ if $self->{_currpod};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_currpod"} 1 0 1
207 #
208 # process any open package
209 #
210 1 ▶ $self->_processPackage() if $self->{_currpkg};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_currpkg"} 1 0 1
211  
212 warn "$self->{_nosubs} classdoc sections found without matching methods."
213 1 ▶ if $self->{_nosubs} && $self->{_verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_nosubs"} and $self->{"_verbose"} 0 1 1
Condition33%1/3
$self->{"_nosubs"} and $self->{"_verbose"}
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"_nosubs"} and $self->{"_verbose"}
$self->{"_nosubs"} $self->{"_verbose"}
Truth table33%1/3
A and B
A= $self->{"_nosubs"}B= $self->{"_verbose"}
ABresult
0X0
100
111
214  
215 1 ▶ if ($self->{_verbose} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_verbose"} > 1) 0 1 1
216  
217 0 foreach my $currpkg (sort keys %{$self->{_classes}}) {
218 0 my $pkg = $self->{_classes}{$currpkg};
219 0 print "Package $currpkg at line $pkg->{File}:$pkg->{Line}:\n$pkg->{Description}\n\nhas the following methods:\n\n";
220 0 my $sub;
221 $sub = $pkg->{Methods}{$_},
222 print "**********\n$_ at line $sub->{File}:$sub->{Line}:\n$sub->{Description}\n\n"
223 0 foreach (sort keys %{$pkg->{Methods}});
224 }
225 }
226  
227 1 return $Document;
228 }
229  
230 =pod
231  
232 =begin classdoc
233  
234 Load the specified package file.
235  
236 @param $path path to the package file.
237 @param $pkg Perl name of the package
238  
239 @return the PPI::Document object generated from the input file
240  
241 =end classdoc
242  
243 =cut
244  
245 0 ▶sub open {
Subroutine open: not called CC=5 SCAR=34.0
Pod undocumented
246 0 my ($self, $path, $pkg) = @_;
247  
248 0 ▶ my $file = $pkg ? "$path/$pkg" : $path;
Branch: 1 branch
BranchTrueFalseTotal
$pkg ? : 0 0 0
249 0 $file=~s/::/\//g;
250 0 ▶ $file .= '.pm' if $pkg;
Branch: 1 branch
BranchTrueFalseTotal
if $pkg 0 0 0
251 0 ▶ $@ = "Cannot open $file: $!" and
Branch: 1 branch
BranchTrueFalseTotal
unless CORE::open INF, $file 0 0 0
Condition0%0/5
CORE::open(INF, $file) || ($@ = "Cannot open ${file}: $!") && (return undef)
l!l&&r!l&&!r
000
$@ = "Cannot open ${file}: $!" and return undef
!ll
00
MC/DC0%0/2
CORE::open(INF, $file) || ($@ = "Cannot open ${file}: $!") && (return undef)
CORE::open(INF, $file) $@ = "Cannot open ${file}: $!"
Truth table0%0/3
A || B
A= CORE::open(INF, $file)B= $@ = "Cannot open ${file}: $!"
ABresult
1X1
011
000
252 return undef
253 unless open(INF, $file);
254  
255 0 my $oldsep = $/;
256 0 $/ = undef;
257 0 my $doc = <INF>;
258 0 close INF;
259 0 $/ = $oldsep;
260  
261 0 return $self->add($doc, $file);
262 }
263  
264 =pod
265  
266 =begin classdoc
267  
268 Load all the package files within a specified project directory.
269 Recurses into subdirectories as needed.
270  
271 @param @projects list of pathnames of root project directories
272  
273 @return this Pod::Classdoc object
274  
275 =end classdoc
276  
277 =cut
278  
279 0 ▶sub openProject {
Subroutine openProject: not called CC=8 SCAR=42.8
Pod undocumented
280 0 my $self = shift;
281  
282 $self->_getSubDirs($_)
283 0 foreach @_;
284 0 my $dirs = $self->{_dirs};
285 print "Scanning ", join("\n", @$dirs), "\n"
286 0 ▶ if $self->{_verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} 0 0 0
287  
288 0 my @files = ();
289 0 foreach my $path (@$dirs) {
290 0 ▶ unless (opendir(PATH, $path)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (opendir PATH, $path) 0 0 0
291 warn "directory $path not found"
292 0 ▶ if $self->{_verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} 0 0 0
293 0 next;
294 }
295 #
296 # glob the directory for all .pm files;
297 #
298 0 my @tfiles = readdir PATH;
299 0 closedir PATH;
300  
301 0 push @files, map "$path/$_", grep /\.pm$/, @tfiles;
302 }
303  
304 0 foreach (@files) {
305 return undef
306 0 ▶ unless $self->open($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->open($_) 0 0 0
307 }
308 0 return $self;
309 }
310  
311 39 ▶sub _processClassdocs {
Subroutine _processClassdocs: called CC=8 SCAR=20.8
312 39 my ($currsub, $currpod, $podloc, $subloc, $file, $packages, $currpkg) = @_;
313 #
314 # collect all classdocs first, there may be a list of @xs before a real sub
315 #
316 39 ▶ my @classdocs = $currpod ?
Branch: 1 branch
BranchTrueFalseTotal
$currpod ? : 38 1 39
317 ($currpod=~/\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs) :
318 ();
319 39 ▶ if ($currsub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currsub) 37 2 39
320 #
321 # if a real sub, grab the last one...but make sure it isn't for @xs
322 #
323 37 $currpod = pop @classdocs;
324 37 ▶ if ((!$currpod) || ($currpod=~/\n\s*\@xs\s+/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $currpod or $currpod =~ /\n\s*\@xs\s+/) { } 2 35 37
Condition100%3/3
not $currpod or $currpod =~ /\n\s*\@xs\s+/
l!l&&r!l&&!r
1135
MC/DC100%2/2
not $currpod or $currpod =~ /\n\s*\@xs\s+/
not $currpod $currpod =~ /\n\s*\@xs\s+/
Truth table100%3/3
not(A) or B
A= not $currpodB= $currpod =~ /\n\s*\@xs\s+/
ABresult
1X1
011
000
325 2 ▶ push @classdocs, $currpod if $currpod;
Branch: 1 branch
BranchTrueFalseTotal
if $currpod 1 1 2
326 2 _processSub($currsub, undef, $subloc, $file, $packages, $currpkg);
327 }
328 else {
329 35 _processSub($currsub, $currpod, $subloc, $file, $packages, $currpkg);
330 }
331 }
332 39 my $nosubs = 0;
333 39 foreach (@classdocs) {
334 #
335 # flag unexpected classdocs
336 #
337 62 ▶ if (s/\n\s*\@xs\s+([\w\:]+)[ \t\r]*\n/\n/s) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/\n\s*\@xs\s+([\w\:]+)[ \t\r]*\n/\n/s) { } 62 0 62
338 62 _processSub($1, $_, $podloc, $file, $packages, $currpkg);
339 }
340 else {
341 0 $nosubs++;
342 }
343 }
344 39 return $nosubs;
345 }
346  
347 99 ▶sub _processSub {
Subroutine _processSub: called CC=5 SCAR=20.3
348 99 my ($currsub, $currpod, $subloc, $file, $packages, $currpkg) = @_;
349 #
350 # need to check for fully qualified sub name
351 #
352 99 my @parts = split /\:\:/, $currsub;
353 99 ▶ if (@parts > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@parts > 1) 0 99 99
354 0 $currsub = pop @parts;
355 0 $currpkg = join('::', @parts);
356 }
357 $packages->{$currpkg} = {
358 File => '',
359 Line => 0,
360 Description => undef,
361 Methods => {}
362 }
363 99 ▶ unless exists $packages->{$currpkg};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $packages->{$currpkg} 0 99 99
364  
365 99 ▶ if (exists $packages->{$currpkg}{Methods}{$currsub}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $packages->{$currpkg}{'Methods'}{$currsub}) { } 0 99 99
366 $packages->{$currpkg}{Methods}{$currsub}{File} = $file,
367 $packages->{$currpkg}{Methods}{$currsub}{Line} = $subloc,
368 $packages->{$currpkg}{Methods}{$currsub}{Description} = $currpod
369 0 ▶ unless $packages->{$currpkg}{Methods}{$currsub}{File};
Branch: 1 branch
BranchTrueFalseTotal
unless $packages->{$currpkg}{"Methods"}{$currsub}{"File"} 0 0 0
370 }
371 else {
372 99 $packages->{$currpkg}{Methods}{$currsub} = {
373 File => $file,
374 Line => $subloc,
375 Description => $currpod
376 };
377 }
378 }
379  
380 20083 ▶sub _wanted {
Subroutine _wanted: called CC=25 SCAR=37.3
381 20083 my ($self, $token, $parent) = @_;
382
383 print "*** Got a ", ref $token, "\n"
384 20083 ▶ if ($self->{_verbose} > 2) && ($token->significant || $token->isa('PPI::Token::Pod'));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} > 2 and $token->significant || $token->isa("PPI::Token::Pod") 0 20083 20083
Condition16%1/6
$self->{"_verbose"} > 2 and $token->significant || $token->isa("PPI::Token::Pod")
!ll&&!rl&&r
2008300
$token->significant or $token->isa("PPI::Token::Pod")
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->{"_verbose"} > 2 and $token->significant || $token->isa("PPI::Token::Pod")
$self->{"_verbose"} > 2 $token->significant $token->isa("PPI::Token::Pod")
Truth table25%1/4
A and B or C
A= $self->{"_verbose"} > 2B= $token->significantC= $token->isa("PPI::Token::Pod")
ABCresult
0XX0
1000
11X1
1011
385  
386 20083 ▶ return 0 if ($self->{_state} == 0) && (!$token->isa('PPI::Token::Pod'));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_state"} == 0 and not $token->isa("PPI::Token::Pod") 19683 400 20083
Condition100%3/3
$self->{"_state"} == 0 and not $token->isa("PPI::Token::Pod")
!ll&&!rl&&r
3584219683
MC/DC100%2/2
$self->{"_state"} == 0 and not $token->isa("PPI::Token::Pod")
$self->{"_state"} == 0 not $token->isa("PPI::Token::Pod")
Truth table100%3/3
A and not(B)
A= $self->{"_state"} == 0B= not $token->isa("PPI::Token::Pod")
ABresult
0X0
100
111
387  
388 400 my $content;
389 400 ▶ if ($self->{_state} == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_state'} == 0) { } 42 358 400
elsif ($self->{'_state'} == 1) { } 358 0 358
390 42 $content = $token->content;
391 42 ▶ return 0 unless $content=~/\n=begin\s+classdoc[ \r\t]*\n.*?\n=end\s+classdoc[ \r\t]*\n/s;
Branch: 1 branch
BranchTrueFalseTotal
unless $content =~ /\n=begin\s+classdoc[ \r\t]*\n.*?\n=end\s+classdoc[ \r\t]*\n/s 0 42 42
392 print "** Process a new POD\n"
393 42 ▶ if ($self->{_verbose} > 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} > 1 0 42 42
394 42 $self->{_currpod} = $content;
395 42 $self->{_currloc} = ${$token->location}[0];
396 42 $self->{_state} = 1;
397 }
398 elsif ($self->{_state} == 1) {
399 #
400 # we'll support dangling classdocs and nested POD (have to, to support @xs!)
401 #
402 358 ▶ if ($token->isa('PPI::Token::Pod')) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token->isa('PPI::Token::Pod')) { } 1 357 358
elsif ($token->isa('PPI::Statement::Package')) { } 4 353 357
elsif ($token->isa('PPI::Statement::Sub')) { } 37 316 353
403 1 $content = $token->content;
404 1 ▶ return 0 unless $content=~/\n=begin\s+classdoc[ \r\t]*\n.*?\n=end\s+classdoc[ \r\t]*\n/s;
Branch: 1 branch
BranchTrueFalseTotal
unless $content =~ /\n=begin\s+classdoc[ \r\t]*\n.*?\n=end\s+classdoc[ \r\t]*\n/s 0 1 1
405 #
406 # process prior classdoc section
407 #
408 print "** Process a new dangling POD\n"
409 1 ▶ if ($self->{_verbose} > 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} > 1 0 1 1
410 1 $self->{_nosubs} += _processClassdocs(undef, $self->{_currpod}, $self->{_currloc}, $self->{_currloc}, $self->{_currfile}, $self->{_classes}, $self->{_currpkg});
411 1 $self->{_currpod} = $1;
412 1 $self->{_currloc} = ${$token->location}[0];
413 }
414 elsif ($token->isa('PPI::Statement::Package')) {
415 print "** Process a Package\n"
416 4 ▶ if ($self->{_verbose} > 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} > 1 0 4 4
417 #
418 # if a prior namespace defined, save its body and recover any
419 # inheritance info; we should really try to use PPI here...
420 #
421 3 $self->_processPackage(${$token->location}[0])
422 4 ▶ if $self->{_currpkg};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_currpkg"} 3 1 4
423 4 $self->{_currpkg} = $token->namespace;
424  
425 4 ▶ if (exists $self->{_classes}{$self->{_currpkg}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'_classes'}{$self->{'_currpkg'}}) { } 0 4 4
426 $self->{_classes}{$self->{_currpkg}}{File} = $self->{_currfile},
427 0 ▶ $self->{_classes}{$self->{_currpkg}}{Line} = ${$token->location}[0],
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_currpod'} && $self->{'_currpod'} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs ? : 0 0 0
Condition0%0/3
$self->{"_currpod"} and $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"_currpod"} and $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
$self->{"_currpod"} $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
Truth table0%0/3
A and B
A= $self->{"_currpod"}B= $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
ABresult
0X0
100
111
428 $self->{_classes}{$self->{_currpkg}}{Description} =
429 ($self->{_currpod} && $self->{_currpod}=~/\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs) ? $1 : undef
430 0 ▶ unless $self->{_classes}{$self->{_currpkg}}{File};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_classes"}{$self->{"_currpkg"}}{"File"} 0 0 0
431 }
432 else {
433 $self->{_classes}{$self->{_currpkg}} = {
434 File => $self->{_currfile},
435 4 ▶ Line => ${$token->location}[0],
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_currpod'} && $self->{'_currpod'} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs ? : 4 0 4
Condition33%1/3
$self->{"_currpod"} and $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
!ll&&!rl&&r
004
MC/DC0%0/2
$self->{"_currpod"} and $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
$self->{"_currpod"} $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
Truth table33%1/3
A and B
A= $self->{"_currpod"}B= $self->{"_currpod"} =~ /\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs
ABresult
0X0
100
111
436 4 Description => ($self->{_currpod} && $self->{_currpod}=~/\n=begin\s+classdoc[ \r\t]*\n(.*?)\n=end\s+classdoc[ \r\t]*\n/gs) ? $1 : undef,
437 Methods => {}
438 };
439 }
440 4 $self->{_currpod} = '';
441 4 $self->{_currloc} = undef;
442 4 $self->{_state} = 0;
443 }
444 elsif ($token->isa('PPI::Statement::Sub')) {
445 0 die "Unexpected sub $content at line " . ${$token->location}[0]
446 37 ▶ unless $self->{_currpkg};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_currpkg"} 0 37 37
447  
448 print "** Process a Sub\n"
449 37 ▶ if ($self->{_verbose} > 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} > 1 0 37 37
450 37 $self->{_nosubs} += _processClassdocs($token->name, $self->{_currpod}, $self->{_currloc}, ${$token->location}[0], $self->{_currfile}, $self->{_classes}, $self->{_currpkg});
451 37 $self->{_currpod} = '';
452 37 $self->{_currloc} = undef;
453 37 $self->{_state} = 0;
454 }
455 }
456 400 return 1;
457 }
458  
459 4 ▶sub _processPackage {
Subroutine _processPackage: called CC=4 SCAR=14.2
460 4 my ($self, $end) = @_;
461 #
462 # if a prior namespace defined, save its body and recover any
463 # inheritance info; we should really try to use PPI here...
464 #
465 4 my $pkg = $self->{_classes}{$self->{_currpkg}};
466 my $txt = "\n" .
467 (defined $end ?
468 substr($self->{_currtext}, $pkg->{Line}, $end - $pkg->{Line}) :
469 4 ▶ substr($self->{_currtext}, $pkg->{Line}));
Branch: 1 branch
BranchTrueFalseTotal
defined $end ? : 3 1 4
470  
471 4 my @parents = ($txt=~/\n\s*use\s+base\s+([^;]+);/gs);
472 4 foreach my $base (@parents) {
473 0 my @bases = ();
474 0 eval "\@bases = $base;";
475 0 map $pkg->{InheritsFrom}{$_} = 1, @bases;
476 }
477 4 @parents = ($txt=~/\n\s*(?:(?:my|our)\s+)?\@ISA\s+=\s+([^;]+);/gs);
478 4 foreach my $base (@parents) {
479 1 my @bases = ();
480 1 eval "\@bases = $base;";
481 1 map $pkg->{InheritsFrom}{$_} = 1, @bases;
482 }
483 }
484  
485 =pod
486  
487 =begin classdoc
488  
489 Get or set the output directory path for rendered documents.
490  
491 @optional $path root directory where classdocs are to be written; if not provided,
492 a Get operation is executed
493  
494 @returns for a Get operation, the current output path;
495 for a Set operation, the prior output path
496  
497 =end classdoc
498  
499 =cut
500  
501 3 ▶sub path {
Subroutine path: called CC=3 SCAR=11.0
Pod undocumented
502 3 my ($self, $path) = @_;
503
504 3 ▶ return $self->{_path} unless $path;
Branch: 1 branch
BranchTrueFalseTotal
unless $path 2 1 3
505 1 ▶ $path=~s/\/+$// unless ($path eq '/');
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "/" 1 0 1
506 1 my $old = $self->{_path};
507 1 $self->{_path} = $path;
508 1 return $old;
509 }
510  
511 =pod
512  
513 =begin classdoc
514  
515 Render the loaded packages into classdocs. Creates
516 subdirectories for subordinate classdocs as needed.
517 Package files containing multiple package definitions
518 will result in individual files for each package.
519  
520 @optional $use_private include private methods. By default,
521 only public methods are included in the output; setting this flag
522 causes any documented private methods (methods beginning with an
523 underscore) to be included as well. Note that constructors
524 are always considered public.
525  
526 @returns on success, a hashref mapping classnames to an arrayref
527 of the classdoc formatted output, the input source file name and line number
528 of the class's associated classdoc'd package definition, and
529 a hashref mapping method names to an arrayref of source file name and
530 linenumber;
531 undef on failure, with error message in $@
532  
533 =end classdoc
534  
535 =cut
536  
537 2 ▶sub render {
Subroutine render: called CC=11 SCAR=24.8
Pod undocumented
538 2 my ($self, $use_private) = @_;
539  
540 2 my $descr;
541 2 my $version = '';
542 2 my $accum = '';
543 2 my $indoc;
544 my $inpod;
545 2 my $classes = $self->{_classes};
546 2 my ($class, $content);
547 2 my $path = $self->{_path};
548 #
549 # now create crossref of inherits/subclasses
550 #
551 2 foreach $class (keys %$classes) {
552 8 foreach (keys %$classes) {
553 $classes->{$class}{SubclassedBy}{$_} = 1
554 32 ▶ if exists $classes->{$_}{InheritsFrom}{$class};
Branch: 1 branch
BranchTrueFalseTotal
if exists $classes->{$_}{"InheritsFrom"}{$class} 0 32 32
555 }
556 }
557 #
558 # parse each description for tags
559 #
560 2 my ($method, $info);
561 2 foreach $class (keys %$classes) {
562 8 ▶ if ($classes->{$class}{Description}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($classes->{$class}{'Description'}) { } 8 0 8
elsif ($self->{'_verbose'} > 1) { } 0 0 0
563 8 $self->_parseTags($class, $classes->{$class}, \%validpkgtags);
564 }
565 elsif ($self->{_verbose} > 1) {
566 0 warn "No classdoc for $class\n";
567 }
568  
569 8 ▶ while (($method, $info) = each %{$classes->{$class}{Methods}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$classes{$class}{"Methods"};}) 198 8 206
570 198 ▶ if ($info->{Description}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($info->{'Description'}) { } 194 4 198
elsif ($self->{'_verbose'} > 1) { } 0 4 4
571 194 $self->_parseTags($class, $info, \%validsubtags);
572 }
573 elsif ($self->{_verbose} > 1) {
574 0 warn "No classdoc for $class\::$method\n";
575 }
576 }
577 }
578 2 my %classlist;
579 $classlist{$_} = $self->_generateDoc($_, $path, $use_private)
580 2 foreach (keys %$classes);
581  
582 2 return \%classlist;
583 }
584  
585 =pod
586  
587 =begin classdoc
588  
589 Clear this object. Removes all currently loaded packages.
590  
591 @return this object
592  
593 =end classdoc
594  
595 =cut
596  
597 0 ▶sub clear {
Subroutine clear: not called CC=1 SCAR=6.9
Pod undocumented
598 0 my $self = shift;
599  
600 0 $self->{_classes} = {};
601 0 return $self;
602 }
603  
604 =pod
605  
606 =begin classdoc
607  
608 Write out a toplevel container document for the TOC and
609 classdoc frames. Assumes the TOC is named 'toc.html'.
610  
611 @param $container name of output file without path; path is taken
612 from the path specified via <method>new<method>() or
613 <method>path<method>()
614 @optional $home pathname of a toplevel document to be included in index
615  
616 @return this object on success, undef on failure, with error message in $@
617  
618 =end classdoc
619  
620 =cut
621  
622 1 ▶sub writeFrameContainer {
Subroutine writeFrameContainer: called CC=2 SCAR=7.0
Pod undocumented
623 1 my ($self, $container, $home) = @_;
624 1 my $path = $self->{_path};
625 1 ▶ $@ = "Can't open $path/$container: $!",
Branch: 1 branch
BranchTrueFalseTotal
unless CORE::open OUTF, ">$path/$container" 0 1 1
626 return undef
627 unless CORE::open(OUTF, ">$path/$container");
628  
629 1 print OUTF $self->getFrameContainer($home);
630 1 close OUTF;
631 1 return $self;
632 }
633  
634 =pod
635  
636 =begin classdoc
637  
638 Generate a toplevel container document for the TOC and
639 classdoc frames. Assumes the TOC is named 'toc.html'.
640  
641 @optional $home pathname of a toplevel document to be included in index
642  
643 @return the frame container document
644  
645 =end classdoc
646  
647 =cut
648  
649 2 ▶sub getFrameContainer {
Subroutine getFrameContainer: called CC=2 SCAR=7.0
Pod undocumented
650 2 my ($self, $home) = @_;
651  
652 2 my $path = $self->{_path};
653 2 my $title = $self->{_title};
654  
655 2 ▶ return $home ?
Branch: 1 branch
BranchTrueFalseTotal
$home ? : 2 0 2
656 "<html><head><title>$title</title></head>
657 <frameset cols='15%,85%'>
658 <frame name='navbar' src='toc.html' scrolling=auto frameborder=0>
659 <frame name='mainframe' src='$home'>
660 </frameset>
661 </html>
662 " :
663 "<html><head><title>$title</title></head>
664 <frameset cols='15%,85%'>
665 <frame name='navbar' src='toc.html' scrolling=auto frameborder=0>
666 <frame name='mainframe'>
667 </frameset>
668 </html>
669 ";
670  
671 }
672  
673 =pod
674  
675 =begin classdoc
676  
677 Write out an table of contents document for the current collection of
678 classdocs as a nested HTML list. The output filename is 'toc.html'.
679 The caller may optionally specify the order of classes in the menu.
680  
681 @optional @order list of packages in the order in which they should appear in TOC; if a partial list,
682 any remaining packages will be appended to the TOC in alphabetical order
683 @return this object on success, undef on failure, with error message in $@
684  
685 =end classdoc
686  
687 =cut
688  
689 1 ▶sub writeTOC {
Subroutine writeTOC: called CC=2 SCAR=7.0
Pod undocumented
690 1 my $self = shift;
691 1 my $path = $self->{_path};
692 1 ▶ $@ = "Can't open $path/toc.html: $!",
Branch: 1 branch
BranchTrueFalseTotal
unless CORE::open OUTF, ">$path/toc.html" 0 1 1
693 return undef
694 unless CORE::open(OUTF, ">$path/toc.html");
695  
696 1 print OUTF $self->getTOC(@_);
697 1 close OUTF;
698 1 return $self;
699 }
700  
701 =pod
702  
703 =begin classdoc
704  
705 Generate a table of contents document for the current collection of
706 classdocs as a nested HTML list. Caller may optionally specify
707 the order of classes in the menu.
708  
709 @optional @order list of packages in the order in which they should appear in TOC; if a partial list,
710 any remaining packages will be appended to the TOC in alphabetical order
711 @return the TOC document
712  
713 =end classdoc
714  
715 =cut
716  
717 2 ▶sub getTOC {
Subroutine getTOC: called CC=21 SCAR=34.9
Pod undocumented
718 2 my $self = shift;
719  
720 2 my @order = @_;
721 2 my $path = $self->{_path};
722 2 my $title = $self->{_title};
723 2 my $base;
724 2 my $doc =
725 "<html>
726 <body>
727 <small>
728 <!-- INDEX BEGIN -->
729 <ul>
730 ";
731 2 my %ordered = ();
732 2 $ordered{$_} = 1 foreach (@order);
733 2 foreach (sort keys %{$self->{_classes}}) {
734 8 ▶ push @order, $_ unless exists $ordered{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ordered{$_} 8 0 8
735 }
736
737 2 foreach my $class (@order) {
738 #
739 # due to input @order, we might get classes that don't exist
740 #
741 8 ▶ next unless exists $self->{_classes}{$class};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_classes"}{$class} 0 8 8
742  
743 8 $base = $class;
744 8 $base =~s/::/\//g;
745 8 $doc .= "<li><a href='$base.html' target='mainframe'>$class</a>
746 <ul>
747 <li><a href='$base.html#summary' target='mainframe'>Summary</a></li>
748 ";
749 8 my $info = $self->{_classes}{$class};
750 8 my %t;
751 8 my ($k, $v);
752 8 ▶ if (exists $info->{exports} && @{$info->{exports}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"exports"} and @{$info->{"exports"};}) 2 6 8
Condition66%2/3
exists $info->{"exports"} and @{$info->{"exports"};}
!ll&&!rl&&r
602
MC/DC50%1/2
exists $info->{"exports"} and @{$info->{"exports"};}
exists $info->{"exports"} @{$info->{"exports"};}
Truth table66%2/3
A and B
A= exists $info->{"exports"}B= @{$info->{"exports"};}
ABresult
0X0
100
111
753 2 $doc .= "<li><a href='$base.html#exports' target='mainframe'>Exports</a>
754 <ul>
755 ";
756 2 %t = @{$info->{exports}};
757 $doc .= "<li><a href='$base.html#_e_$_' target='mainframe'>$_</a></li>\n"
758 2 foreach (sort keys %t);
759 2 $doc .= "</ul>\n</li>\n";
760 }
761 0 ▶ if (exists $info->{imports} && @{$info->{imports}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"imports"} and @{$info->{"imports"};}) 0 8 8
Condition33%1/3
exists $info->{"imports"} and @{$info->{"imports"};}
!ll&&!rl&&r
800
MC/DC0%0/2
exists $info->{"imports"} and @{$info->{"imports"};}
exists $info->{"imports"} @{$info->{"imports"};}
Truth table33%1/3
A and B
A= exists $info->{"imports"}B= @{$info->{"imports"};}
ABresult
0X0
100
111
762 0 $doc .= "<li><a href='$base.html#imports' target='mainframe'>Imports</a>
763 <ul>
764 ";
765 0 %t = @{$info->{imports}};
766 $doc .= "<li><a href='$base.html#_i_$_' target='mainframe'>$_</a></li>\n"
767 0 foreach (sort keys %t);
768 0 $doc .= "</ul>\n</li>\n";
769 }
770 8 ▶ if (exists $info->{member} && @{$info->{member}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"member"} and @{$info->{"member"};}) 8 0 8
Condition33%1/3
exists $info->{"member"} and @{$info->{"member"};}
!ll&&!rl&&r
008
MC/DC0%0/2
exists $info->{"member"} and @{$info->{"member"};}
exists $info->{"member"} @{$info->{"member"};}
Truth table33%1/3
A and B
A= exists $info->{"member"}B= @{$info->{"member"};}
ABresult
0X0
100
111
771 8 $doc .= "<li><a href='$base.html#members' target='mainframe'>Public Members</a>
772 <ul>
773 ";
774 8 %t = @{$info->{member}};
775 $doc .= "<li><a href='$base.html#_m_$_' target='mainframe'>$_</a></li>\n"
776 8 foreach (sort keys %t);
777 8 $doc .= "</ul>\n</li>\n";
778 }
779 8 ▶ if (exists $info->{constructors} && %{$info->{constructors}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"constructors"} and %{$info->{"constructors"};}) 0 8 8
Condition33%1/3
exists $info->{"constructors"} and %{$info->{"constructors"};}
!ll&&!rl&&r
080
MC/DC0%0/2
exists $info->{"constructors"} and %{$info->{"constructors"};}
exists $info->{"constructors"} %{$info->{"constructors"};}
Truth table33%1/3
A and B
A= exists $info->{"constructors"}B= %{$info->{"constructors"};}
ABresult
0X0
100
111
780 0 $doc .= "<li><a href='$base.html#constructor_detail' target='mainframe'>Constructors</a>
781 <ul>
782 ";
783 $doc .= "<li><a href='$base.html#_f_$_' target='mainframe'>$_</a></li>\n"
784 0 foreach (sort keys %{$info->{constructors}});
785 0 $doc .= "</ul>\n</li>\n";
786 }
787 8 ▶ if (exists $info->{Methods} && %{$info->{Methods}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"Methods"} and %{$info->{"Methods"};}) 8 0 8
Condition33%1/3
exists $info->{"Methods"} and %{$info->{"Methods"};}
!ll&&!rl&&r
008
MC/DC0%0/2
exists $info->{"Methods"} and %{$info->{"Methods"};}
exists $info->{"Methods"} %{$info->{"Methods"};}
Truth table33%1/3
A and B
A= exists $info->{"Methods"}B= %{$info->{"Methods"};}
ABresult
0X0
100
111
788 8 $doc .= "<li><a href='$base.html#method_detail' target='mainframe'>Methods</a>
789 <ul>
790 ";
791 $doc .= "<li><a href='$base.html#_f_$_' target='mainframe'>$_</a></li>\n"
792 8 foreach (sort keys %{$info->{Methods}});
793 8 $doc .= "</ul>\n</li>\n";
794 }
795 8 $doc .= "</ul>\n</li>\n";
796 }
797  
798 2 $doc .= "
799 </ul>
800 <!-- INDEX END -->
801 </small>
802 </body>
803 </html>
804 ";
805  
806 2 return $doc;
807 }
808  
809 =pod
810  
811 =begin classdoc
812  
813 Write out the documents for the current collection of
814 classdocs. Renders the current set of classdocs before
815 writing.
816  
817 @optional $use_private include private methods. By default,
818 only public methods are included in the output; setting this flag
819 causes any documented private methods (methods beginning with an
820 underscore) to be included as well. Note that constructors
821 are always considered public.
822  
823 @return undef on failure, with error message in $@; otherwise, a hashref
824 mapping classnames to an arrayref of the full pathname of the classdoc formatted output file,
825 the input source file name and line number of the class's associated classdoc'd package
826 definition, and a hashref mapping method names to an arrayref of source file name and
827 linenumber.
828  
829 =end classdoc
830  
831 =cut
832  
833 1 ▶sub writeClassdocs {
Subroutine writeClassdocs: called CC=4 SCAR=14.0
Pod undocumented
834 1 my ($self, $use_private) = @_;
835
836 1 ▶ my $classdocs = $self->render($use_private)
Branch: 1 branch
BranchTrueFalseTotal
my $classdocs = $self->render($use_private) or return undef 1 0 1
837 or return undef;
838  
839 1 my $path = $self->{_path};
840 1 foreach (sort keys %$classdocs) {
841 4 my $fname = $self->makeClassPath($_);
842  
843 4 ▶ $@ = "Cannot open $fname: $!",
Branch: 1 branch
BranchTrueFalseTotal
unless CORE::open OUTF, ">$fname" 0 4 4
844 return undef
845 unless CORE::open(OUTF, ">$fname");
846  
847 4 print OUTF $classdocs->{$_}[0];
848 4 close(OUTF);
849 4 $classdocs->{$_}[0] = $fname;
850 }
851 1 return $classdocs;
852 }
853  
854 =pod
855  
856 =begin classdoc
857  
858 Generate fully qualified pathname of output classdoc
859 file for a given package name. Also creates the path
860 if needed.
861  
862 @param $class package name to be resolved to output classdoc file
863  
864 @return the fully qualified pathname to the classdocs for $class,
865 with a '.html' qualifier.
866  
867 =end classdoc
868  
869 =cut
870  
871 4 ▶sub makeClassPath {
Subroutine makeClassPath: called CC=2 SCAR=6.9
Pod undocumented
872 4 my ($self, $class) = @_;
873 4 my $path = $self->{_path};
874 4 $class=~s!::!/!g;
875 4 $class = join('/', $path, $class);
876 4 my ($dir) = ($class=~/^(.*)\/[^\/]+$/);
877 4 ▶ mkpath $dir
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 1 3 4
878 unless -d $dir;
879 4 return "$class.html";
880 }
881  
882 8 ▶sub _generateDoc {
Subroutine _generateDoc: called CC=58 SCAR=53.7
883 8 my ($self, $class, $path, $use_private) = @_;
884 8 my $info = $self->{_classes}{$class};
885 8 my @parts = split /\:\:/, $class;
886 8 my $fname = pop @parts;
887 8 ▶ my $dir = @parts ? join('/', @parts) : '';
Branch: 1 branch
BranchTrueFalseTotal
@parts ? : 6 2 8
888 #
889 # create nav path prefix
890 #
891 8 my $pfxcnt = 1 + ($dir=~tr'/'');
892 8 my $pathpfx = '../' x $pfxcnt;
893  
894 8 my ($constrsum, $constrdet, $methsum, $methdet) =
895 (
896 "<a href='#constructor_summary'>CONSTR</a>",
897 "<a href='#constructor_detail'>CONSTR</a>",
898 "<a href='#method_summary'>METHOD</a>",
899 "<a href='#method_detail'>METHOD</a>"
900 );
901  
902 8 my $doc = "
903 <html>
904 <head>
905 <title>$class</title>
906 </head>
907 <body>
908 <table width='100%' border=0 CELLPADDING='0' CELLSPACING='3'>
909 <TR>
910 <TD VALIGN='top' align=left><FONT SIZE='-2'>
911 SUMMARY:&nbsp;$constrsum&nbsp;|&nbsp;$methsum
912 </FONT></TD>
913 <TD VALIGN='top' align=right><FONT SIZE='-2'>
914 DETAIL:&nbsp;$constrdet&nbsp;|&nbsp;$methdet
915 </FONT></TD>
916 </TR>
917 </table><hr>
918 <h2>Class $class</h2>
919 ";
920 #
921 # process InheritsFrom
922 #
923 8 my $base;
924 8 my @bases = ();
925 8 foreach (keys %{$info->{InheritsFrom}}) {
926 4 $base = $_;
927 4 $base=~s/::/\//g;
928 # $base=~s/^$dir\///; # remove matching headers
929 4 push @bases, "<a href='$pathpfx$base.html'>$_</a>";
930 }
931  
932 8 ▶ $doc .= "
Branch: 1 branch
BranchTrueFalseTotal
if scalar @bases 2 6 8
933 <p>
934 <dl>
935 <dt><b>Inherits from:</b>
936 <dd>" . join("</dd>\n<dd>", @bases) . "</dd>
937 </dt>
938 </dl>
939 "
940 if scalar @bases;
941 #
942 # process SubclassedBy
943 #
944 8 @bases = ();
945 8 foreach (keys %{$info->{SubclassedBy}}) {
946 0 $base = $_;
947 0 $base=~s/::/\//g;
948 # $base=~s/^$dir\///; # remove matching headers
949 0 push @bases, "<a href='$pathpfx$base.html'>$_</a>";
950 }
951  
952 8 ▶ $doc .= "
Branch: 1 branch
BranchTrueFalseTotal
if scalar @bases 0 8 8
953 <p>
954 <dl>
955 <dt><b>Known Subclasses:</b>
956 <dd>" . join("</dd>\n<dd>", @bases) . "</dd>
957 </dt>
958 </dl>
959 "
960 if scalar @bases;
961 #
962 # process package tags
963 #
964 8 $doc .= '
965 <hr>
966 ';
967 $doc .= "<b>Deprecated.</b>" .
968 (($info->{deprecated} ne '1') ? " <i>$info->{deprecated}</i>\n" : "\n") .
969 "<p>\n"
970 8 ▶ if $info->{deprecated};
Branch: 2 branches
BranchTrueFalseTotal
if $info->{"deprecated"} 0 8 8
$info->{'deprecated'} ne '1' ? : 0 0 0
971  
972 $doc .= "
973 $info->{Description}
974 <p>
975 "
976 8 ▶ if $info->{Description};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"Description"} 8 0 8
977  
978 8 $doc .= '
979 <dl>
980 ';
981 $doc .= "
982 <dt><b>Author:</b></dt>
983 <dd>$info->{author}</dd>
984 "
985 8 ▶ if $info->{author};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"author"} 2 6 8
986  
987 $doc .= "
988 <dt><b>Version:</b></dt>
989 <dd>$info->{Version}</dd>
990 "
991 8 ▶ if $info->{Version};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"Version"} 0 8 8
992  
993 $doc .= "
994 <dt><b>Since:</b></dt>
995 <dd>$info->{since}</dd>
996 "
997 8 ▶ if $info->{since};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"since"} 2 6 8
998  
999 $doc .= join('', "
1000 <dt><b>See Also:</b></dt>
1001 <dd>", _makeSeeLinks($info->{see}, $pathpfx), "</dd>
1002 ")
1003 8 ▶ if $info->{see};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"see"} 2 6 8
1004  
1005 $doc .= "
1006 <p>
1007 <i>Class instances are $info->{instance} references.</i>
1008 <p>"
1009 8 ▶ if $info->{instance};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"instance"} 0 8 8
1010  
1011 $doc .= "
1012 <p>
1013 <i>Unless otherwise noted, <code>$info->{self}</code> is the object instance variable.</i>
1014 <p>"
1015 8 ▶ if $info->{self};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"self"} 0 8 8
1016  
1017 #
1018 # process imports
1019 #
1020 $doc .= join('', "
1021 <a name='imports'></a>
1022 <table border=1 cellpadding=3 cellspacing=0 width='100%'>
1023 <tr bgcolor='$aqua'><th colspan=2 align=left><font size='+2'>Imported Symbols</font></th></tr>
1024 ", _makeExportDesc($info->{imports}, '_i_'), "
1025 </table>
1026 <p>
1027 ")
1028 8 ▶ if $info->{imports};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"imports"} 0 8 8
1029 #
1030 # process exports
1031 #
1032 $doc .= join('', "
1033 <a name='exports'></a>
1034 <table border=1 cellpadding=3 cellspacing=0 width='100%'>
1035 <tr bgcolor='$aqua'><th colspan=2 align=left><font size='+2'>Exported Symbols</font></th></tr>
1036 ", _makeExportDesc($info->{exports}, '_e_'), "
1037 </table>
1038 <p>
1039 ")
1040 8 ▶ if $info->{exports};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"exports"} 2 6 8
1041 #
1042 # process members
1043 #
1044 $doc .= join('', "
1045 <a name='members'></a>
1046 <table border=1 cellpadding=3 cellspacing=0 width='100%'>
1047 <tr bgcolor='$aqua'><th colspan=2 align=left><font size='+2'>Public Instance Members</font></th></tr>
1048 ", _makeExportDesc($info->{member}, '_m_'), "
1049 </table>
1050 <p>
1051 ")
1052 8 ▶ if $info->{member};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"member"} 8 0 8
1053 #
1054 # collect method map info before processing
1055 #
1056 8 my %methodmap = ();
1057 8 ▶ while (my($sub, $methodinfo) = each %{$info->{Methods}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$info{"Methods"};}) 198 8 206
1058 $methodmap{$sub} = [ $methodinfo->{File}, $methodinfo->{Line} ]
1059 unless (!$use_private) &&
1060 (substr($sub, 0, 1) eq '_') &&
1061 198 ▶ (!$methodinfo->{constructor});
Branch: 1 branch
BranchTrueFalseTotal
unless not $use_private and substr($sub, 0, 1) eq "_" and not $methodinfo->{"constructor"} 198 0 198
Condition33%2/6
not $use_private and substr($sub, 0, 1) eq "_" and not $methodinfo->{"constructor"}
!ll&&!rl&&r
19800
not $use_private and substr($sub, 0, 1) eq "_"
!ll&&!rl&&r
01980
MC/DC0%0/3
not $use_private and substr($sub, 0, 1) eq "_" and not $methodinfo->{"constructor"}
not $use_private substr($sub, 0, 1) eq "_" not $methodinfo->{"constructor"}
Truth table25%1/4
not(A) and B and not(C)
A= not $use_privateB= substr($sub, 0, 1) eq "_"C= not $methodinfo->{"constructor"}
ABCresult
0XX0
10X0
1100
1111
1062 }
1063 #
1064 # process constructors. Scan for methods with descriptions with '@constructor'
1065 #
1066 8 $doc .= "
1067 <a name='summary'></a>
1068 ";
1069
1070 8 my %constructors = ();
1071 8 my $constructor;
1072 my $anchored;
1073 8 foreach (sort keys %{$info->{Methods}}) {
1074 next
1075 198 ▶ unless exists $info->{Methods}{$_}{constructor};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $info->{"Methods"}{$_}{"constructor"} 198 0 198
1076 0 ▶ $anchored = 1,
Branch: 1 branch
BranchTrueFalseTotal
unless $anchored 0 0 0
1077 $doc .= "
1078 <a name='constructor_summary'></a>
1079 ",
1080 unless $anchored;
1081  
1082 0 ▶ $doc .= "
Branch: 1 branch
BranchTrueFalseTotal
unless $constructor 0 0 0
1083 <table border=1 cellpadding=3 cellspacing=0 width='100%'>
1084 <tr bgcolor='$aqua'><th align=left><font size='+2'>Constructor Summary</font></th></tr>
1085 "
1086 unless $constructor;
1087  
1088 0 $constructor = $constructors{$_} = delete $info->{Methods}{$_};
1089  
1090 $doc .= join('', "
1091 <tr><td align=left valign=top>
1092 0 <code><a href='#_f_$_'>$_</a>", _makeParamList($constructor->{param}), "</code>
1093 ");
1094 0 ▶ if ($constructor->{deprecated}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($constructor->{'deprecated'}) { } 0 0 0
elsif ($constructor->{'Description'}) { } 0 0 0
1095 $doc .= '
1096 <BR>
1097 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;' .
1098 0 ▶ (($constructor->{deprecated} ne '1') ? "<i>$constructor->{deprecated}</i>" : '');
Branch: 1 branch
BranchTrueFalseTotal
$constructor->{'deprecated'} ne '1' ? : 0 0 0
1099 }
1100 elsif ($constructor->{Description}) {
1101 0 my $descr = $constructor->{Description};
1102 0 ▶ my $brief = _briefDescription(($descr=~/^\s*Constructor\.\s*(.*)$/s) ? $1 : $descr);
Branch: 1 branch
BranchTrueFalseTotal
$descr =~ /^\s*Constructor\.\s*(.*)$/s ? : 0 0 0
1103 0 $doc .= "
1104 <BR>
1105 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$brief
1106 ";
1107 }
1108 0 $doc .= "</td></tr>\n";
1109 } # end for constructors
1110 8 $info->{constructors} = \%constructors;
1111 8 ▶ if ($constructor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($constructor) { } 0 8 8
1112 0 $doc .= "</table><p>\n"
1113 }
1114 else {
1115 8 $doc=~s!<a href='#constructor_summary'>CONSTR</a>!CONSTR!;
1116 8 $doc=~s!<a href='#constructor_detail'>CONSTR</a>!CONSTR!;
1117 }
1118 #
1119 # process methods
1120 #
1121 8 my @methods = sort keys %methodmap;
1122 8 my $methcount = @methods;
1123 8 ▶ if ($methcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($methcount) { } 8 0 8
1124 8 $doc .= "
1125 <a name='method_summary'></a>
1126 <table border=1 cellpadding=3 cellspacing=0 width='100%'>
1127 <tr bgcolor='$aqua'><th align=left><font size='+2'>Method Summary</font></th></tr>
1128 ";
1129 8 foreach (@methods) {
1130 198 my $method = $info->{Methods}{$_};
1131 $doc .= join('', "
1132 <tr><td align=left valign=top>
1133 198 <code><a href='#_f_$_'>$_</a>", _makeParamList($method->{param}), "</code>
1134 ");
1135 198 ▶ if ($method->{deprecated}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($method->{'deprecated'}) { } 2 196 198
elsif ($method->{'Description'}) { } 192 4 196
1136 $doc .= '
1137 <BR>
1138 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;' .
1139 2 ▶ (($method->{deprecated} ne '1') ? "<i>$method->{deprecated}</i>" : '');
Branch: 1 branch
BranchTrueFalseTotal
$method->{'deprecated'} ne '1' ? : 2 0 2
1140 }
1141 elsif ($method->{Description}) {
1142 192 ▶ my $descr = ($method->{static} ? "<i>(class method)</i> " : '') . $method->{Description};
Branch: 1 branch
BranchTrueFalseTotal
$method->{'static'} ? : 14 178 192
1143 192 my $brief = _briefDescription($descr);
1144 192 $doc .= "
1145 <BR>
1146 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$brief
1147 ";
1148 }
1149 198 $doc .= "</td></tr>\n";
1150 }
1151 8 $doc .= "</table>
1152 <p>
1153 ";
1154 }
1155 else {
1156 0 $doc=~s!<a href='#method_summary'>METHOD</a>!METHOD!;
1157 0 $doc=~s!<a href='#method_detail'>METHOD</a>!METHOD!;
1158 }
1159  
1160 8 ▶ if (keys %constructors) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %constructors) 0 8 8
1161 0 $doc .= "
1162 <a name='constructor_detail'></a>
1163 <table border=1 cellpadding=3 cellspacing=0 width='100%'>
1164 <tr bgcolor='$aqua'>
1165 <th align=left><font size='+2'>Constructor Details</font></th>
1166 </tr>
1167 </table>
1168 ";
1169 0 foreach (sort keys %constructors) {
1170 0 my $method = $constructors{$_};
1171 0 my $returns = $method->{return};
1172 0 ▶ my $descr = $method->{Description} || '&nbsp;';
Condition0%0/2
$method->{'Description'} || '&nbsp;'
l!l
00
MC/DC0%0/1
$method->{'Description'} || '&nbsp;'
$method->{'Description'}
Truth table0%0/2
A
A= $method->{'Description'}
Aresult
11
00
1173 0 $descr=~s/^\s*Constructor\.\s*//;
1174 $doc .= join('', "
1175 <a name='_f_$_'></a>
1176 <h3>$_</h3>
1177 <pre>
1178 0 $_", _makeParamList($method->{param}), "
1179 </pre><p>
1180 <dl>
1181 <dd>$descr
1182 <p>
1183 <dd><dl>
1184 ");
1185 $doc .= join('', "<dt><b>Parameters:</b>\n", _makeParamDesc($method->{param}))
1186 0 ▶ if $method->{param};
Branch: 1 branch
BranchTrueFalseTotal
if $method->{"param"} 0 0 0
1187  
1188 0 ▶ $doc .= "<dt><b>Returns:</b><dd>$returns</dd>\n"
Branch: 1 branch
BranchTrueFalseTotal
if $returns 0 0 0
1189 if $returns;
1190  
1191 $doc .= "<dt><b>Since:</b></dt><dd>$method->{since}</dd>\n"
1192 0 ▶ if $method->{since};
Branch: 1 branch
BranchTrueFalseTotal
if $method->{"since"} 0 0 0
1193  
1194 $doc .= join('', "<dt><b>See Also:</b></dt><dd>", _makeSeeLinks($method->{see}, $pathpfx), "</dd>\n")
1195 0 ▶ if $method->{see};
Branch: 1 branch
BranchTrueFalseTotal
if $method->{"see"} 0 0 0
1196  
1197 0 $doc .= "</dl></dd></dl><hr>\n";
1198 }
1199 0 $doc .= "\n<p>\n";
1200 } # end if constructor
1201  
1202 8 ▶ if ($methcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($methcount) 8 0 8
1203 8 $doc .= "
1204 <a name='method_detail'></a>
1205 <table border=1 cellpadding=3 cellspacing=0 width='100%'>
1206 <tr bgcolor='$aqua'>
1207 <th align=left><font size='+2'>Method Details</font></th>
1208 </tr></table>
1209 ";
1210 8 foreach (@methods) {
1211 198 my $method = $info->{Methods}{$_};
1212 198 my $returns = $method->{return};
1213 198 my $returnlist = $method->{returnlist};
1214 my $descr = ($method->{static} ? "<i>(class method)</i> " : '') .
1215 198 ▶ ($method->{Description} || '&nbsp;');
Branch: 1 branch
BranchTrueFalseTotal
$method->{'static'} ? : 14 184 198
Condition100%2/2
$method->{'Description'} || '&nbsp;'
l!l
1944
MC/DC100%1/1
$method->{'Description'} || '&nbsp;'
$method->{'Description'}
Truth table100%2/2
A
A= $method->{'Description'}
Aresult
11
00
1216 $doc .= join('', "
1217 <a name='_f_$_'></a>
1218 <h3>$_</h3>
1219 <pre>
1220 198 $_", _makeParamList($method->{param}), "
1221 </pre><p>
1222 <dl>
1223 <dd>$descr
1224 <p>
1225 <dd><dl>
1226 ");
1227  
1228 198 ▶ if ($method->{simplex}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($method->{'simplex'}) { } 0 198 198
elsif ($method->{'urgent'}) { } 0 198 198
1229 $doc .= ($method->{urgent} ?
1230 0 ▶ "<dt><b>Simplex, Urgent</b></dt>\n" :
Branch: 1 branch
BranchTrueFalseTotal
$method->{'urgent'} ? : 0 0 0
1231 "<dt><b>Simplex</b></dt>\n");
1232 }
1233 elsif ($method->{urgent}) {
1234 0 $doc .= "<dt><b>Urgent</b></dt>\n";
1235 }
1236  
1237 $doc .= join('', "<dt><b>Parameters:</b>\n", _makeParamDesc($method->{param}))
1238 198 ▶ if $method->{param};
Branch: 1 branch
BranchTrueFalseTotal
if $method->{"param"} 144 54 198
1239  
1240 198 ▶ if ($returns) {
Branch: 1 branch
BranchTrueFalseTotal
if ($returns) 152 46 198
1241 152 ▶ $doc .= ($returnlist ?
Branch: 1 branch
BranchTrueFalseTotal
$returnlist ? : 12 140 152
1242 "<dt><b>In scalar context, returns:</b><dd>$returns</dd>\n" :
1243 "<dt><b>Returns:</b><dd>$returns</dd>\n");
1244 }
1245  
1246 198 ▶ $doc .= ($returns ?
Branch: 2 branches
BranchTrueFalseTotal
if $returnlist 26 172 198
$returns ? : 12 14 26
1247 "<dt><b>In list context, returns:</b><dd>($returnlist)</dd>\n" :
1248 "<dt><b>Returns:</b><dd>($returnlist)</dd>\n")
1249 if $returnlist;
1250  
1251 $doc .= "<dt><b>Since:</b></dt><dd>$method->{since}</dd>\n"
1252 198 ▶ if $method->{since};
Branch: 1 branch
BranchTrueFalseTotal
if $method->{"since"} 42 156 198
1253  
1254 $doc .= join('', "<dt><b>See Also:</b></dt><dd>", _makeSeeLinks($method->{see}, $pathpfx), "</dd>\n")
1255 198 ▶ if $method->{see};
Branch: 1 branch
BranchTrueFalseTotal
if $method->{"see"} 82 116 198
1256  
1257 198 $doc .= "</dl></dd></dl><hr>\n";
1258 } # end foreach method
1259 } # end if methods
1260 #
1261 # finish up
1262 #
1263 8 my $tstamp = scalar localtime();
1264  
1265 8 $doc .= "
1266 <small>
1267 <center>
1268 <i>Generated by POD::ClassDoc $VERSION on $tstamp</i>
1269 </center>
1270 </small>
1271 </body>
1272 </html>
1273 ";
1274 8 return [ $doc, $info->{File}, $info->{Line}, \%methodmap ];
1275 }
1276 #
1277 # generate a path from a class, along with
1278 # an updir path from the class
1279 #
1280 202 ▶sub _pathFromClass {
Subroutine _pathFromClass: called CC=1 SCAR=0.0
1281 202 my $class = shift;
1282 202 my @parts = split /\:\:/, $class;
1283 202 pop @parts;
1284 202 return ( '../' x (scalar @parts), join('/', @parts));
1285 }
1286  
1287 202 ▶sub _parseTags {
Subroutine _parseTags: called CC=25 SCAR=32.2
1288 202 my ($self, $class, $info, $validtags) = @_;
1289 #
1290 # expand all <cpan>, <member>, <method>, and <package> tags
1291 # NOTE: need a nesting level to construct updir prefixes
1292 #
1293 202 my ($updir, $path) = _pathFromClass($class);
1294 202 my @parts = ();
1295 202 my $method;
1296 202 ▶ $updir ||= '';
Condition100%2/2
$updir ||= ""
l!l
16834
MC/DC100%1/1
$updir ||= ""
$updir
Truth table100%2/2
A
A= $updir
Aresult
11
00
1297 202 $info->{Description}=~s!<cpan>([^<]+)</cpan>!<a href='http://search.cpan.org/perldoc\?$1'>$1</a>!g;
1298 202 $info->{Description}=~s!<(export|import|method|member)>(\w+)</(?:export|import|method|member)>!<a href='#$secttags{$1}$2'>$2</a>!g;
1299 202 $info->{Description}=~s!<(export|import|method|member|package)>([\w\:]+)</(?:export|import|method|member|package)>!
1300 43 ▶ { @parts = split('\:\:', $2); $method = ($1 eq 'package') ? '' : pop @parts;
Branch: 1 branch
BranchTrueFalseTotal
$1 eq 'package' ? : 1 42 43
1301 43 ▶ "<a href='$updir" . join('/', @parts) . '.html' . (($1 eq 'package') ? '' : "#$secttags{$1}") . "$method'>$2</a>" }!egx;
Branch: 1 branch
BranchTrueFalseTotal
$1 eq 'package' ? : 1 42 43
1302 #
1303 # process classdoc sections
1304 #
1305 202 my $desc = '';
1306 202 my @lines = split /\n/, $info->{Description};
1307 202 my $tag = 'Description';
1308 202 my $param;
1309 202 my ($ttag, $tdesc);
1310 202 my $sep = "\n";
1311 202 foreach (@lines) {
1312 5096 s/^#\*?\s*//;
1313  
1314 $desc .= "$_$sep",
1315 next
1316 5096 ▶ unless /^\@(\w+)(\s+(.*))?$/ && $validtags->{$1};
Branch: 1 branch
BranchTrueFalseTotal
unless /^\@(\w+)(\s+(.*))?$/ and $validtags->{$1} 4641 455 5096
Condition100%3/3
/^\@(\w+)(\s+(.*))?$/ and $validtags->{$1}
!ll&&!rl&&r
46401455
MC/DC100%2/2
/^\@(\w+)(\s+(.*))?$/ and $validtags->{$1}
/^\@(\w+)(\s+(.*))?$/ $validtags->{$1}
Truth table100%3/3
A and B
A= /^\@(\w+)(\s+(.*))?$/B= $validtags->{$1}
ABresult
0X0
100
111
1317  
1318 455 ($ttag, $tdesc) = ($1, $3);
1319 455 ▶ if (($tag eq 'param') || ($tag eq 'optional') || ($tag eq 'exports') || ($tag eq 'imports') || ($tag eq 'member')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tag eq 'param' or $tag eq 'optional' or $tag eq 'exports' or $tag eq 'imports' or $tag eq 'member') { } 272 183 455
elsif ($tag eq 'see') { } 28 155 183
Condition91%11/12
$tag eq "param" or $tag eq "optional" or $tag eq "exports" or $tag eq "imports" or $tag eq "member"
l!l&&r!l&&!r
17399183
$tag eq "param" or $tag eq "optional" or $tag eq "exports" or $tag eq "imports"
l!l&&r!l&&!r
1730282
$tag eq "param" or $tag eq "optional" or $tag eq "exports"
l!l&&r!l&&!r
1712282
$tag eq "param" or $tag eq "optional"
l!l&&r!l&&!r
10665284
MC/DC80%4/5
$tag eq "param" or $tag eq "optional" or $tag eq "exports" or $tag eq "imports" or $tag eq "member"
$tag eq "param" $tag eq "optional" $tag eq "exports" $tag eq "imports" $tag eq "member"
Truth table83%5/6
A or B or C or D or E
A= $tag eq "param"B= $tag eq "optional"C= $tag eq "exports"D= $tag eq "imports"E= $tag eq "member"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
1320 272 ($param, $desc) = ($desc=~/^\s*((?:[\\]?[\$\%\@\*\&])?[\w\:]+)\s*(.*)$/s);
1321 272 ▶ $tag = 'param',
Branch: 1 branch
BranchTrueFalseTotal
if $tag eq "optional" 65 207 272
1322 $desc = '<i>(optional)</i>' . $desc
1323 if ($tag eq 'optional');
1324 272 push @{$info->{$tag}}, $param, $desc;
1325 }
1326 elsif ($tag eq 'see') {
1327 28 push @{$info->{$tag}}, $desc;
1328 }
1329 else {
1330 155 ▶ chop $desc, chop $desc if ($sep ne "\n");
Branch: 1 branch
BranchTrueFalseTotal
if $sep ne "\n" 1 154 155
1331 155 $info->{$tag} = $desc;
1332 }
1333 455 $tag = $ttag;
1334 455 ▶ $desc = $tdesc || 1;
Condition100%2/2
$tdesc || 1
l!l
4478
MC/DC100%1/1
$tdesc || 1
$tdesc
Truth table100%2/2
A
A= $tdesc
Aresult
11
00
1335 455 ▶ $sep = ($validtags->{$tag} == 1) ? "\n" : ",\n";
Branch: 1 branch
BranchTrueFalseTotal
$validtags->{$tag} == 1 ? : 397 58 455
1336 455 $desc .= $sep;
1337 }
1338 #
1339 # don't forget the last one!
1340 #
1341 202 ▶ if (($tag eq 'param') || ($tag eq 'optional') || ($tag eq 'exports') || ($tag eq 'imports') || ($tag eq 'member')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tag eq 'param' or $tag eq 'optional' or $tag eq 'exports' or $tag eq 'imports' or $tag eq 'member') { } 6 196 202
elsif ($tag eq 'see') { } 29 167 196
Condition83%10/12
$tag eq "param" or $tag eq "optional" or $tag eq "exports" or $tag eq "imports" or $tag eq "member"
l!l&&r!l&&!r
24196
$tag eq "param" or $tag eq "optional" or $tag eq "exports" or $tag eq "imports"
l!l&&r!l&&!r
20200
$tag eq "param" or $tag eq "optional" or $tag eq "exports"
l!l&&r!l&&!r
20200
$tag eq "param" or $tag eq "optional"
l!l&&r!l&&!r
11200
MC/DC60%3/5
$tag eq "param" or $tag eq "optional" or $tag eq "exports" or $tag eq "imports" or $tag eq "member"
$tag eq "param" $tag eq "optional" $tag eq "exports" $tag eq "imports" $tag eq "member"
Truth table66%4/6
A or B or C or D or E
A= $tag eq "param"B= $tag eq "optional"C= $tag eq "exports"D= $tag eq "imports"E= $tag eq "member"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
1342 6 ($param, $desc) = ($desc=~/^\s*((?:[\\]?[\$\%\@\*\&])?[\w\:]+)\s*(.*)$/s);
1343 6 ▶ $tag = 'param',
Branch: 1 branch
BranchTrueFalseTotal
if $tag eq "optional" 1 5 6
1344 $desc = '<i>(optional)</i>' . $desc
1345 if ($tag eq 'optional');
1346 6 push @{$info->{$tag}}, $param, $desc;
1347 }
1348 elsif ($tag eq 'see') {
1349 29 push @{$info->{$tag}}, $desc;
1350 }
1351 else {
1352 167 ▶ chop $desc, chop $desc if ($sep ne "\n");
Branch: 1 branch
BranchTrueFalseTotal
if $sep ne "\n" 0 167 167
1353 167 $info->{$tag} = $desc;
1354 }
1355 }
1356  
1357 396 ▶sub _makeParamList {
Subroutine _makeParamList: called CC=4 SCAR=13.9
1358 396 my $params = shift;
1359 396 my $p = '(';
1360 396 my $t;
1361 396 my $i = 0;
1362  
1363 396 ▶ $t = $params->[$i++],
Branch: 2 branches
BranchTrueFalseTotal
$i < $params->$#* and do { $t = $$params[$i++], ++$i, $p .= ($t =~ /^[\\]?[\$\%\@\*\&]/ ? "$t, " : "$t =&gt; <i>value</i>, ") } 692 396 1088
$t =~ /^[\\]?[\$\%\@\*\&]/ ? : 688 4 692
1364 $i++,
1365 $p .= ($t=~/^[\\]?[\$\%\@\*\&]/) ? "$t, " : "$t =&gt; <i>value</i>, "
1366 while ($i < $#$params);
1367  
1368 396 ▶ chop $p,
Branch: 1 branch
BranchTrueFalseTotal
if length $p > 1 288 108 396
1369 chop $p
1370 if (length($p) > 1);
1371  
1372 396 return "$p)";
1373 }
1374  
1375 144 ▶sub _makeParamDesc {
Subroutine _makeParamDesc: called CC=3 SCAR=11.0
1376 144 my $params = shift;
1377 144 my $p = '<dd><table border=0>';
1378 144 my ($t, $d, $sep);
1379 144 my $i = 0;
1380  
1381 144 ▶ $t = $params->[$i++],
Branch: 2 branches
BranchTrueFalseTotal
$i < $params->$#* and do { $t = $$params[$i++], $d = $$params[$i++], $sep = $t =~ /^[\\]?[\$\%\@\*\&]/ ? " - " : " =&gt; ", $p .= "<tr><td align=left valign=top><code>$t</code></td><td valign=top align=center>$sep</td><td align=left>$d</td></tr>\n" } 346 144 490
$t =~ /^[\\]?[\$\%\@\*\&]/ ? : 344 2 346
1382 $d = $params->[$i++],
1383 $sep = ($t=~/^[\\]?[\$\%\@\*\&]/) ? ' - ' : ' =&gt; ',
1384 $p .= "<tr><td align=left valign=top><code>$t</code></td><td valign=top align=center>$sep</td><td align=left>$d</td></tr>\n"
1385 while ($i < $#$params);
1386  
1387 144 return $p . "</table></dd>\n";
1388 }
1389  
1390 10 ▶sub _makeExportDesc {
Subroutine _makeExportDesc: called CC=1 SCAR=0.0
1391 10 my ($params, $pfx) = @_;
1392 10 my $p = '';
1393  
1394 10 my %t = @$params;
1395 10 return join("\n",
1396 map "<tr><td align=right valign=top><a name='$pfx$_'></a><code>$_</code></td><td align=left valign=top>$t{$_}</td></tr>", sort keys %t) . "\n";
1397 }
1398  
1399 0 ▶sub _getSubDirs {
Subroutine _getSubDirs: not called CC=6 SCAR=37.4
1400 0 my ($self, $path) = @_;
1401 0 ▶ $@ = "$path directory not found",
Branch: 1 branch
BranchTrueFalseTotal
unless opendir PATH, $path 0 0 0
1402 return undef
1403 unless opendir(PATH, $path);
1404 0 push @{$self->{_dirs}}, $path;
1405 #
1406 # glob the directory for all subdirs
1407 #
1408 0 my @files = readdir PATH;
1409 0 closedir PATH;
1410  
1411 0 foreach (@files) {
1412 0 ▶ push(@{$self->{_dirs}}, "$path/$_")
Branch: 1 branch
BranchTrueFalseTotal
if $_ ne "." and $_ ne ".." and -d "$path/$_" 0 0 0
Condition0%0/6
$_ ne "." and $_ ne ".." and -d "$path/$_"
!ll&&!rl&&r
000
$_ ne "." and $_ ne ".."
!ll&&!rl&&r
000
MC/DC0%0/3
$_ ne "." and $_ ne ".." and -d "$path/$_"
$_ ne "." $_ ne ".." -d "$path/$_"
Truth table0%0/4
A and B and C
A= $_ ne "."B= $_ ne ".."C= -d "$path/$_"
ABCresult
0XX0
10X0
1100
1111
1413 if ($_ ne '.') && ($_ ne '..') && (-d "$path/$_");
1414 }
1415 0 return $self;
1416 }
1417  
1418 84 ▶sub _makeSeeLinks {
Subroutine _makeSeeLinks: called CC=1 SCAR=0.0
1419 84 $_[0][-1]=~s/,\n$/\n/;
1420 84 return join("<br>\n", @{$_[0]}) . "\n";
1421 }
1422  
1423 192 ▶sub _briefDescription {
Subroutine _briefDescription: called CC=5 SCAR=16.6
1424 192 my $descr = shift;
1425 192 ▶ while ($descr=~/\G.*?((?:<a [^>]*>[^<]*<\/a>)|\.|\?|\!)/igcs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($descr =~ m[\G.*?((?:<a [^>]*>[^<]*</a>)|\.|\?|\!)]cgis) 198 0 198
1426 198 ▶ return substr($descr, 0, $+[1]) if ($1 eq '.') || ($1 eq '?') || ($1 eq '!');
Branch: 1 branch
BranchTrueFalseTotal
if $1 eq "." or $1 eq "?" or $1 eq "!" 192 6 198
Condition83%5/6
$1 eq "." or $1 eq "?" or $1 eq "!"
l!l&&r!l&&!r
19206
$1 eq "." or $1 eq "?"
l!l&&r!l&&!r
182106
MC/DC66%2/3
$1 eq "." or $1 eq "?" or $1 eq "!"
$1 eq "." $1 eq "?" $1 eq "!"
Truth table75%3/4
A or B or C
A= $1 eq "."B= $1 eq "?"C= $1 eq "!"
ABCresult
1XX1
01X1
0011
0000
1427 }
1428 0 return $descr;
1429 }
1430  
1431 3 1;
« lib/Pod/Classdoc/Project.pm ↑ Summary lib/Pod/mkprojdocs.pl »