use POSIX qw(strftime setlocale LC_TIME);
my $this_program = 'help2man';
-my $this_version = '1.011';
+my $this_version = '1.012';
my $version_info = <<EOT;
$this_program $this_version
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
- --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 $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,
- 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;
# Header.
print <<EOT;
.\\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version.
-.TH $PROGRAM 1 "$date" "$package $version" "FSF"
+.TH $PROGRAM "$section" "$date" "$package $version" FSF
.SH NAME
$include{NAME}
EOT
+my $break;
my $accumulate = 1;
my @description = ();
print $include{DESCRIPTION};
}
+ $break = 1;
next unless $_;
}
if (s/^(Options|Examples): *\n//)
{
print qq(.SH \U$1\n);
+ $break = '';
next unless length;
}
if (/^Report bugs |^Email bug reports to /)
{
print qq(.SH "REPORTING BUGS"\n$_\n);
+ $break = '';
next;
}
# Option subsections have second line indented.
- print qq(.SS "$1"\n) if s/^(\S.*)\n / /;
+ if (s/^(\S.*)\n / /)
+ {
+ print qq(.SS "$1"\n);
+ $break = '';
+ }
my $output = '';
while (length)
{
$indent = length $1;
$output .= ".TP\n$2\n$3\n";
+ $break = 1;
}
# Indented paragraph
{
$indent = length $1;
$output .= ".IP\n$2\n";
+ $break = 1;
}
# Left justified paragraph
else
{
s/(.*)\n?//;
- $output .= ".PP\n" if $output;
+ $output .= ".PP\n" if $break;
$output .= "$1\n";
+ $break = 1;
}
# Continuations