mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 06:50:12 +00:00
man-pages: Add a batch mode to merge-pod
The merge-pod script is our simple custom preprocessor for man-page pod files. The merge-pod script expects one or more arguments to specify the input files and generates the output files in the same directory as the input files. Unfortunately, this precludes us from using merge-pod to do out-of-tree builds (a.k.a. objdir builds) which generate man-pages, since the output files are written to the source directory. Change merge-pod so when no input files are specified, merge-pod will scan the man-page pod<n> directories for *.in files, and put the pod output files in pod<n> directories in the current working directory. With this change, merge-pod remains compatible with the old method, which is still in use by the NT makefile and the regen.sh script, but provides support for a future commit to invoke merge-pod from the man-pages Makefile. Change-Id: I36b5b851cd1a09d050cf21c65ab3ae160a5c15cb Reviewed-on: https://gerrit.openafs.org/15788 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
parent
4baeaf1d9f
commit
ad526abaab
@ -1,29 +1,38 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# POD currently doesn't support any sort of =include directive. This
|
||||
# processor works around that limitation. It takes a list of files ending in
|
||||
# *.in as its argument and processes any POD directives of the form =include
|
||||
# <file> in that file, generating a file with the *.in suffix removed. All
|
||||
# paths are taken to be relative to the directory containing the file being
|
||||
# processed.
|
||||
# POD currently doesn't support any sort of =include directive. This processor
|
||||
# works around that limitation. Currently, only single include nesting is
|
||||
# supported. The included file is not processed for additional =include
|
||||
# statements. The include paths are taken to be relative to the directory
|
||||
# containing the file being processed.
|
||||
#
|
||||
# Currently, only single include nesting is supported. The included file is
|
||||
# not processed for additional =include statements.
|
||||
# Usage: merge-pod <input-file> [<input-file> ...]
|
||||
# merge-pod
|
||||
#
|
||||
# The first form takes a list of file paths ending in .in as its arguments and
|
||||
# processes any POD directives of the form =include <file> in that file,
|
||||
# generating a file with the .in suffix removed. The output file is written to
|
||||
# the same directory as the input file.
|
||||
#
|
||||
# When no input files are given, merge-pod scans the pod<n> directories
|
||||
# relative to the path of the merge-pod script itself for files ending in
|
||||
# *.in. For each input file file found, merge-pod processes any POD
|
||||
# directives of the form =include <file> in that file, generating an output
|
||||
# file with the .in suffix removed in the pod<n> directory in the current
|
||||
# working directory. The pod<n> directories are created in the current
|
||||
# directory if not already present.
|
||||
|
||||
require 5.00503;
|
||||
|
||||
use Cwd qw(getcwd);
|
||||
use File::Basename qw(dirname basename);
|
||||
use File::Spec::Functions qw(catfile);
|
||||
|
||||
my $start = getcwd;
|
||||
for my $file (@ARGV) {
|
||||
chdir $start or die "cannot chdir to $start: $!\n";
|
||||
$file =~ s:\\:/:g if $^O eq 'cygwin';
|
||||
sub merge_pod {
|
||||
my ($file, $out) = @_;
|
||||
my $start = getcwd;
|
||||
my $dir = dirname ($file);
|
||||
my $out = $file;
|
||||
unless ($out =~ s/\.in\z//) {
|
||||
die "input file $file does not end in .in\n";
|
||||
}
|
||||
|
||||
open (FILE, "< $file") or die "cannot open $file: $!\n";
|
||||
binmode FILE, ':crlf' if $^O eq 'MSWin32';
|
||||
binmode FILE, ':crlf' if $^O eq 'cygwin';
|
||||
@ -44,4 +53,34 @@ for my $file (@ARGV) {
|
||||
}
|
||||
close OUT or die "cannot write to $out: $!\n";
|
||||
close FILE or die "cannot read from $file\n";
|
||||
chdir $start or die "cannot chdir to $start: $!\n";
|
||||
}
|
||||
|
||||
if (scalar(@ARGV) > 0) {
|
||||
for my $file (@ARGV) {
|
||||
$file =~ s:\\:/:g if $^O eq 'cygwin';
|
||||
my $out = $file;
|
||||
unless ($out =~ s/\.in\z//) {
|
||||
die "input file $file does not end in .in\n";
|
||||
}
|
||||
merge_pod($file, $out);
|
||||
}
|
||||
} else {
|
||||
my $srcdir = dirname(__FILE__);
|
||||
for my $section (qw(1 3 5 8)) {
|
||||
unless (-d "pod${section}") {
|
||||
mkdir("pod${section}", 0755) or
|
||||
die "Cannot create pod${section} directory: $!\n";
|
||||
}
|
||||
my $dir = catfile($srcdir, "pod${section}");
|
||||
opendir(D, $dir) or die "Cannot open $dir: $!\n";
|
||||
for my $file (readdir(D)) {
|
||||
if ($file =~ /\.in\z/) {
|
||||
my $input = catfile($srcdir, "pod${section}", $file);
|
||||
my $output = catfile("pod${section}", $file);
|
||||
$output =~ s/\.in\z//;
|
||||
merge_pod($input, $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user