util/process_docs.pl: handle multiple source directories correctly
The way this script handled multiple source directories wasn't quite
right, it ended up giving pod2html 'ARRAY(0xXXXXXXXXX)' as a source
directory.
This corrects the mistake.
Fixes
Fixes
@@ -84,10 +84,11 @@ my $symlink_exists = eval { symlink("",""); 1 };
foreach my $section (sort @{$options{section}}) {
my $subdir = "man$section";
- my @podsourcedirs = map { catfile($_, $subdir); } @{$options{sourcedir}};
- my @podglobs = map { catfile($_, "*.pod"); } @podsourcedirs;
+ foreach my $sourcedir (@{$options{sourcedir}}) {
+ my $podsourcedir = catfile($sourcedir, $subdir);
+ my $podglob = catfile($podsourcedir, "*.pod");
- foreach my $podfile (map { glob $_ } @podglobs) {
+ foreach my $podfile (glob $podglob) {
my $podname = basename($podfile, ".pod");
my $podpath = catfile($podfile);
my %podinfo = extract_pod_info($podpath,
@@ -97,10 +98,16 @@ foreach my $section (sort @{$options{section}}) {
my $updir = updir();
my $name = uc $podname;
- my $suffix = { man => ".$podinfo{section}".($options{suffix} // ""),
+ my $suffix =
+ { man => ".$podinfo{section}".($options{suffix} // ""),
html => ".html" } -> {$options{type}};
- my $generate = { man => "pod2man --name=$name --section=$podinfo{section} --center=OpenSSL --release=$config{version} \"$podpath\"",
- html => "pod2html \"--podroot=$options{sourcedir}\" --htmldir=$updir --podpath=man1:man3:man5:man7 \"--infile=$podpath\" \"--title=$podname\" --quiet"
+ my $generate =
+ { man => <<"_____",
+pod2man --name=$name --section=$podinfo{section} --center=OpenSSL --release=$config{version} "$podpath"
+_____
+ html => <<"_____",
+pod2html "--podroot=$sourcedir" --htmldir=$updir --podpath=man1:man3:man5:man7 "--infile=$podpath" "--title=$podname" --quiet
+_____
} -> {$options{type}};
my $output_dir = catdir($options{destdir}, "man$podinfo{section}");
my $output_file = $podname . $suffix;
@@ -115,9 +122,9 @@ foreach my $section (sort @{$options{section}}) {
map { s|href="http://man\.he\.net/(man\d/[^"]+)(?:\.html)?"|href="../$1.html"|g; } @output
if $options{type} eq "html";
if ($options{type} eq "man") {
- # Because some *roff parsers are more strict than others,
- # multiple lines in the NAME section must be merged into
- # one.
+ # Because some *roff parsers are more strict than
+ # others, multiple lines in the NAME section must
+ # be merged into one.
my $in_name = 0;
my $name_line = "";
my @newoutput = ();
@@ -144,7 +151,8 @@ foreach my $section (sort @{$options{section}}) {
print STDERR "DEBUG: Done processing\n" if $options{debug};
if (! -d $output_dir) {
- print STDERR "DEBUG: Creating directory $output_dir\n" if $options{debug};
+ print STDERR "DEBUG: Creating directory $output_dir\n"
+ if $options{debug};
unless ($options{"dry-run"}) {
mkpath $output_dir
or die "Trying to create directory $output_dir: $!\n";
@@ -195,6 +203,7 @@ foreach my $section (sort @{$options{section}}) {
}
}
}
+}
__END__
