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
|
#!/usr/bin/perl -W
use strict;
-d "html" and system("rm -rf html");
mkdir "html", 0777 or die $!;
mkdir "html/Search", 0777 or die $!;
my %pages = ();
pod2html('Xapian.pm', 'html/Search/Xapian.html');
mkdir "html/Search/Xapian", 0777 or die $!;
for my $f (<Xapian/*.pm>) {
my $o = $f;
$o =~ s/\.pm$/.html/;
pod2html($f, "html/Search/$o");
}
for (sort keys %pages) {
my $v = $pages{$_};
if ($v eq 'Y') {
print "$_ has a POD but is never linked to\n";
} elsif ($v =~ /^N=/) {
print "$_ has no POD but is linked to\n";
} elsif ($v eq 'N') {
# print "$_ has no POD (but no links)\n";
}
}
sub pod2html {
my ($in, $out) = @_;
my $tmp = 'pod2html.tmp';
my $root = '.';
$root = 'Xapian' if $out =~ m!/Xapian\.html$!;
my $is_pod;
open POD, $in or die $!;
while (<POD>) {
if (/^=/) {
$is_pod = 1;
last;
}
}
close POD;
my $class = $in;
$class =~ s!\.pm$!!;
$class =~ s!/!::!g;
$class = "Search::$class";
open HTML, ">$out" or die $!;
if (!$is_pod) {
$pages{$class} = 'N' . ($pages{$class} || '');
print HTML <<EOT;
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>$class</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" />
</head>
<body style="background-color: white">
<p>No Perl-specific documentation currently exists for class
<code>$class</code> - please refer to the
<a href="https://xapian.org/docs/apidoc/html/annotated.html">C++
API documentation</a> for now.
</body>
</html>
EOT
} else {
$pages{$class} = 'Y' . ($pages{$class} || '');
system('pod2html', '--podroot=blib/lib', '--podpath=.', '--htmlroot', $root, '--infile', $in, '--outfile', $tmp) == 0
or die $!;
if ($?) { die $?; }
open TMP, $tmp or die $!;
while (<TMP>) {
s!>the (.*?) manpage<!>$1<!g;
s!\bhref="mailto:.*?@.*?"!!g;
# Clean up redundant . and .. in links.
s!(href=")\./\.\./\.\./Search/Xapian/!$1!g;
s!(href=")\./\.\./\.\./Search/!$1../!g;
s!(href=")Xapian/\.\./\.\./Search/!$1!g;
while (m!\bhref="(?:../)*(Search/Xapian[^.]*)!g) {
my $class = $1;
$class =~ s!/!::!g;
$pages{$class} = ($pages{$class} || '') . '=';
}
print HTML $_;
}
close TMP;
unlink $tmp;
}
close HTML or die $!;
}
|