diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-12-22 11:26:29 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-12-24 09:30:09 +0100 |
commit | 9bbb230a203c96fa7e8a45ef46e37c00319fafb1 (patch) | |
tree | d6bb6acdc88be55d591dbd6e678d4caf805bcfb6 | |
parent | 3bf293368e665fedf90271ec12ba69772cca9a5c (diff) | |
download | perl-9bbb230a203c96fa7e8a45ef46e37c00319fafb1.tar.gz |
Move the common Pod scanning code from installman and buildtoc to pod_lib.pl
The unified code to scan lib/ for Pod is now in pods_to_install().
It returns found Pods partitioned into 'MODULE' and 'PRAGMA', as buildtoc
needs this distinction. installman installs Pods in the same order as before,
as 'PRAGMA' sort lexically after 'MODULE'.
-rw-r--r-- | Porting/pod_lib.pl | 31 | ||||
-rwxr-xr-x | installman | 29 | ||||
-rw-r--r-- | pod/buildtoc | 37 |
3 files changed, 40 insertions, 57 deletions
diff --git a/Porting/pod_lib.pl b/Porting/pod_lib.pl index a87c3ee048..7efe7686dc 100644 --- a/Porting/pod_lib.pl +++ b/Porting/pod_lib.pl @@ -2,6 +2,7 @@ use strict; use Digest::MD5 'md5'; +use File::Find; # make it clearer when we haven't run to completion, as we can be quite # noisy when things are working ok @@ -37,6 +38,36 @@ sub write_or_die { close $fh or die "Can't close $filename: $!"; } +sub pods_to_install { + # manpages not to be installed + my %do_not_install = map { ($_ => 1) } + qw(Pod::Functions XS::APItest XS::Typemap); + + my (%done, %found); + + File::Find::find({no_chdir=>1, + wanted => sub { + # $_ is $File::Find::name when using no_chdir + return unless m!\.p(?:m|od)\z! && -f $_; + return if m!(?:^|/)t/!; + return if m!lib/Net/FTP/.+\.pm\z!; # Hi, Graham! :-) + # Skip .pm files that have corresponding .pod files + return if s!\.pm\z!.pod! && -e $_; + s!\.pod\z!!; + s!\Alib/!!; + s!/!::!g; + + my_die("Duplicate files for $_, '$done{$_}' and '$File::Find::name'") + if exists $done{$_}; + $done{$_} = $File::Find::name; + + return if $do_not_install{$_}; + return if is_duplicate_pod($File::Find::name); + $found{/\A[a-z]/ ? 'PRAGMA' : 'MODULE'}{$_} + = $File::Find::name; + }}, 'lib'); + return \%found; +} my %state = ( # Don't copy these top level READMEs diff --git a/installman b/installman index 263e7ced29..ced3028dc0 100755 --- a/installman +++ b/installman @@ -8,7 +8,6 @@ BEGIN { use strict; use Getopt::Long; -use File::Find; use File::Path qw(mkpath); use ExtUtils::Packlist; use Pod::Man; @@ -73,31 +72,9 @@ pod2man({ # Install the pods for library modules. { - # manpages not to be installed - my %do_not_install = map { ($_ => 1) } - qw(Pod::Functions XS::APItest XS::Typemap); - - my %modpods; - File::Find::find({no_chdir=>1, - wanted => sub { - # $_ is $File::Find::name when using no_chdir - if (-f $_ and /\.p(?:m|od)$/) { - return if m!(?:^|/)t/!; - return if m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-) - # Skip .pm files that have corresponding .pod files - return if s!\.pm\z!.pod! && -e $_; - s!\.pod\z!!; - s!\Alib/!!; - s!/!::!g; - - return if $do_not_install{$_}; - return if is_duplicate_pod($File::Find::name); - $modpods{$_} = $File::Find::name; - } - }}, - 'lib'); - - pod2man(\%modpods, $opts{man3dir}, $opts{man3ext}, 'lib'); + my $found = pods_to_install(); + pod2man($found->{$_}, $opts{man3dir}, $opts{man3ext}, 'lib') + foreach qw(MODULE PRAGMA); } # Install the pods embedded in the installed scripts diff --git a/pod/buildtoc b/pod/buildtoc index 61ea096a47..06307c4bc0 100644 --- a/pod/buildtoc +++ b/pod/buildtoc @@ -1,9 +1,8 @@ #!/usr/bin/perl -w use strict; -use vars qw(%Found $Quiet); +use vars qw($Quiet); use File::Spec; -use File::Find; use FindBin; use Text::Wrap; use Getopt::Long; @@ -23,33 +22,9 @@ die "$0: Usage: $0 [--quiet]\n" my $state = get_pod_metadata(0, sub { warn @_ if @_ }, 'pod/perltoc.pod'); -# Find all the modules -# manpages not to be installed -my %do_not_install = map { ($_ => 1) } - qw(Pod::Functions XS::APItest XS::Typemap); - -my %done; -find({no_chdir => 1, - wanted => sub { - if (/\.p(od|m)$/) { - return if m!(?:^|/)t/!; - return if m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-) - return if s!\.pm\z!.pod! && -e $_; - s!\.pod\z!!; - s!\Alib/!!; - s!/!::!g; - my_die("Duplicate files for $_, '$done{$_}' and '$File::Find::name'") - if exists $done{$_}; - $done{$_} = $File::Find::name; - - return if $do_not_install{$_}; - return if is_duplicate_pod($File::Find::name); - - $Found{/\A[a-z]/ ? 'PRAGMA' : 'MODULE'}{$_} = $File::Find::name; - } - }}, 'lib'); - -my_die "Can't find any pods!\n" unless %done; +my $found = pods_to_install(); + +my_die "Can't find any pods!\n" unless %$found; # Accumulating everything into a lexical before writing to disk dates from the # time when this script also provided the functionality of regen/pod_rules.pl @@ -95,9 +70,9 @@ foreach my $type (qw(PRAGMA MODULE)) { EOPOD2B - foreach my $name (sort keys %{$Found{$type}}) { + foreach my $name (sort keys %{$found->{$type}}) { $roffitall .= " \$libdir/$name.3 \\\n"; - podset($name, $Found{$type}{$name}); + podset($name, $found->{$type}{$name}); } } |