Fix build with xapian-core < 1.4.10
[xapian.git] / search-xapian / makehtmldocs
blob2ce4fd38197300ae791af0831159a0ec64ddb1dd
1 #!/usr/bin/perl -W
2 use strict;
4 -d "html" and system("rm -rf html");
5 mkdir "html", 0777 or die $!;
6 mkdir "html/Search", 0777 or die $!;
8 my %pages = ();
9 pod2html('Xapian.pm', 'html/Search/Xapian.html');
10 mkdir "html/Search/Xapian", 0777 or die $!;
11 for my $f (<Xapian/*.pm>) {
12 my $o = $f;
13 $o =~ s/\.pm$/.html/;
14 pod2html($f, "html/Search/$o");
17 for (sort keys %pages) {
18 my $v = $pages{$_};
19 if ($v eq 'Y') {
20 print "$_ has a POD but is never linked to\n";
21 } elsif ($v =~ /^N=/) {
22 print "$_ has no POD but is linked to\n";
23 } elsif ($v eq 'N') {
24 # print "$_ has no POD (but no links)\n";
28 sub pod2html {
29 my ($in, $out) = @_;
30 my $tmp = 'pod2html.tmp';
31 my $root = '.';
32 $root = 'Xapian' if $out =~ m!/Xapian\.html$!;
34 my $is_pod;
35 open POD, $in or die $!;
36 while (<POD>) {
37 if (/^=/) {
38 $is_pod = 1;
39 last;
42 close POD;
44 my $class = $in;
45 $class =~ s!\.pm$!!;
46 $class =~ s!/!::!g;
47 $class = "Search::$class";
49 open HTML, ">$out" or die $!;
50 if (!$is_pod) {
51 $pages{$class} = 'N' . ($pages{$class} || '');
52 print HTML <<EOT;
53 <?xml version="1.0" ?>
54 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
55 <html xmlns="http://www.w3.org/1999/xhtml">
56 <head>
57 <title>$class</title>
58 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
59 <link rev="made" />
60 </head>
62 <body style="background-color: white">
64 <p>No Perl-specific documentation currently exists for class
65 <code>$class</code> - please refer to the
66 <a href="https://xapian.org/docs/apidoc/html/annotated.html">C++
67 API documentation</a> for now.
68 </body>
70 </html>
71 EOT
72 } else {
73 $pages{$class} = 'Y' . ($pages{$class} || '');
75 system('pod2html', '--podroot=blib/lib', '--podpath=.', '--htmlroot', $root, '--infile', $in, '--outfile', $tmp) == 0
76 or die $!;
77 if ($?) { die $?; }
79 open TMP, $tmp or die $!;
81 while (<TMP>) {
82 s!>the (.*?) manpage<!>$1<!g;
83 s!\bhref="mailto:.*?@.*?"!!g;
84 # Clean up redundant . and .. in links.
85 s!(href=")\./\.\./\.\./Search/Xapian/!$1!g;
86 s!(href=")\./\.\./\.\./Search/!$1../!g;
87 s!(href=")Xapian/\.\./\.\./Search/!$1!g;
88 while (m!\bhref="(?:../)*(Search/Xapian[^.]*)!g) {
89 my $class = $1;
90 $class =~ s!/!::!g;
91 $pages{$class} = ($pages{$class} || '') . '=';
93 print HTML $_;
95 close TMP;
96 unlink $tmp;
98 close HTML or die $!;