update help2man

This commit is contained in:
okuji 1999-06-24 16:37:20 +00:00
parent 2465e9eb0b
commit efbf4469d4
5 changed files with 95 additions and 84 deletions

View file

@ -1,3 +1,13 @@
1999-06-24 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* Makefile.am (SUBDIRS): Change the order of the directories so
that a directory will be made after the dependent directories
are made. `grub' depends on `stage2', and `docs' depends on
`grub'. Do not make in parallel.
* docs/help2man: Copied from help2man-1.012, which contains my
previous change.
* docs/grub.8: Regenerated.
1999-06-24 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
Build process is cleaned up. Stage 2 and Stage 1.5's are all

View file

@ -1,4 +1,4 @@
SUBDIRS = stage1 stage2 docs debian grub
SUBDIRS = stage1 stage2 grub docs debian
EXTRA_DIST = BUGS
# We get $(PACKAGE) and $(VERSION) from debian/changelog.

View file

@ -74,7 +74,7 @@ host_vendor = @host_vendor@
install_sh = @install_sh@
SUBDIRS = stage1 stage2 docs debian grub
SUBDIRS = stage1 stage2 grub docs debian
EXTRA_DIST = BUGS
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4

View file

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.010.
.TH GRUB "8" "June 2000" "GNU GRUB 0.5.92" "FSF"
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.012.
.TH GRUB "8" "June 1999" "GNU GRUB 0.5.92" FSF
.SH NAME
GRUB \- the stage2 emulator shell
.SH SYNOPSIS

View file

@ -22,10 +22,11 @@
use 5.004;
use strict;
use Getopt::Long;
use Text::Tabs qw(expand);
use POSIX qw(strftime setlocale LC_TIME);
my $this_program = 'help2man';
my $this_version = '1.010';
my $this_version = '1.012';
my $version_info = <<EOT;
$this_program $this_version
@ -41,31 +42,32 @@ my $help_info = <<EOT;
Usage: $this_program [OPTION]... EXECUTABLE
--name=STRING use `STRING' as the description for the NAME paragraph
--include=FILE include material from `FILE'
--opt-include=FILE include material from `FILE' if it exists
--output=FILE send output to `FILE'
--no-info suppress pointer to Texinfo manual
--section=SECTION use `SECTION' as the section for the man page
--help print this help, then exit
--version print $this_program program version number, then exit
-n, --name=STRING use `STRING' as the description for the NAME paragraph
-s, --section=SECTION use `SECTION' as the section for the man page
-i, --include=FILE include material from `FILE'
-I, --opt-include=FILE include material from `FILE' if it exists
-o, --output=FILE send output to `FILE'
-N, --no-info suppress pointer to Texinfo manual
--help print this help, then exit
--version print $this_program program version number, then exit
EXECUTABLE should accept `--help' and `version' options.
EOT
my ($include, $opt_name, $opt_include, $opt_output, $opt_no_info,
$opt_section);
my $section = 1;
my ($include, $opt_name, $opt_include, $opt_output, $opt_no_info);
# Parse options.
Getopt::Long::config('bundling');
GetOptions (
'name=s' => \$opt_name,
'include=s' => \$include,
'opt-include=s' => \$opt_include,
'output=s' => \$opt_output,
'no-info' => \$opt_no_info,
'section=s' => \$opt_section,
help => sub { print $help_info; exit },
version => sub { print $version_info; exit },
'n|name=s' => \$opt_name,
's|section=s' => \$section,
'i|include=s' => \$include,
'I|opt-include=s' => \$opt_include,
'o|output=s' => \$opt_output,
'N|no-info' => \$opt_no_info,
help => sub { print $help_info; exit },
version => sub { print $version_info; exit },
) or die $help_info;
die $help_info unless @ARGV == 1;
@ -127,11 +129,14 @@ if ($include or $opt_include)
# Turn off localisation of date (for strftime)
setlocale LC_TIME, 'C';
# Expand tabs, strip trailing spaces and break into paragraphs
sub paragraphs { split /\n\n+/, join '', expand @_ }
# Grab help and version paragraphs from executable
my @help = split /\n\n+/, `$ARGV[0] --help 2>/dev/null`
my @help = paragraphs `$ARGV[0] --help 2>/dev/null`
or die "$this_program: can't get `--help' info from $ARGV[0]\n";
my @version = split /\n\n+/, `$ARGV[0] --version 2>/dev/null`
my @version = paragraphs `$ARGV[0] --version 2>/dev/null`
or die "$this_program: can't get `--version' info from $ARGV[0]\n";
my $date = strftime "%B %Y", localtime;
@ -139,10 +144,6 @@ my $date = strftime "%B %Y", localtime;
my $package = $program;
my $version;
# Set the section to 1 by default.
my $section = 1;
$section = $opt_section if $opt_section;
if ($opt_output)
{
unlink $opt_output
@ -166,14 +167,14 @@ if ($opt_output)
$_ = shift @version;
if (/^(\S+)\s+\(((?:GNU|Free)\s+[^)]+)\)\s+(.*)/ or
/^(\S+)\s+-\s*((?:GNU|Free)\s+\S+)\s+(.*)/)
if (/^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/ or
/^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/)
{
$program = $1;
$package = $2;
$version = $3;
}
elsif (/^((?:GNU|Free)\s+)?(\S+)\s+(.*)/)
elsif (/^((?:GNU|Free) +)?(\S+) +(.*)/)
{
$program = $2;
$package = $1 ? "$1$2" : $2;
@ -201,11 +202,12 @@ my $PROGRAM = uc $program;
# Header.
print <<EOT;
.\\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version.
.TH $PROGRAM "$section" "$date" "$package $version" "FSF"
.TH $PROGRAM "$section" "$date" "$package $version" FSF
.SH NAME
$include{NAME}
EOT
my $break;
my $accumulate = 1;
my @description = ();
@ -216,7 +218,7 @@ for (@help)
{
chomp;
if (s/^Usage:\s+\S+\s+(.*)\n?//)
if (s/^Usage: +\S+ +(.*)\n?//)
{
# Turn the usage clause into a synopsis.
my $synopsis = '';
@ -226,13 +228,13 @@ for (@help)
$syn =~ s/(([][]|\.\.+)+)/\\fR$1\\fI/g;
$syn =~ s/^/\\fI/ unless $syn =~ s/^\\fR//;
$syn .= '\fR';
$syn =~ s/\\fI(\s*)\\fR/$1/g;
$syn =~ s/\\fI( *)\\fR/$1/g;
$synopsis .= ".br\n" unless $accumulate;
$synopsis .= ".B $program\n";
$synopsis .= "$syn\n";
$accumulate = 0;
} while s/^(?:Usage|\s*or):\s+\S+\s+(.*)\n?//;
} while s/^(?:Usage| *or): +\S+ +(.*)\n?//;
# Include file overrides SYNOPSIS.
print ".SH SYNOPSIS\n", $include{SYNOPSIS} || $synopsis;
@ -248,6 +250,7 @@ for (@help)
print $include{DESCRIPTION};
}
$break = 1;
next unless $_;
}
@ -260,9 +263,10 @@ for (@help)
}
# Convert some standard paragraph names
if (s/^(Options|Examples):\s*\n//)
if (s/^(Options|Examples): *\n//)
{
print qq(.SH \U$1\n);
$break = '';
next unless length;
}
@ -270,59 +274,56 @@ for (@help)
if (/^Report bugs |^Email bug reports to /)
{
print qq(.SH "REPORTING BUGS"\n$_\n);
$break = '';
next;
}
# Special case for tar 1.12: --label=NAME\nPATTERN.
s{(\n[ \t]*)(-V,[ \t]+--label=NAME.*)\n[ \t]+PATTERN[ \t]+}
{$1$2$1\\&...=PATTERN };
# Convert options.
s/((?:^|,)\s+)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/mge;
# Option subsections have second line indented.
print qq(.SS "$1"\n) if s/^(\S.*)\n(\s)/$2/;
my $ind = 0;
for (split /\n/)
if (s/^(\S.*)\n / /)
{
# indented paragraph
if (/^\s/)
print qq(.SS "$1"\n);
$break = '';
}
my $output = '';
while (length)
{
my $indent = 0;
# Tagged paragraph
if (s/^( +(\S.*?) +)(\S.*)\n?//)
{
# Join continued lines when indented to the same point as
# text following at least two spaces on the previous line.
if ($ind > 0 and /^ {$ind}\S/)
{
s/^\s+//;
print "$_\n" if $_;
}
else
{
# use the words(s) before two or more spaces for the
# tag
s/^(\s+)//;
$ind = length $1;
if (s/(\s\s+)/\n/)
{
$ind += (length $1) + index $_, "\n";
}
else
{
$ind = 0;
}
print ".TP\n$_\n" if $_;
}
$indent = length $1;
$output .= ".TP\n$2\n$3\n";
$break = 1;
}
# Anything else.
# Indented paragraph
elsif (s/^( +)(\S.*)\n?//)
{
$indent = length $1;
$output .= ".IP\n$2\n";
$break = 1;
}
# Left justified paragraph
else
{
print ".PP\n" unless $ind < 0;
print "$_\n";
$ind = -1;
s/(.*)\n?//;
$output .= ".PP\n" if $break;
$output .= "$1\n";
$break = 1;
}
# Continuations
$output .= "$1\n" while s/^ {$indent}(\S.*)\n?//;
}
$_ = $output;
# Convert options.
s/(^| )(-[][\w=-]+)/$1 . convert_option $2/mge;
print;
}
# Print any include items other than the ones we have already dealt
@ -363,16 +364,16 @@ for (@version)
s/([A-Za-z])-\n */$1/g;
# Convert copyright symbol or (c) to nroff character.
s/Copyright\s+(?:\xa9|\([Cc]\))/Copyright \\(co/g;
s/Copyright +(?:\xa9|\([Cc]\))/Copyright \\(co/g;
# Insert appropriate headings for copyright and author.
if (/^Copyright\s\\/) { print ".SH COPYRIGHT\n" }
elsif (/^Written\s+by/) { print ".SH AUTHOR\n" }
else { print ".PP\n"; }
if (/^Copyright \\/) { print ".SH COPYRIGHT\n" }
elsif (/^Written +by/) { print ".SH AUTHOR\n" }
else { print ".PP\n"; }
# Insert line breaks before additional copyright messages and the
# disclaimer.
s/(.)\n(Copyright\s|This is free software)/$1\n.br\n$2/g;
s/(.)\n(Copyright |This is free software)/$1\n.br\n$2/g;
print "$_\n";
}