This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix (some) installhtml bugs
[perl5.git] / installhtml
index 72564d1..053858d 100755 (executable)
@@ -1,4 +1,6 @@
-#!/usr/bin/perl -w
+#!./perl -w
+
+# This file should really be a extracted from a .PL
 
 use lib 'lib';         # use source library if present
 
 
 use lib 'lib';         # use source library if present
 
@@ -61,13 +63,13 @@ a URL.  The default is `/'.
 
 =item B<--splithead> POD files to split on =head directive
 
 
 =item B<--splithead> POD files to split on =head directive
 
-Colon-separated list of pod files to split by the =head directive.  The
+Comma-separated list of pod files to split by the =head directive.  The
 .pod suffix is optional. These files should have names specified
 relative to podroot.
 
 =item B<--splititem> POD files to split on =item directive
 
 .pod suffix is optional. These files should have names specified
 relative to podroot.
 
 =item B<--splititem> POD files to split on =item directive
 
-Colon-separated list of all pod files to split by the =item directive.
+Comma-separated list of all pod files to split by the =item directive.
 The .pod suffix is optional.  I<installhtml> does not do the actual
 split, rather it invokes I<splitpod> to do the dirty work.  As with
 --splithead, these files should have names specified relative to podroot.
 The .pod suffix is optional.  I<installhtml> does not do the actual
 split, rather it invokes I<splitpod> to do the dirty work.  As with
 --splithead, these files should have names specified relative to podroot.
@@ -78,7 +80,7 @@ The directory containing the splitpod program. The default is `podroot/pod'.
 
 =item B<--libpods> library PODs for LE<lt>E<gt> links
 
 
 =item B<--libpods> library PODs for LE<lt>E<gt> links
 
-Colon-separated list of "library" pod files.  This is the same list that
+Comma-separated list of "library" pod files.  This is the same list that
 will be passed to pod2html when any pod is converted.
 
 =item B<--verbose> verbose output
 will be passed to pod2html when any pod is converted.
 
 =item B<--verbose> verbose output
@@ -93,14 +95,14 @@ The following command-line is an example of the one we use to convert
 perl documentation:
 
     ./installhtml --podpath=lib:ext:pod:vms   \
 perl documentation:
 
     ./installhtml --podpath=lib:ext:pod:vms   \
-                 --podroot=/usr/src/perl     \
-                  --htmldir=/perl/nmanual     \
-                 --htmlroot=/perl/nmanual    \
-                 --splithead=pod/perlipc     \
-                 --splititem=pod/perlfunc    \
-                 --libpods=perlfunc:perlguts:perlvar:perlrun:perlop \
-                  --recurse \
-                 --verbose
+                       --podroot=/usr/src/perl     \
+                       --htmldir=/perl/nmanual     \
+                       --htmlroot=/perl/nmanual    \
+                       --splithead=pod/perlipc     \
+                       --splititem=pod/perlfunc    \
+                       --libpods=perlfunc,perlguts,perlvar,perlrun,perlop \
+                       --recurse \
+                       --verbose
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
@@ -289,11 +291,13 @@ sub absolute_path {
 sub create_index {
     my($html, $dir) = @_;
     my(@files, @filedata, @index, $file);
 sub create_index {
     my($html, $dir) = @_;
     my(@files, @filedata, @index, $file);
+    my($lcp1,$lcp2);
+
 
     # get the list of .html files in this directory
     opendir(DIR, $dir) ||
        die "$0: error opening directory $dir for reading: $!\n";
 
     # get the list of .html files in this directory
     opendir(DIR, $dir) ||
        die "$0: error opening directory $dir for reading: $!\n";
-    @files = sort(grep(/\.html$/, readdir(DIR)));
+    @files = sort(grep(/\.html?$/, readdir(DIR)));
     closedir(DIR);
 
     open(HTML, ">$html") ||
     closedir(DIR);
 
     open(HTML, ">$html") ||
@@ -312,17 +316,20 @@ sub create_index {
 
        # pull out the NAME section
        ($name) = grep(/NAME=/, @filedata);
 
        # pull out the NAME section
        ($name) = grep(/NAME=/, @filedata);
-       $name =~ m,/H1>\s(\S+)\s[\s-]*(.*?)\s*$,sm;
+       ($lcp1,$lcp2) = ($name =~ m,/H1>\s(\S+)\s[\s-]*(.*?)\s*$,sm);
+       if (defined $lcp1 and $lcp1 eq '<P>') { # Uninteresting.  Try again.
+          ($lcp1,$lcp2) = ($name =~ m,/H1>\s<P>\s(\S+)\s[\s-]*(.*?)\s*$,sm);
+       }
        print HTML qq(<A HREF="$dir/$file">);
        print HTML qq(<A HREF="$dir/$file">);
-       print HTML "<DT>$1</A><DD>$2\n" if defined $1;
-#      print HTML qq(<A HREF="$dir/$file">$1</A><BR>\n") if defined $1;
+       print HTML "<DT>$lcp1</A><DD>$lcp2\n" if defined $lcp1;
+#      print HTML qq(<A HREF="$dir/$file">$lcp1</A><BR>\n") if defined $lcp1;
 
        next;
 
        @index = grep(/<!-- INDEX BEGIN -->.*<!-- INDEX END -->/s,
                    @filedata);
        for (@index) {
 
        next;
 
        @index = grep(/<!-- INDEX BEGIN -->.*<!-- INDEX END -->/s,
                    @filedata);
        for (@index) {
-           s/<!-- INDEX BEGIN -->(\s*<!--)(.*)(-->\s*)<!-- INDEX END -->/$2/s;
+           s/<!-- INDEX BEGIN -->(\s*<!--)(.*)(-->\s*)<!-- INDEX END -->/$lcp2/s;
            s,#,$dir/$file#,g;
            # print HTML "$_\n";
            print HTML "$_\n<P><HR><P>\n";
            s,#,$dir/$file#,g;
            # print HTML "$_\n";
            print HTML "$_\n<P><HR><P>\n";