/usr/bin/pods2html is in libpod-tree-perl 1.25-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
use strict;
use warnings;
use File::Find;
use File::Path;
use Getopt::Long;
use HTML::Stream;
use IO::File;
use Pod::Tree::HTML;
use File::Spec;
my %Options = (
bgcolor => '#ffffff',
text => '#000000',
hr => 1,
toc => 1
);
my $ok = GetOptions(
\%Options, "base:s", "css:s", "bgcolor:s", "empty", "index:s",
"module", "text:s", "toc!", "hr:i", "variables:s"
);
$ok or die "Bad command line options\n";
my %Index;
my @Dirs;
my ( $PodDir, $HTMLDir, $Template, @Variables ) = @ARGV;
$HTMLDir or die "pods2html PodDir HTMLDir\n";
$PodDir = canonpath File::Spec $PodDir;
$HTMLDir = rel2abs File::Spec $HTMLDir;
mkpath($HTMLDir);
do $Options{variables} if $Options{variables};
for (@Variables) {
chomp;
my ( $name, $value ) = split /=/, $_, 2;
$name =~ s(^\$)();
${ $Pod::Tree::HTML::{$name} } = $value;
}
umask 0022;
find(
{
wanted => \&Translate,
no_chdir => 1
},
$PodDir
);
Index() if $Options{index};
Cleanup() unless $Options{empty};
sub Translate {
-d and &Translate_Dir;
-f and &Translate_POD;
}
sub MkDir {
my $dir = shift;
-d $dir and return;
mkdir $dir, 0755 or die "Can't mkdir $dir: $!\n";
push @Dirs, $dir;
}
sub Translate_Dir {
my $dir = $File::Find::name;
if ( $HTMLDir eq rel2abs File::Spec $dir) {
$File::Find::prune = 1;
return;
}
if ( $Options{module} and ( m(/t$) or m(/blib$) ) ) {
$File::Find::prune = 1;
return;
}
$dir =~ s/^\Q$PodDir/$HTMLDir/o;
-d $dir or MkDir $dir;
print "$File::Find::name\n";
}
sub Translate_POD {
m( \.(pm|pod)$ )x or return;
my $source = $File::Find::name;
Hidden($source) and return;
print "$source\n";
my $dest = $source;
$dest =~ s/^\Q$PodDir/$HTMLDir/o;
$dest =~ s( \.\w+$ )(.html)x;
my $depth = Depth($source);
my $pod = $source;
$pod =~ s(^$PodDir/)();
$pod =~ s( \.\w+$ )()x;
$Index{$pod} = 1;
my $html = Pod::Tree::HTML->new( $source, $dest, %Options );
$html->set_options( depth => $depth );
$html->translate($Template);
}
sub Hidden {
my $source = shift;
$source =~ m(\.pm$) or return 0;
$source =~ s(\.pm$)(.pod);
-e $source;
}
sub Depth {
my $source = shift;
my $tree = Pod::Tree->new;
$tree->load_file($source);
my $children = $tree->get_root->get_children;
my @pod = grep { is_pod $_ } @$children;
my $node1 = $pod[1];
$node1 or return '';
my $text = $node1->get_deep_text;
my ($name) = split m(\s+-+\s+), $text;
$name =~ s(^\s+)();
my @name = split /::/, $name;
@name - 1;
}
sub Index {
my $index = "$HTMLDir/index.html";
my $fh = IO::File->new(">$index");
defined $fh or die "Can't open $index: $!\n";
my $stream = HTML::Stream->new($fh);
my $title = $Options{index};
my $bgcolor = $Options{bgcolor};
my $text = $Options{text};
$stream->HTML->HEAD;
$stream->TITLE->text($title)->_TITLE;
$stream->_HEAD->BODY( BGCOLOR => $bgcolor, TEXT => $text );
$stream->H1->t($title)->_H1;
Emit_Entries($stream);
$stream->_BODY->_HTML;
}
sub Emit_Entries {
my $stream = shift;
$stream->UL;
for my $entry ( sort keys %Index ) {
$stream->LI->A( HREF => "$entry.html" )->t($entry)->_A->_LI;
}
$stream->_UL;
}
sub Cleanup {
while (@Dirs) {
my $dir = pop @Dirs;
rmdir $dir; # does nothing unless $dir is empty
}
}
__END__
=head1 NAME
pods2html - translate a tree of PODs to HTML
=head1 SYNOPSIS
C<pods2html>
[C<--base> I<url>]
[C<--css> I<url>]
[C<--empty>]
[C<--index> I<title>]
[C<--module>]
[C<-->[C<no>]C<toc>] [C<--hr> I<level>]
[C<--bgcolor> I<#rrggbb>] [C<--text> I<#rrggbb>]
[C<--variables> I<values.pl>]
I<PODdir> I<HTMLdir> [F<template> [I<variable>=I<value> ...]]
=head1 DESCRIPTION
C<pods2html> finds all the F<.pod> and F<.pm> files in the
directory tree rooted at I<PODdir>.
It translates each POD to HTML,
and writes it to a parallel directory tree rooted at I<HTMLdir>
It makes the HTML files world-readable.
If a F<template> file is provided,
then F<template> will be filled in by the C<Text::Template> module and written to F<dest>.
Here is a minimal template, showing all the variables that are set by C<pods2html>.
<html>
<head>
<base href="{$base}">
<link href="{$css}" rel="stylesheet" type="text/css">
<title>{$title}</title>
</head>
<body bgcolor="{$bgcolor}" text="{$text}">
{$toc}
{$body}
</body>
</html>
If the C<--variables> option is provided, then the file I<values.pl> will be executed with a C<do>
call before the template is filled in. I<values.pl> may contain arbitrary Perl code.
The program fragments in the template are evaulted in the C<Pod::Tree::HTML> package.
Any variables that I<values.pl> sets in this package will be available to the template.
Additional scalar variables may be set on the command line with the I<variable>=I<value> syntax.
Variables set on the command line override variables set in I<values.pl>.
=head1 OPTIONS
=over 4
=item C<--base> I<url>
Specifies a base URL for HTML links.
=item C<--css> I<url>
Specifies a Cascanding Style Sheet for the generated HTML pages.
Here are example rules for all the different HTML elements that may appear in a POD.
a:link { background: #ff8080 }
body { background: #f0f0f0 }
code { background: #c0ffc0 }
dd { background: #ffffe0 }
dl { background: #fffff0 }
dt { background: #ffffc0 }
h1 { background: #ffc0c0 }
h2 { background: #ffe0e0 }
hr { background: #ff0000; height: 5px }
i { background: #ffc0c0 }
li { background: #e0e0e0 }
ol { background: #fff0ff }
p { background: #f0f0ff }
pre { background: #f0fff0 }
ul { background: #f0ffff }
=item C<--empty>
Creates HTML files for empty PODs.
If this option is not provided, then no HTML file is created for empty PODs.
=item C<--index> I<title>
Writes an index of all the HTML files to I<HTMLDir>F</index.html>.
I<title> is used as the title of the index page.
=item C<--module>
Ignores files in directories named F<t/> and F<blib/>.
Useful for translating PODs in a module development directory.
=item C<-->[C<no>]C<toc>
Includes or omits the table of contents.
Default is to include the TOC.
=item C<--hr> I<level>
Controls the profusion of horizontal lines in the output, as follows:
level horizontal lines
0 none
1 between TOC and body
2 after each =head1
3 after each =head1 and =head2
Default is level 1.
=item C<--bgcolor> I<#rrggbb>
Set the background color to I<#rrggbb>.
Default is white.
=item C<--text> I<#rrggbb>
Set the text color to I<#rrggbb>.
Default is black.
=back
=head1 REQUIRES
L<C<Pod::Tree::HTML>>,
L<C<HTML::Stream>>
=head1 BUGS
The recursion check doesn't work on Win32.
This means that the program will enter an infinite recursion
if I<HTMLdir> is a subdirectory of I<PODdir>.
=head1 SEE ALSO
L<C<pod2html>>,
L<C<Pod::Tree::HTML>>
=head1 AUTHOR
Steven McDougall, <swmcd@world.std.com>
=head1 COPYRIGHT
Copyright (c) 1999-2010 by Steven McDougall. This program is free software;
you can redistribute it and/or modify it under the same terms as Perl.
|