diff options
author | Marc Green <marcgreen@cpan.org> | 2011-06-07 17:18:06 -0400 |
---|---|---|
committer | Marc Green <marcgreen@cpan.org> | 2011-10-31 13:26:39 -0400 |
commit | 9949917516c8bca1036187e3e878ed8869558a65 (patch) | |
tree | 27c547d8ebf38994c880b810346ae95da7ecdf03 /ext | |
parent | a5e8ccd3a47aacb3c106e9dafe89f4e0df8163c7 (diff) | |
download | perl-9949917516c8bca1036187e3e878ed8869558a65.tar.gz |
Finish skeleton version of Pod::Html
It can now output html!
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Pod-Html/lib/Pod/Html.pm | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/ext/Pod-Html/lib/Pod/Html.pm b/ext/Pod-Html/lib/Pod/Html.pm index 9c4774e2e8..61bc40386f 100644 --- a/ext/Pod-Html/lib/Pod/Html.pm +++ b/ext/Pod-Html/lib/Pod/Html.pm @@ -11,6 +11,7 @@ $VERSION = 1.11; use Carp; use Config; use Cwd; +use File::Basename; use File::Spec; use File::Spec::Unix; use Getopt::Long; @@ -246,14 +247,12 @@ sub pod2html { local $_; init_globals(); - - # parse the command-line parameters parse_command_line(); # finds all pod modules/pages in podpath, stores in %Pages # --recurse is implemented in _save_page for now (its inefficient right now) # (maybe subclass ::Search to implement instead) - Pod::Simple::Search->new->inc(0)->verbose(1) + Pod::Simple::Search->new->inc(0)->verbose($Verbose) ->callback(\&_save_page)->survey(@Podpath); # finds all =head/=item directives in libpods/infile, stores in %Sections @@ -269,6 +268,7 @@ sub pod2html { $parser->output_string(\my $output); # written to file later # TODO: implement default title generator in ::xhtml $parser->force_title(html_escape($Title)); + $parser->verbose($Verbose); $parser->html_doctype('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'); my $input; @@ -276,7 +276,7 @@ sub pod2html { if ($Podfile and $Podfile ne '-') { $input = $Podfile; } else { - $input = '-'; + $input = '-'; # note: make a test case for this } } else { $Podfile = $ARGV[0]; @@ -287,8 +287,16 @@ sub pod2html { $parser->parse_file($input); # Write output to file -# $Htmlfile = "-" unless $Htmlfile; # stdout - # open > $Htmlfile... + $Htmlfile = "-" unless $Htmlfile; # stdout + my $fhout; + if($Htmlfile and $Htmlfile ne '-') { + open $fhout, ">", $Htmlfile + or die "$0: cannot open $Htmlfile file for output: $!\n"; + } else { + open $fhout, ">-"; + } + print $fhout $output; + close $fhout or die "Failed to close $Htmlfile: $!"; } ############################################################################## @@ -420,4 +428,15 @@ sub anchorify { return $anchor; } +sub _save_page { + my ($modspec, $modname) = @_; + + unless ($Recurse) { +# discard any pages that are below top level dir + } + + my ($file, $dir) = fileparse($modspec, qr/\.[^.]*/); #strip .ext + $Pages{$modname} = $dir . $file; +} + 1; |