diff --git a/contrib/dist/make-html-man-pages.pl b/contrib/dist/make-html-man-pages.pl index 616ecf6958..d637663805 100755 --- a/contrib/dist/make-html-man-pages.pl +++ b/contrib/dist/make-html-man-pages.pl @@ -2,8 +2,8 @@ # # Copyright (c) 2010 Cisco Systems, Inc. # -# Script to generate PHP-ized files of man pages generated by Open MPI -# tarballs. +# Script to generate PHP-ized files of Open MPI tarball-installed man +# pages. # use strict; @@ -11,16 +11,16 @@ use File::Find; use File::Basename; use Cwd; -my $topdir; +my $mandir; my $version; # Read command line arguments while (@ARGV) { my $a = $ARGV[0]; - if ($a eq "--topdir" && $#ARGV >= 1) { + if ($a eq "--mandir" && $#ARGV >= 1) { shift @ARGV; - $topdir = $ARGV[0]; - print "Found topdir: $topdir\n"; + $mandir = $ARGV[0]; + print "Found mandir: $mandir\n"; shift @ARGV; } @@ -33,8 +33,8 @@ while (@ARGV) { } # Check that we have what we need -if (!defined($topdir) || !defined($version)) { - print "Usage: $0 --topdir dir --version version\n"; +if (!defined($mandir) || !defined($version)) { + print "Usage: $0 --mandir dir --version version\n"; exit(1); } @@ -42,15 +42,15 @@ if (!defined($topdir) || !defined($version)) { my @files; my $pwd = Cwd::cwd(); -# Find all *.[0-9] files in the $topdir/share/man tree. +# Find all *.[0-9] files in the $mandir tree. &File::Find::find( sub { push(@files, $File::Find::name) if (-f $_ && $_ =~ /\.[1-9]$/); - }, "$topdir/share/man"); + }, $mandir); -# Must cd into the "man" directory because some of the man pages refer -# to other man pages by "man/" relative path names. -chdir("$topdir/share/man"); +# Must cd into the $mandir directory because some of the man pages +# refer to other man pages by "man/" relative path names. +chdir($mandir); my %dirs; my $outfiles; @@ -75,35 +75,54 @@ foreach my $file (@files) { if (! -d $outdir); print "Generating: $name ($section)\n"; + + # Run the groff command and send the output to the file + open(CMD, "groff -mandoc -T html $file|") || die("Can't open command"); + my $text; + $text .= $_ + while (); + close(CMD); + + # Post-process the text: + # Remove ... + # Remove + # Remove + # Remove + # Remove ... + # Remove and + # Remove and + + $text =~ s/.*<\/head>//is; + $text =~ s///is; + $text =~ s///i; + $text =~ s/<\/html>//i; + $text =~ s///i; + $text =~ s/<\/body>//i; + + # Remove carriage returns, extra white space, and double blank + # lines + $text =~ s/\r//g; + $text =~ s/[ \t]+\n/\n/g; + $text =~ s/\n{3,}/\n\n/g; + + # Now we're left with what we want. Output the PHP page. + + # Write the output PHP file with our own header and footer, + # suitable for www.open-mpi.org. unlink($outfile); open(FILE, ">$outfile") || die "Can't open $outfile"; - - # Write a PHP header that is suitable for the pages on - # www.open-mpi.org print FILE ' -'; - - # Run the groff command and send the output to the file - open(CMD, "groff -mandoc -T html $file|") || die("Can't open command"); - while () { - last - if ($_ =~ /<\/body>/ || $_ =~ /<\/html>/); - print FILE $_; - } - close(CMD); - - # Write a PHP footer that is suitable for the pages on - # www.open-mpi.org - print FILE ' « Return to documentation listing

+' . $text . ' +

« Return to documentation listing

+