This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move the common Pod scanning code from installman and buildtoc to pod_lib.pl
[perl5.git] / Porting / pod_lib.pl
index a87c3ee..7efe768 100644 (file)
@@ -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