summaryrefslogtreecommitdiffstats
path: root/util/process_docs.pl
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-06-02 15:38:16 +0200
committerRichard Levitte <levitte@openssl.org>2016-06-02 15:38:16 +0200
commitee2c1a253d558dc64a9d4d5b09dc083a4cff395a (patch)
tree2165b1c3f9f279cfa4e2b54d242ef21189298b86 /util/process_docs.pl
parent8d054a5530defa35ad9a337c23968f8bdef9a6c7 (diff)
perl: refactor .pod name section extractor into its own module
Adapt util/process_docs.pl Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'util/process_docs.pl')
-rw-r--r--util/process_docs.pl47
1 files changed, 9 insertions, 38 deletions
diff --git a/util/process_docs.pl b/util/process_docs.pl
index fe8589b18a..8b8de81acd 100644
--- a/util/process_docs.pl
+++ b/util/process_docs.pl
@@ -20,6 +20,11 @@ use Pod::Usage;
use lib '.';
use configdata;
+# We know we are in the 'util' directory and that our perl modules are
+# in util/perl
+use lib catdir(dirname($0), "perl");
+use OpenSSL::Util::Pod;
+
my %options = ();
GetOptions(\%options,
'sourcedir=s', # Source directory
@@ -78,44 +83,10 @@ foreach my $subdir (keys %{$options{subdir}}) {
foreach my $podfile (glob $podglob) {
my $podname = basename($podfile, ".pod");
my $podpath = catfile($podfile);
- my %podinfo = ( section => $section );
-
- print STDERR "DEBUG: Reading $podpath\n" if $options{debug};
- open my $pod_fh, $podpath or die "Trying to read $podpath: $!\n";
- while (<$pod_fh>) {
- s|\R$||;
- if (m|^=for\s+comment\s+openssl_manual_section:\s*([0-9])\s*$|) {
- print STDERR "DEBUG: Found man section number $1\n"
- if $options{debug};
- $podinfo{section} = $1;
- }
- last if (m|^=head1|
- && defined $podinfo{lastsect}
- && $podinfo{lastsect} eq "NAME");
- if (m|^=head1\s*(.*)|) {
- $podinfo{lastsect} = $1;
- $podinfo{lastsect} =~ s/\s+$//;
- print STDERR "DEBUG: Found new pod section $1\n"
- if $options{debug};
- print STDERR "DEBUG: Clearing pod section text\n"
- if $options{debug};
- $podinfo{lastsecttext} = "";
- }
- next if (m|^=| || m|^\s*$|);
- print STDERR "DEBUG: accumulating pod section text \"$_\"\n"
- if $options{debug};
- $podinfo{lastsecttext} .= " " if $podinfo{lastsecttext};
- $podinfo{lastsecttext} .= $_;
- }
- close $pod_fh;
- print STDERR "DEBUG: Done reading $podpath\n" if $options{debug};
- $podinfo{lastsecttext} =~ s| - .*$||;
- print STDERR "DEBUG: Done reading $podpath\n" if $options{debug};
-
- my @podfiles =
- grep { $_ ne $podname }
- map { s|\s+||g; $_ }
- split(m|,|, $podinfo{lastsecttext});
+ my %podinfo = extract_pod_info($podpath,
+ { debug => $options{debug},
+ section => $section });
+ my @podfiles = grep { $_ ne $podname } @{$podinfo{names}};
my $updir = updir();
my $name = uc $podname;