This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In buildtoc, make %Readmepods lexical, and $delta_target global.
[perl5.git] / pod / buildtoc
index 68f75b3..19bb814 100644 (file)
@@ -2,7 +2,7 @@
 
 use strict;
 use vars qw($masterpodfile %Build %Targets $Verbose $Quiet %Ignore
-           @Master %Readmes %Pods %Aux %Readmepods %Pragmata %Modules
+           @Master %Readmes %Pods %Aux %Pragmata %Modules $delta_target
            %Copies %Generated $Test);
 use File::Spec;
 use File::Find;
@@ -15,14 +15,11 @@ use Carp;
 no locale;
 require 5.010;
 
+# Assumption is that we're either already being run from the top level (*nix,
+# VMS), or have absolute paths in @INC (Win32, pod/Makefile)
 {
   my $Top = File::Spec->catdir($FindBin::Bin, File::Spec->updir);
-
-  sub abs_from_top {
-    my $path = shift;
-    return File::Spec->catdir($Top, split /\//, $path) if $path =~ s!/\z!!;
-    return File::Spec->catfile($Top, split /\//, $path);
-  }
+  chdir $Top or die "Can't chdir to $Top: $!";
 }
 
 # make it clearer when we haven't run to completion, as we can be quite
@@ -36,7 +33,7 @@ sub my_die {
 }
 
 
-$masterpodfile = abs_from_top('pod.lst');
+$masterpodfile = 'pod.lst';
 
 # Generate any/all of these files
 # --verbose gives slightly more output
@@ -61,10 +58,6 @@ $masterpodfile = abs_from_top('pod.lst');
      # TODO: add roffitall
     );
 
-foreach (values %Targets) {
-  $_ = abs_from_top($_);
-}
-
 # process command-line switches
 
 {
@@ -117,11 +110,9 @@ if ($Verbose) {
   print "I will be building $_\n" foreach keys %Build;
 }
 
-my $delta_target;
-
 {
     my $source = 'perldelta.pod';
-    my $filename = abs_from_top("pod/$source");
+    my $filename = "pod/$source";
     open my $fh, '<', $filename or my_die "Can't open $filename: $!";
     local $/;
     my $contents = <$fh>;
@@ -137,6 +128,8 @@ my $delta_target;
 }
 
 # process pod.lst
+{
+    my %Readmepods;
 
 open my $master, '<', $masterpodfile or my_die "Can't open $masterpodfile: $!";
 
@@ -191,7 +184,7 @@ foreach (<$master>) {
 close $master;
 
 # Sanity cross check
-{
+
   my (%disk_pods, @disk_pods);
   my (@manipods, %manipods);
   my (@manireadmes, %manireadmes);
@@ -199,12 +192,18 @@ close $master;
   my (@cpanpods, %cpanpods, %cpanpods_short);
   my (%our_pods);
 
+  # These are stub files for deleted documents. We don't want them to show up
+  # in perl.pod, they just exist so that if someone types "perldoc perltoot"
+  # they get some sort of pointer to the new docs.
+  my %ignoredpods
+      = map { ( "$_.pod" => 1 ) } qw( perlboot perlbot perltooc perltoot );
+
   # Convert these to a list of filenames.
   foreach (keys %Pods, keys %Readmepods) {
     $our_pods{"$_.pod"}++;
   }
 
-  opendir my $dh, abs_from_top('pod/');
+  opendir my $dh, 'pod';
   while (defined ($_ = readdir $dh)) {
     next unless /\.pod\z/;
     push @disk_pods, $_;
@@ -214,7 +213,7 @@ close $master;
   # Things we copy from won't be in perl.pod
   # Things we copy to won't be in MANIFEST
 
-  my $filename = abs_from_top('MANIFEST');
+  my $filename = 'MANIFEST';
   open my $mani, '<', $filename or my_die "opening $filename failed: $!";
   while (<$mani>) {
     chomp;
@@ -236,7 +235,7 @@ close $master;
   @cpanpods{@cpanpods} = map { s/.*\///r } @cpanpods;
   %cpanpods_short = reverse %cpanpods;
 
-  $filename = abs_from_top('pod/perl.pod');
+  $filename = 'pod/perl.pod';
   open my $perlpod, '<', $filename or my_die "opening $filename failed: $!\n";
   while (<$perlpod>) {
     if (/^For ease of access, /../^\(If you're intending /) {
@@ -257,7 +256,7 @@ close $master;
     push @inconsistent, "$0: $i exists but is unknown by ../MANIFEST\n"
       if !$manipods{$i} && !$manireadmes{$i} && !$Copies{$i} && !$Generated{$i} && !$cpanpods{$i};
     push @inconsistent, "$0: $i exists but is unknown by perl.pod\n"
-       if !$perlpods{$i} && !exists $Copies{$i} && !$cpanpods{$i};
+      if !$perlpods{$i} && !exists $Copies{$i} && !$cpanpods{$i} && !$ignoredpods{$i};
   }
   my %BuildFiles;
   foreach my $path (values %Build) {
@@ -296,7 +295,7 @@ close $master;
 # Find all the modules
 if ($Build{toc}) {
   my @modpods;
-  find \&getpods => abs_from_top('lib/');
+  find \&getpods => 'lib';
 
   sub getpods {
     if (/\.p(od|m)$/) {
@@ -376,7 +375,7 @@ EOPOD2B
 
   # All the things in the master list that happen to be pod filenames
   foreach (grep {defined $_ && @$_ == 3 && !$_->[0]{toc_omit}} @Master) {
-    podset($_->[1], abs_from_top($_->[2]));
+    podset(@$_);
   }