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");
195 for (@ARCHPODS) { s/$/.pod/ }
196 @ARCHPODS{@ARCHPODS} = ();
198 for (@pods) { s/$/.pod/ }
202 open(MANI, "../MANIFEST") || die "$0: opening ../MANIFEST failed: $!";
204 if (m!^pod/([^.]+\.pod)\s+!i) {
209 @MANIPODS{@MANIPODS} = ();
211 open(PERLPOD, "perl.pod") || die "$0: opening perl.pod failed: $!\n";
213 if (/^For ease of access, /../^\(If you're intending /) {
214 if (/^\s+(perl\S*)\s+\w/) {
215 push @PERLPODS, "$1.pod";
220 die "$0: could not find the pod listing of perl.pod\n"
222 @PERLPODS{@PERLPODS} = ();
224 # Cross-check against ourselves
225 # Cross-check against the MANIFEST
226 # Cross-check against the perl.pod
228 foreach my $i (sort keys %PODS) {
229 warn "$0: $i exists but is unknown by buildtoc\n"
230 unless exists $pods{$i};
231 warn "$0: $i exists but is unknown by ../MANIFEST\n"
232 if !exists $MANIPODS{$i} && !exists $ARCHPODS{$i};
233 warn "$0: $i exists but is unknown by perl.pod\n"
234 unless exists $PERLPODS{$i};
236 foreach my $i (sort keys %pods) {
237 warn "$0: $i is known by buildtoc but does not exist\n"
238 unless exists $PODS{$i};
240 foreach my $i (sort keys %MANIPODS) {
241 warn "$0: $i is known by ../MANIFEST but does not exist\n"
242 unless exists $PODS{$i};
244 foreach my $i (sort keys %PERLPODS) {
245 warn "$0: $i is known by perl.pod but does not exist\n"
246 unless exists $PODS{$i};
249 # We are ready to rock.
250 open(OUT, ">perltoc.pod") || die "$0: creating perltoc.pod failed: $!";
255 ($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
259 perltoc - perl documentation table of contents
263 This page provides a brief table of contents for the rest of the Perl
264 documentation set. It is meant to be scanned quickly or grepped
265 through to locate the proper section you're looking for.
267 =head1 BASIC DOCUMENTATION
274 find \&getpods => qw(../lib ../ext);
278 # Skip .pm files that have corresponding .pod files, and Functions.pm.
279 return if /(.*)\.pm$/ && -f "$1.pod";
280 my $file = $File::Find::name;
281 return if $file eq '../lib/Pod/Functions.pm'; # Used only by pod itself
283 die "tut $name" if $file =~ /TUT/;
284 unless (open (F, "< $_\0")) {
285 warn "bogus <$file>: $!";
286 system "ls", "-l", $file;
290 while ($line = <F>) {
291 if ($line =~ /^=head1\s+NAME\b/) {
292 push @modpods, $file;
293 #warn "GOOD $file\n";
297 warn "$0: $file: cannot find =head1 NAME\n";
302 die "no pods" unless @modpods;
305 #($name) = /(\w+)\.p(m|od)$/;
306 $name = path2modname($_);
307 if ($name =~ /^[a-z]/) {
310 if ($done{$name}++) {
311 # warn "already did $_\n";
315 push @modname, $name;
319 ($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
323 =head1 PRAGMA DOCUMENTATION
327 podset(sort @pragmata);
329 ($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
333 =head1 MODULE DOCUMENTATION
337 podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] );
339 ($_= <<EOPOD2B) =~ s/^\t//gm;
342 =head1 AUXILIARY DOCUMENTATION
344 Here should be listed all the extra programs' documentation, but they
345 don't all have manual pages yet:
371 Larry Wall <F<larry\@wall.org>>, with the help of oodles
377 output "\n"; # flush $LINE
384 if (s/^=head1 (NAME)\s*/=head2 /) {
385 $pod = path2modname($ARGV);
387 output "\n \n\n=head2 ";
389 if ( /^\s*$pod\b/ ) {
390 s/$pod\.pm/$pod/; # '.pm' in NAME !?
398 if (s/^=head1 (.*)/=item $1/) {
400 output "=over 4\n\n" unless $inhead1;
402 output $_; nl(); next;
404 if (s/^=head2 (.*)/=item $1/) {
406 output "=over 4\n\n" unless $inhead2;
408 output $_; nl(); next;
410 if (s/^=item ([^=].*)/$1/) {
411 next if $pod eq 'perldiag';
412 s/^\s*\*\s*$// && next;
417 next if $pod eq 'perlmodlib' && /^ftp:/;
418 ##print "=over 4\n\n" unless $initem;
419 output ", " if $initem;
425 if (s/^=cut\s*\n//) {
444 output "\n\n=back\n\n";
452 output "\n\n=back\n\n";
460 ##print "\n\n=back\n\n";
469 my $NEWLINE; # how many newlines have we seen recently
470 my $LINE; # what remains to be printed
473 for (split /(\n)/, shift) {
476 print OUT wrap('', '', $LINE);
484 elsif (/\S/ && length) {
493 close OUT or die "Can't close $file: $!";
494 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
495 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';