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, sub { warn @_ if @_ }, 'pod/perltoc.pod');
26 # Find all the modules
31 return if m!/Pod/Functions.pm\z!; # Used only by pod itself
32 return if m!(?:^|/)t/!;
33 return if m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-)
34 return if m!XS/(?:APItest|Typemap)!;
35 return if s!pm\z!pod! && -e $_;
39 my_die("Duplicate files for $_, '$done{$_}' and '$File::Find::name'")
42 $done{$_} = $File::Find::name;
43 $Found{/\A[a-z]/ ? 'PRAGMA' : 'MODULE'}{$_} = $File::Find::name;
47 my_die "Can't find any pods!\n" unless %done;
49 # Accumulating everything into a lexical before writing to disk dates from the
50 # time when this script also provided the functionality of regen/pod_rules.pl
51 # and this code was in a subroutine do_toc(). In turn, the use of a file scoped
52 # lexical instead of a parameter or return value is because the code dates back
53 # further still, and used *only* to create pod/perltoc.pod by printing direct
58 ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
60 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
61 # This file is autogenerated by buildtoc from all the other pods.
62 # Edit those files and run $0 to effect changes.
66 perltoc - perl documentation table of contents
70 This page provides a brief table of contents for the rest of the Perl
71 documentation set. It is meant to be scanned quickly or grepped
72 through to locate the proper section you're looking for.
74 =head1 BASIC DOCUMENTATION
78 # All the things in the master list that happen to be pod filenames
79 foreach (grep {!$_->[2]{toc_omit}} @{$state->{master}}) {
80 $roffitall .= " \$mandir/$_->[0].1 \\\n";
81 podset($_->[0], $_->[1]);
84 foreach my $type (qw(PRAGMA MODULE)) {
85 ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
89 =head1 $type DOCUMENTATION
93 foreach my $name (sort keys %{$Found{$type}}) {
94 next if is_duplicate_pod($Found{$type}{$name});
95 $roffitall .= " \$libdir/$name.3 \\\n";
96 podset($name, $Found{$type}{$name});
103 =head1 AUXILIARY DOCUMENTATION
105 Here should be listed all the extra programs' documentation, but they
106 don't all have manual pages yet:
112 $_ .= join "\n", map {"\t=item $_\n"} @{$state->{aux}};
119 Larry Wall <F<larry\@wall.org>>, with the help of oodles
128 $OUT =~ s/\n\s+\n/\n\n/gs;
129 $OUT =~ s/\n{3,}/\n\n/g;
131 $OUT =~ s/([^\n]+)/wrap('', '', $1)/ge;
133 write_or_die('pod/perltoc.pod', $OUT);
135 write_or_die('pod/roffitall', <<'EOH' . $roffitall . <<'EOT');
138 # Usage: roffitall [-nroff|-psroff|-groff]
140 # Authors: Tom Christiansen, Raphael Manfredi
145 if test -f ../config.sh; then
149 mandir=$installman1dir
150 libdir=$installman3dir
152 test -d $mandir || mandir=/usr/new/man/man1
153 test -d $libdir || libdir=/usr/new/man/man3
156 -nroff) cmd="nroff -man"; ext='txt';;
157 -psroff) cmd="psroff -t"; ext='ps';;
158 -groff) cmd="groff -man"; ext='ps';;
160 echo "Usage: roffitall [-nroff|-psroff|-groff]" >&2
168 | perl -ne 'map { -r && print "$_ " } split'`
170 # Bypass internal shell buffer limit -- can't use case
171 if perl -e '$a = shift; exit($a =~ m|/|)' $toroff; then
172 echo "$me: empty file list -- did you run install?" >&2
176 #psroff -t -man -rC1 -rD1 -rF1 > $tmp/PerlDoc.ps 2>$tmp/PerlTOC.raw
177 #nroff -man -rC1 -rD1 -rF1 > $tmp/PerlDoc.txt 2>$tmp/PerlTOC.nr.raw
179 # First, create the raw data
180 run="$cmd -rC1 -rD1 -rF1 >$tmp/PerlDoc.$ext 2>$tmp/PerlTOC.$ext.raw"
181 echo "$me: running $run"
185 echo "$me: parsing TOC"
186 perl rofftoc $tmp/PerlTOC.$ext.raw > $tmp/PerlTOC.tmp.man
187 run="$cmd $tmp/PerlTOC.tmp.man >$tmp/PerlTOC.$ext"
188 echo "$me: running $run"
191 # Finally, recreate the Doc, without the blank page 0
192 run="$cmd -rC1 -rD1 >$tmp/PerlDoc.$ext 2>$tmp/PerlTOC.$ext.raw"
193 echo "$me: running $run"
195 rm -f $tmp/PerlTOC.tmp.man $tmp/PerlTOC.$ext.raw
196 echo "$me: leaving you with $tmp/PerlDoc.$ext and $tmp/PerlTOC.$ext"
201 # Below are all the auxiliary routines for generating perltoc.pod
203 my ($inhead1, $inhead2, $initem);
206 my ($pod, $file) = @_;
208 open my $fh, '<', $file or my_die "Can't open file '$file' for $pod: $!";
213 if (/^=head1\s+NAME\b/) {
219 unless ($found_pod) {
220 warn "$0: NOTE: cannot find '=head1 NAME' in:\n $file\n" unless $Quiet;
224 seek $fh, 0, 0 or my_die "Can't rewind file '$file': $!";
229 if (s/^=head1 (NAME)\s*/=head2 /) {
231 $OUT .= "\n\n=head2 ";
233 # Remove svn keyword expansions from the Perl FAQ
234 s/ \(\$Revision: \d+ \$\)//g;
235 if ( /^\s*\Q$pod\E\b/ ) {
236 s/$pod\.pm/$pod/; # '.pm' in NAME !?
241 elsif (s/^=head1 (.*)/=item $1/) {
243 $OUT .= "=over 4\n\n" unless $inhead1;
247 elsif (s/^=head2 (.*)/=item $1/) {
249 $OUT .= "=over 4\n\n" unless $inhead2;
253 elsif (s/^=item ([^=].*)/$1/) {
254 next if $pod eq 'perldiag';
255 s/^\s*\*\s*$// && next;
260 next if $pod eq 'perlmodlib' && /^ftp:/;
261 $OUT .= ", " if $initem;
267 unhead1() if /^=cut\s*\n/;
277 $OUT .= "\n\n=back\n\n";
285 $OUT .= "\n\n=back\n\n";
298 # cperl-indent-level: 4
299 # indent-tabs-mode: nil
302 # ex: set ts=8 sts=4 sw=4 et: