summaryrefslogtreecommitdiff
path: root/Porting/pod_lib.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-12-22 11:26:29 +0100
committerNicholas Clark <nick@ccl4.org>2011-12-24 09:30:09 +0100
commit9bbb230a203c96fa7e8a45ef46e37c00319fafb1 (patch)
treed6bb6acdc88be55d591dbd6e678d4caf805bcfb6 /Porting/pod_lib.pl
parent3bf293368e665fedf90271ec12ba69772cca9a5c (diff)
downloadperl-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'.
Diffstat (limited to 'Porting/pod_lib.pl')
-rw-r--r--Porting/pod_lib.pl31
1 files changed, 31 insertions, 0 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