4 use File::Basename qw(&basename &dirname);
7 # List explicitly here the variables you want Configure to
8 # generate. Metaconfig only looks for shell variables, so you
9 # have to mention them as if they were shell variables, not
10 # %Config entries. Thus you write
12 # to ensure Configure will look for $Config{startperl}.
14 # This forces PL files to create target in same directory as PL file.
15 # This is so that make depend always knows where to find PL derivatives.
18 ($file = basename($0)) =~ s/\.PL$//;
19 $file =~ s/\.pl$// if ($^O eq 'os2' or $^O eq 'dos'); # "case-forgiving"
20 $file =~ s/\.pl$/.com/ if ($^O eq 'VMS'); # "case-forgiving"
22 open OUT,">$file" or die "Can't create $file: $!";
24 print "Extracting $file (with variable substitutions)\n";
26 # In this section, perl variables will be expanded during extraction.
27 # You can use $Config{...} to use Configure variables.
29 print OUT <<"!GROK!THIS!";
31 eval 'exec perl -S \$0 "\$@"'
35 # In the following, perl variables are not expanded during extraction.
37 print OUT <<'!NO!SUBS!';
42 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
43 # This file is autogenerated by buildtoc.PL.
44 # Edit that file and run it to effect changes.
46 # Builds perltoc.pod and sanity checks the list of pods against all
47 # of the MANIFEST, perl.pod, and ourselves.
54 @PODS = glob("*.pod");
59 die "$0: failed to chdir('pod'): $!\n" unless chdir("pod");
225 for (@ARCHPODS) { s/$/.pod/ }
226 @ARCHPODS{@ARCHPODS} = ();
228 for (@CJKPODS) { s/$/.pod/ }
229 @CJKPODS{@CJKPODS} = ();
231 for (@pods) { s/$/.pod/ }
235 open(MANI, "../MANIFEST") || die "$0: opening ../MANIFEST failed: $!";
237 if (m!^pod/([^.]+\.pod)\s+!i) {
242 @MANIPODS{@MANIPODS} = ();
244 open(PERLPOD, "perl.pod") || die "$0: opening perl.pod failed: $!\n";
246 if (/^For ease of access, /../^\(If you're intending /) {
247 if (/^\s+(perl\S*)\s+\w/) {
248 push @PERLPODS, "$1.pod";
253 die "$0: could not find the pod listing of perl.pod\n"
255 @PERLPODS{@PERLPODS} = ();
257 # Delete the CJK because we cannot mix their encodings.
258 delete @PERLPODS{@CJKPODS};
259 delete @PODS{@CJKPODS};
260 delete @pods{@CJKPODS};
262 # Cross-check against ourselves
263 # Cross-check against the MANIFEST
264 # Cross-check against the perl.pod
266 foreach my $i (sort keys %PODS) {
267 warn "$0: $i exists but is unknown by buildtoc\n"
268 unless exists $pods{$i};
269 warn "$0: $i exists but is unknown by ../MANIFEST\n"
270 if !exists $MANIPODS{$i} && !exists $ARCHPODS{$i} && !exists $CJKPODS{$i};
271 warn "$0: $i exists but is unknown by perl.pod\n"
272 unless exists $PERLPODS{$i};
274 foreach my $i (sort keys %pods) {
275 warn "$0: $i is known by buildtoc but does not exist\n"
276 unless exists $PODS{$i};
278 foreach my $i (sort keys %MANIPODS) {
279 warn "$0: $i is known by ../MANIFEST but does not exist\n"
280 unless exists $PODS{$i};
282 foreach my $i (sort keys %PERLPODS) {
283 warn "$0: $i is known by perl.pod but does not exist\n"
284 unless exists $PODS{$i};
287 # We are ready to rock.
288 open(OUT, ">perltoc.pod") || die "$0: creating perltoc.pod failed: $!";
293 ($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
297 perltoc - perl documentation table of contents
301 This page provides a brief table of contents for the rest of the Perl
302 documentation set. It is meant to be scanned quickly or grepped
303 through to locate the proper section you're looking for.
305 =head1 BASIC DOCUMENTATION
312 find \&getpods => qw(../lib ../ext);
316 my $file = $File::Find::name;
317 return if $file eq '../lib/Pod/Functions.pm'; # Used only by pod itself
318 return if $file =~ m!(?:^|/)t/!;
319 return if $file =~ m!lib/Attribute/Handlers/demo/!;
320 return if $file =~ m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-)
321 return if $file =~ m!lib/Math/BigInt/t/!;
322 return if $file =~ m!/Devel/PPPort/[Hh]arness|lib/Devel/Harness!i;
323 return if $file =~ m!XS/(?:APItest|Typemap)!;
324 die "tut $name" if $file =~ /TUT/;
325 unless (open (F, "< $_\0")) {
326 warn "bogus <$file>: $!";
327 system "ls", "-l", $file;
331 while ($line = <F>) {
332 if ($line =~ /^=head1\s+NAME\b/) {
333 push @modpods, $file;
334 #warn "GOOD $file\n";
338 warn "$0: $file: cannot find =head1 NAME\n";
343 die "no pods" unless @modpods;
346 #($name) = /(\w+)\.p(m|od)$/;
347 $name = path2modname($_);
348 if ($name =~ /^[a-z]/) {
351 if ($done{$name}++) {
352 # warn "already did $_\n";
356 push @modname, $name;
360 ($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
364 =head1 PRAGMA DOCUMENTATION
368 podset(sort @pragmata);
370 ($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
374 =head1 MODULE DOCUMENTATION
378 podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] );
380 ($_= <<EOPOD2B) =~ s/^\t//gm;
383 =head1 AUXILIARY DOCUMENTATION
385 Here should be listed all the extra programs' documentation, but they
386 don't all have manual pages yet:
412 Larry Wall <F<larry\@wall.org>>, with the help of oodles
418 output "\n"; # flush $LINE
425 if (s/^=head1 (NAME)\s*/=head2 /) {
426 $pod = path2modname($ARGV);
428 output "\n \n\n=head2 ";
430 if ( /^\s*$pod\b/ ) {
431 s/$pod\.pm/$pod/; # '.pm' in NAME !?
439 if (s/^=head1 (.*)/=item $1/) {
441 output "=over 4\n\n" unless $inhead1;
443 output $_; nl(); next;
445 if (s/^=head2 (.*)/=item $1/) {
447 output "=over 4\n\n" unless $inhead2;
449 output $_; nl(); next;
451 if (s/^=item ([^=].*)/$1/) {
452 next if $pod eq 'perldiag';
453 s/^\s*\*\s*$// && next;
458 next if $pod eq 'perlmodlib' && /^ftp:/;
459 ##print "=over 4\n\n" unless $initem;
460 output ", " if $initem;
466 if (s/^=cut\s*\n//) {
485 output "\n\n=back\n\n";
493 output "\n\n=back\n\n";
501 ##print "\n\n=back\n\n";
510 my $NEWLINE; # how many newlines have we seen recently
511 my $LINE; # what remains to be printed
514 for (split /(\n)/, shift) {
517 print OUT wrap('', '', $LINE);
525 elsif (/\S/ && length) {
534 close OUT or die "Can't close $file: $!";
535 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
536 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';