File Coverage

blib/lib/Pod/Simple/HTMLLegacy.pm
Criterion Covered Total %
statement 9 35 25.7
branch 0 16 0.0
condition 0 6 0.0
subroutine 3 7 42.8
pod 0 3 0.0
total 12 67 17.9


line stmt bran cond sub pod time code
1             package Pod::Simple::HTMLLegacy;
2 1     1   948 use strict;
  1         3  
  1         29  
3 1     1   5 use warnings;
  1         10  
  1         30  
4              
5 1     1   823 use Getopt::Long;
  1         11498  
  1         10  
6              
7             our $VERSION = "5.01";
8              
9             #--------------------------------------------------------------------------
10             #
11             # This class is meant to thinly emulate bad old Pod::Html
12             #
13             # TODO: some basic docs
14              
15             sub pod2html {
16 0     0 0   my @args = (@_);
17              
18 0           my( $verbose, $infile, $outfile, $title );
19 0           my $index = 1;
20              
21             {
22 0           my($help);
  0            
23              
24             my($netscape); # dummy
25 0           local @ARGV = @args;
26 0 0         GetOptions(
27             "help" => \$help,
28             "verbose!" => \$verbose,
29             "infile=s" => \$infile,
30             "outfile=s" => \$outfile,
31             "title=s" => \$title,
32             "index!" => \$index,
33              
34             "netscape!" => \$netscape,
35             ) or return bad_opts(@args);
36 0 0         bad_opts(@args) if @ARGV; # it should be all switches!
37 0 0         return help_message() if $help;
38             }
39              
40 0 0 0       for($infile, $outfile) { $_ = undef unless defined and length }
  0            
41              
42 0 0         if($verbose) {
43 0           warn sprintf "%s version %s\n", __PACKAGE__, $VERSION;
44 0           warn "OK, processed args [@args] ...\n";
45 0 0         warn sprintf
46             " Verbose: %s\n Index: %s\n Infile: %s\n Outfile: %s\n Title: %s\n",
47             map defined($_) ? $_ : "(nil)",
48             $verbose, $index, $infile, $outfile, $title,
49             ;
50 0           *Pod::Simple::HTML::DEBUG = sub(){1};
51             }
52 0           require Pod::Simple::HTML;
53 0           Pod::Simple::HTML->VERSION(3);
54              
55 0 0 0       die "No such input file as $infile\n"
56             if defined $infile and ! -e $infile;
57              
58              
59 0           my $pod = Pod::Simple::HTML->new;
60 0 0         $pod->force_title($title) if defined $title;
61 0           $pod->index($index);
62 0           return $pod->parse_from_file($infile, $outfile);
63             }
64              
65             #--------------------------------------------------------------------------
66              
67 0     0 0   sub bad_opts { die _help_message(); }
68 0     0 0   sub help_message { print STDOUT _help_message() }
69              
70             #--------------------------------------------------------------------------
71              
72             sub _help_message {
73              
74 0     0     join '',
75              
76             "[", __PACKAGE__, " version ", $VERSION, qq~]
77             Usage: pod2html --help --infile= --outfile=
78             --verbose --index --noindex
79              
80             Options:
81             --help - prints this message.
82             --[no]index - generate an index at the top of the resulting html
83             (default behavior).
84             --infile - filename for the pod to convert (input taken from stdin
85             by default).
86             --outfile - filename for the resulting html file (output sent to
87             stdout by default).
88             --title - title that will appear in resulting html file.
89             --[no]verbose - self-explanatory (off by default).
90              
91             Note that pod2html is DEPRECATED, and this version implements only
92             some of the options known to older versions.
93             For more information, see 'perldoc pod2html'.
94             ~;
95              
96             }
97              
98             1;
99             __END__