This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta: update modules sections for 5.20.0
[perl5.git] / pod / buildtoc
index a8a05ff..cbdec61 100644 (file)
@@ -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,28 +22,9 @@ die "$0: Usage: $0 [--quiet]\n"
 
 my $state = get_pod_metadata(0, sub { warn @_ if @_ }, 'pod/perltoc.pod');
 
-# Find all the modules
-my %done;
-find({no_chdir => 1,
-      wanted => sub {
-          if (/\.p(od|m)$/) {
-              return if m!/Pod/Functions.pm\z!; # Used only by pod itself
-              return if m!(?:^|/)t/!;
-              return if m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-)
-              return if m!XS/(?:APItest|Typemap)!;
-              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;
-              $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
@@ -61,6 +41,8 @@ my $roffitall;
        # This file is autogenerated by buildtoc from all the other pods.
        # Edit those files and run $0 to effect changes.
 
+       =encoding UTF-8
+
        =head1 NAME
 
        perltoc - perl documentation table of contents
@@ -76,9 +58,9 @@ my $roffitall;
 EOPOD2B
 
 # All the things in the master list that happen to be pod filenames
-foreach (grep {defined $_ && @$_ == 5 && !$_->[0]{toc_omit}} @{$state->{master}}) {
-    $roffitall .= "    \$mandir/$_->[4].1 \\\n";
-    podset($_->[4], $_->[2]);
+foreach (grep {!$_->[2]{toc_omit}} @{$state->{master}}) {
+    $roffitall .= "    \$mandir/$_->[0].1 \\\n";
+    podset($_->[0], $_->[1]);
 }
 
 foreach my $type (qw(PRAGMA MODULE)) {
@@ -90,10 +72,9 @@ foreach my $type (qw(PRAGMA MODULE)) {
 
 EOPOD2B
 
-    foreach my $name (sort keys %{$Found{$type}}) {
-        next if is_duplicate_pod($Found{$type}{$name});
+    foreach my $name (sort keys %{$found->{$type}}) {
         $roffitall .= "    \$libdir/$name.3 \\\n";
-        podset($name, $Found{$type}{$name});
+        podset($name, $found->{$type}{$name});
     }
 }
 
@@ -109,7 +90,7 @@ $_= <<"EOPOD2B";
 
 EOPOD2B
 
-$_ .=  join "\n", map {"\t=item $_\n"} sort keys %{$state->{aux}};
+$_ .=  join "\n", map {"\t=item $_\n"} @{$state->{aux}};
 $_ .= <<"EOPOD2B" ;
 
        =back