script/mpod2html

filter: Statementstmt 50.0% 40 / 80 Branchbran 27.2% 12 / 44 Conditioncond 12.5% 1 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 41.9% 60 / 143 CC 1 SCAR 0.0
CC
1
Cov
40%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Marek/Pod/HTML.pm ↑ Summary
1 #!/usr/local/bin/perl
2 1 ▶ eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
Branch: 1 branch
BranchTrueFalseTotal
if $running_under_some_shell 0 1 1
3 if $running_under_some_shell;
4 #!perl -w
5  
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use vars qw($VERSION $TEST_MODE);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 $VERSION = 0.2;
9  
10 3 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use Pod::Find qw(pod_find simplify_name);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my %opt = ( banner => 1 );
15  
16 # compatibility hack for previous version(s) of pod2html
17 1 my %oldopt;
18  
19 die unless(GetOptions(\%opt, qw(
20 banner!
21 converter=s
22 suffix=s
23 filesuffix=s
24 dir=s
25 libpods=s
26 navigation!
27 localtoc!
28 toc!
29 idx!
30 tocname=s
31 idxname=s
32 toctitle=s
33 idxtitle=s
34 idxopt=s
35 ps!
36 psdir=s
37 psfont=s
38 papersize=s
39 inc!
40 script!
41 stylesheet=s
42 warnings!
43 verbose!
44 help|h
45 version|V),
46 'flush' => \$oldopt{flush},
47 'htmlroot=s' => \$oldopt{htmlroot}, # can be ignored
48 'index!' => \$oldopt{'index'},
49 'infile=s' => \$oldopt{infile},
50 'netscape!' => \$oldopt{netscape}, # ignore
51 'outfile=s' => \$oldopt{outfile},
52 'podpath=s' => \$oldopt{podpath}, # can be ignored
53 'podroot=s' => \$oldopt{podroot},
54 'recurse!' => \$oldopt{recurse}, # ignored now
55 'title=s' => \$oldopt{title}
56 1 ▶));
Branch: 1 branch
BranchTrueFalseTotal
unless &GetOptions(\%opt, ("banner!", "converter=s", "suffix=s", "filesuffix=s", "dir=s", "libpods=s", "navigation!", "localtoc!", "toc!", "idx!", "tocname=s", "idxname=s", "toctitle=s", "idxtitle=s", "idxopt=s", "ps!", "psdir=s", "psfont=s", "papersize=s", "inc!", "script!", "stylesheet=s", "warnings!", "verbose!", "help|h", "version|V"), "flush", \$oldopt{"flush"}, "htmlroot=s", \$oldopt{"htmlroot"}, "index!", \$oldopt{"index"}, "infile=s", \$oldopt{"infile"}, "netscape!", \$oldopt{"netscape"}, "outfile=s", \$oldopt{"outfile"}, "podpath=s", \$oldopt{"podpath"}, "podroot=s", \$oldopt{"podroot"}, "recurse!", \$oldopt{"recurse"}, "title=s", \$oldopt{"title"}) 0 1 1
57  
58 1 my %addopts = ();
59  
60 1 ▶if($oldopt{infile}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($oldopt{"infile"}) 0 1 1
61 0 @ARGV = ( $oldopt{infile} );
62 }
63  
64 1 ▶if($oldopt{outfile}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($oldopt{"outfile"}) 0 1 1
65 0 $addopts{-outfile} = $oldopt{outfile};
66 }
67  
68 1 ▶if($oldopt{podroot}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($oldopt{"podroot"}) 0 1 1
69 0 push(@ARGV, $oldopt{podroot});
70 }
71  
72 # process libpods
73 1 ▶if($opt{libpods}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"libpods"}) 0 1 1
74 # replace single : with , (old style)
75 0 $opt{libpods} =~ s/(?<!:):(?!:)/,/g;
76 }
77  
78 1 ▶if(defined $oldopt{'index'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oldopt{"index"}) 0 1 1
79 0 $opt{localtoc} = $oldopt{'index'};
80 }
81  
82 1 ▶if(defined $oldopt{title}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oldopt{"title"}) 0 1 1
83 0 $addopts{-title} = $oldopt{title};
84 }
85  
86 1 ▶my $converter = $opt{converter} || 'Marek::Pod::HTML';
Condition50%1/2
$opt{'converter'} || 'Marek::Pod::HTML'
l!l
01
MC/DC0%0/1
$opt{'converter'} || 'Marek::Pod::HTML'
$opt{'converter'}
Truth table50%1/2
A
A= $opt{'converter'}
Aresult
11
00
87 3 ▶eval "use $converter qw(pod2html);";
Subroutine BEGIN: called CC=1 SCAR=0.0
88 1 ▶die "Fatal: Cannot load convertor module '$converter':\n$@\n"
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
89 if($@);
90  
91 1 ▶if($opt{help}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opt{'help'}) { } 0 1 1
elsif ($opt{'version'}) { } 1 0 1
92 3 ▶ use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 0 exec "$Config{scriptdir}/perldoc -F $0";
94 }
95 elsif($opt{version}) {
96 1 print "$0 Version $VERSION\n";
97 }
98 else {
99  
100 0 my %pods = ();
101 0 my @dirs = ();
102  
103 0 foreach(@ARGV) {
104 0 ▶ if(-d) {
Branch: 2 branches
BranchTrueFalseTotal
if (-d $_) { } 0 0 0
elsif (/[*?]/) { } 0 0 0
105 0 push(@dirs,$_);
106 }
107 elsif(/[*?]/) {
108 0 ▶ foreach (glob($_)) {
Subroutine BEGIN: called CC=1 SCAR=0.2
109 0 ▶ if(-d) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $_) { } 0 0 0
110 0 push(@dirs,$_);
111 }
112 else {
113 0 my $name = simplify_name($_);
114 0 $pods{$_} = $name;
115 }
116 }
117 }
118 else {
119 0 my $name = simplify_name($_);
120 0 $pods{$_} = $name;
121 }
122 }
123 0 my %search;
124  
125 0 ▶ if(@dirs || $opt{inc} || $opt{script}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@dirs or $opt{"inc"} or $opt{"script"}) 0 0 0
Condition0%0/6
@dirs or $opt{"inc"} or $opt{"script"}
l!l&&r!l&&!r
000
@dirs or $opt{"inc"}
l!l&&r!l&&!r
000
MC/DC0%0/3
@dirs or $opt{"inc"} or $opt{"script"}
@dirs $opt{"inc"} $opt{"script"}
Truth table0%0/4
A or B or C
A= @dirsB= $opt{"inc"}C= $opt{"script"}
ABCresult
1XX1
01X1
0011
0000
126 0 warn "+++ Searching for POD documents\n";
127 %search = pod_find({
128 -inc => $opt{inc},
129 -script => $opt{script},
130 -verbose => $opt{verbose}
131 0 }, @dirs)
132 }
133  
134 0 map { $pods{$_} = $search{$_} } keys %search;
135  
136 # run as a filter
137 # we have to save it temporarily because we need two passes
138 0 my $tmp;
139 0 ▶ unless(%pods) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%pods) 0 0 0
140 0 my $self = $0;
141 0 $self =~ s:^.*/::;
142 0 $tmp = "/tmp/$self.$$";
143 0 ▶ open(TEMP, ">$tmp") || die "Cannot write temp file: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open TEMP, ">$tmp" or die "Cannot write temp file: $!\n" 0 0 0
144 0 ▶ while(<STDIN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline STDIN)) 0 0 0
145 0 print TEMP;
146 }
147 0 close(TEMP);
148 0 $pods{$tmp} = 'stdin';
149 0 $addopts{-filter} = 1;
150 0 ▶ $opt{navigation} = 0 unless defined $opt{navigation};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt{"navigation"} 0 0 0
151 }
152  
153 0 ▶ warn "+++ Starting conversion\n" if($opt{verbose});
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"verbose"} 0 0 0
154  
155 pod2html( {
156 -banner => $opt{banner},
157 -converter => $converter,
158 -suffix => $opt{suffix},
159 -filesuffix => $opt{filesuffix},
160 -dir => $opt{dir},
161 -libpods => $opt{libpods},
162 -navigation => $opt{navigation},
163 -localtoc => $opt{localtoc},
164 -toc => $opt{toc},
165 -idx => $opt{idx},
166 -tocname => $opt{tocname},
167 -idxname => $opt{idxname},
168 -toctitle => $opt{toctitle},
169 -idxtitle => $opt{idxtitle},
170 -ps => $opt{ps},
171 -psdir => $opt{psdir},
172 -psfont => $opt{psfont},
173 -papersize => $opt{papersize},
174 -warnings => $opt{warnings},
175 -verbose => $opt{verbose},
176 -stylesheet => $opt{stylesheet},
177 -idxopt => $opt{idxopt},
178 0 %addopts
179 }, { %pods });
180  
181 0 ▶ unlink $tmp if($tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $tmp 0 0 0
182 }
183  
184 1 ▶exit 0 unless($TEST_MODE);
Branch: 1 branch
BranchTrueFalseTotal
unless $main::TEST_MODE 0 1 1
185 1 1; # this is for the module test
186  
187 __END__
« lib/Marek/Pod/HTML.pm ↑ Summary