4 use vars qw(%Found $Quiet);
13 # Assumption is that we're either already being run from the top level (*nix,
14 # VMS), or have absolute paths in @INC (Win32, pod/Makefile)
16 my $Top = File::Spec->catdir($FindBin::Bin, File::Spec->updir);
17 chdir $Top or die "Can't chdir to $Top: $!";
18 require 'Porting/pod_lib.pl';
21 die "$0: Usage: $0 [--quiet]\n"
22 unless GetOptions (quiet => \$Quiet) && !@ARGV;
24 my $state = get_pod_metadata(0, 'pod/perltoc.pod');
26 warn @{$state->{inconsistent}} if @{$state->{inconsistent}};
28 # Find all the modules
32 my $file = $File::Find::name;
33 return if $file =~ qr!/Pod/Functions.pm\z!; # Used only by pod itself
34 return if $file =~ m!(?:^|/)t/!;
35 return if $file =~ m!lib/Attribute/Handlers/demo/!;
36 return if $file =~ m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-)
37 return if $file =~ m!lib/Math/BigInt/t/!;
38 return if $file =~ m!/Devel/PPPort/[Hh]arness|lib/Devel/Harness!i;
39 return if $file =~ m!XS/(?:APItest|Typemap)!;
41 return if $pod =~ s/pm$/pod/ && -e $pod;
42 unless (open my $f, '<', $_) {
43 warn "$0: bogus <$file>: $!";
44 system "ls", "-l", $file;
48 while ($line = <$f>) {
49 if ($line =~ /^=head1\s+NAME\b/) {
54 warn "$0: NOTE: cannot find '=head1 NAME' in:\n $file\n" unless $Quiet;
59 my_die "Can't find any pods!\n" unless @modpods;
64 $name =~ s/\.p(m|od)$//;
67 next if $done{$name}++;
69 $Found{$name =~ /^[a-z]/ ? 'PRAGMA' : 'MODULE'}{$name} = $_;
72 # Accumulating everything into a lexical before writing to disk dates from the
73 # time when this script also provided the functionality of regen/pod_rules.pl
74 # and this code was in a subroutine do_toc(). In turn, the use of a file scoped
75 # lexical instead of a parameter or return value is because the code dates back
76 # further still, and used *only* to create pod/perltoc.pod by printing direct
80 ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
82 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
83 # This file is autogenerated by buildtoc from all the other pods.
84 # Edit those files and run $0 to effect changes.
88 perltoc - perl documentation table of contents
92 This page provides a brief table of contents for the rest of the Perl
93 documentation set. It is meant to be scanned quickly or grepped
94 through to locate the proper section you're looking for.
96 =head1 BASIC DOCUMENTATION
100 # All the things in the master list that happen to be pod filenames
101 foreach (grep {defined $_ && @$_ == 5 && !$_->[0]{toc_omit}} @{$state->{master}}) {
102 podset($_->[1], $_->[2]);
105 foreach my $type (qw(PRAGMA MODULE)) {
106 ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
110 =head1 $type DOCUMENTATION
114 foreach my $name (sort keys %{$Found{$type}}) {
115 podset($name, $Found{$type}{$name});
122 =head1 AUXILIARY DOCUMENTATION
124 Here should be listed all the extra programs' documentation, but they
125 don't all have manual pages yet:
131 $_ .= join "\n", map {"\t=item $_\n"} sort keys %{$state->{aux}};
138 Larry Wall <F<larry\@wall.org>>, with the help of oodles
147 $OUT =~ s/\n\s+\n/\n\n/gs;
148 $OUT =~ s/\n{3,}/\n\n/g;
150 $OUT =~ s/([^\n]+)/wrap('', '', $1)/ge;
152 write_or_die('pod/perltoc.pod', $OUT);
156 # Below are all the auxiliary routines for generating perltoc.pod
158 my ($inhead1, $inhead2, $initem);
161 my ($pod, $file) = @_;
165 open my $fh, '<', $file or my_die "Can't open file '$file' for $pod: $!";
169 if (s/^=head1 (NAME)\s*/=head2 /) {
171 $OUT .= "\n\n=head2 ";
173 # Remove svn keyword expansions from the Perl FAQ
174 s/ \(\$Revision: \d+ \$\)//g;
175 if ( /^\s*\Q$pod\E\b/ ) {
176 s/$pod\.pm/$pod/; # '.pm' in NAME !?
181 elsif (s/^=head1 (.*)/=item $1/) {
183 $OUT .= "=over 4\n\n" unless $inhead1;
187 elsif (s/^=head2 (.*)/=item $1/) {
189 $OUT .= "=over 4\n\n" unless $inhead2;
193 elsif (s/^=item ([^=].*)/$1/) {
194 next if $pod eq 'perldiag';
195 s/^\s*\*\s*$// && next;
200 next if $pod eq 'perlmodlib' && /^ftp:/;
201 $OUT .= ", " if $initem;
207 unhead1() if /^=cut\s*\n/;
217 $OUT .= "\n\n=back\n\n";
225 $OUT .= "\n\n=back\n\n";
237 # Code added in commit 416302502f485afa, but never used.
238 # Probably roffitall should become something that buildtoc generates, instead
239 # of something that we ship in the distribution.
241 sub generate_roffitall {
242 (map ({"\t\$maindir/$_.1\t\\"}sort keys %{$state->{pods}}),
244 map ({"\t\$maindir/$_.1\t\\"}sort keys %{$state->{aux}}),
246 map ({"\t\$libdir/$_.3\t\\"}sort keys %{$Found{PRAGMA}}),
248 map ({"\t\$libdir/$_.3\t\\"}sort keys %{$Found{MODULE}}),