Improvements
This commit was SVN r22493.
Этот коммит содержится в:
родитель
3fdb9823cd
Коммит
21a4bc6af5
83
contrib/dist/make-html-man-pages.pl
поставляемый
83
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/<filename>" 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/<filename>" 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 (<CMD>);
|
||||
close(CMD);
|
||||
|
||||
# Post-process the text:
|
||||
# Remove <head> ... </head>
|
||||
# Remove <!doctype ...>
|
||||
# Remove <meta ...>
|
||||
# Remove <style ...> ... </style>
|
||||
# Remove <title> ... </title>
|
||||
# Remove <html> and </html>
|
||||
# Remove <body> and </body>
|
||||
|
||||
$text =~ s/<head>.*<\/head>//is;
|
||||
$text =~ s/<!doctype.*?>//is;
|
||||
$text =~ s/<html>//i;
|
||||
$text =~ s/<\/html>//i;
|
||||
$text =~ s/<body>//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 '<?php
|
||||
$topdir = "../../..";
|
||||
$title = "' . "$name($section) man page (version $version)" . '";
|
||||
|
||||
include_once("$topdir/includes/header.inc");
|
||||
?>
|
||||
';
|
||||
|
||||
# Run the groff command and send the output to the file
|
||||
open(CMD, "groff -mandoc -T html $file|") || die("Can't open command");
|
||||
while (<CMD>) {
|
||||
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 '<?php
|
||||
<p> <a href="../">« Return to documentation listing</a></p>
|
||||
' . $text . '
|
||||
<p> <a href="../">« Return to documentation listing</a></p>
|
||||
<?php
|
||||
include_once("$topdir/includes/footer.inc");
|
||||
';
|
||||
|
||||
# Done with this file
|
||||
close(FILE);
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user