Typos in perl571delta.pod
[p5sagit/p5-mst-13.2.git] / pod / buildtoc.PL
CommitLineData
4755096e 1#!/usr/local/bin/perl
2
3use Config;
4use File::Basename qw(&basename &dirname);
5use Cwd;
6
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
11# $startperl
12# to ensure Configure will look for $Config{startperl}.
13
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.
16$origdir = cwd;
17chdir(dirname($0));
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"
21
22open OUT,">$file" or die "Can't create $file: $!";
23
24print "Extracting $file (with variable substitutions)\n";
25
26# In this section, perl variables will be expanded during extraction.
27# You can use $Config{...} to use Configure variables.
28
29print OUT <<"!GROK!THIS!";
30$Config{'startperl'}
31 eval 'exec perl -S \$0 "\$@"'
32 if 0;
33!GROK!THIS!
34
35# In the following, perl variables are not expanded during extraction.
36
37print OUT <<'!NO!SUBS!';
38
39#
40# buildtoc
41#
42# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
43# This file is autogenerated by buildtoc.PL.
44# Edit that file and run it to effect changes.
45#
46# Builds perltoc.pod and sanity checks the list of pods against all
47# of the MANIFEST, perl.pod, and ourselves.
48#
49
50use File::Find;
51use Cwd;
52use Text::Wrap;
53
54@PODS = glob("*.pod");
55
56sub output ($);
57
58if (-d "pod") {
59 die "$0: failed to chdir('pod'): $!\n" unless chdir("pod");
60}
61
62@pods = qw(
c2e66d9e 63 perl
64 perlfaq
65 perltoc
66 perlbook
67
68 perlsyn
69 perldata
70 perlop
71 perlsub
72 perlfunc
73 perlreftut
74 perldsc
75 perlrequick
76 perlpod
77 perlstyle
78 perltrap
79
80 perlrun
81 perldiag
82 perllexwarn
10862624 83 perldebtut
c2e66d9e 84 perldebug
85
86 perlvar
87 perllol
88 perlopentut
89 perlretut
90
c2e66d9e 91 perlre
d396a558 92 perlref
93
c2e66d9e 94 perlform
d396a558 95
96 perlboot
97 perltoot
98 perltootc
99 perlobj
100 perlbot
101 perltie
c2e66d9e 102
103 perlipc
104 perlfork
105 perlnumber
106 perlthrtut
107
108 perlport
d396a558 109 perllocale
110 perlunicode
111 perlebcdic
c2e66d9e 112
d396a558 113 perlsec
c2e66d9e 114
115 perlmod
116 perlmodlib
117 perlmodinstall
118 perlnewmod
119
4755096e 120 perlfaq1
121 perlfaq2
122 perlfaq3
123 perlfaq4
124 perlfaq5
125 perlfaq6
126 perlfaq7
127 perlfaq8
128 perlfaq9
129
130 perlcompile
131
132 perlembed
133 perldebguts
134 perlxstut
135 perlxs
f40a6c71 136 perlclib
4755096e 137 perlguts
138 perlcall
139 perlutil
140 perlfilter
141 perldbmfilter
142 perlapi
143 perlintern
dc5c060f 144 perliol
4755096e 145 perlapio
146 perltodo
147 perlhack
148
149 perlhist
150 perldelta
1db9e106 151 perl571delta
152 perl570delta
4755096e 153 perl56delta
154 perl5005delta
155 perl5004delta
156
37d4d706 157 perlaix
4755096e 158 perlamiga
dc5c060f 159 perlbs2000
4755096e 160 perlcygwin
161 perldos
9a997319 162 perlepoc
4755096e 163 perlhpux
164 perlmachten
26d9b02f 165 perlmacos
ab648d5e 166 perlmpeix
4755096e 167 perlos2
168 perlos390
d420ca49 169 perlsolaris
dc5c060f 170 perlvmesa
4755096e 171 perlvms
9a997319 172 perlvos
4755096e 173 perlwin32
174 );
175
176@ARCHPODS = qw(
37d4d706 177 perlaix
4755096e 178 perlamiga
dc5c060f 179 perlbs2000
4755096e 180 perlcygwin
181 perldos
9a997319 182 perlepoc
4755096e 183 perlhpux
184 perlmachten
26d9b02f 185 perlmacos
ab648d5e 186 perlmpeix
4755096e 187 perlos2
188 perlos390
d420ca49 189 perlsolaris
dc5c060f 190 perlvmesa
4755096e 191 perlvms
9a997319 192 perlvos
4755096e 193 perlwin32
194 );
195for (@ARCHPODS) { s/$/.pod/ }
196@ARCHPODS{@ARCHPODS} = ();
197
198for (@pods) { s/$/.pod/ }
199@pods{@pods} = ();
200@PODS{@PODS} = ();
201
202open(MANI, "../MANIFEST") || die "$0: opening ../MANIFEST failed: $!";
203while (<MANI>) {
204 if (m!^pod/([^.]+\.pod)\s+!i) {
205 push @MANIPODS, $1;
206 }
207}
208close(MANI);
209@MANIPODS{@MANIPODS} = ();
210
211open(PERLPOD, "perl.pod") || die "$0: opening perl.pod failed: $!\n";
212while (<PERLPOD>) {
213 if (/^For ease of access, /../^\(If you're intending /) {
c2e66d9e 214 if (/^\s+(perl\S*)\s+\w/) {
4755096e 215 push @PERLPODS, "$1.pod";
216 }
217 }
218}
219close(PERLPOD);
220die "$0: could not find the pod listing of perl.pod\n"
221 unless @PERLPODS;
222@PERLPODS{@PERLPODS} = ();
223
224# Cross-check against ourselves
225# Cross-check against the MANIFEST
226# Cross-check against the perl.pod
227
228foreach 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};
235}
236foreach my $i (sort keys %pods) {
237 warn "$0: $i is known by buildtoc but does not exist\n"
238 unless exists $PODS{$i};
239}
240foreach my $i (sort keys %MANIPODS) {
241 warn "$0: $i is known by ../MANIFEST but does not exist\n"
242 unless exists $PODS{$i};
243}
244foreach my $i (sort keys %PERLPODS) {
245 warn "$0: $i is known by perl.pod but does not exist\n"
246 unless exists $PODS{$i};
247}
248
249# We are ready to rock.
250open(OUT, ">perltoc.pod") || die "$0: creating perltoc.pod failed: $!";
251
252$/ = '';
253@ARGV = @pods;
254
255($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
256
257 =head1 NAME
258
259 perltoc - perl documentation table of contents
260
261 =head1 DESCRIPTION
262
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.
266
267 =head1 BASIC DOCUMENTATION
268
269EOPOD2B
270#' make emacs happy
271
272podset(@pods);
273
274find \&getpods => qw(../lib ../ext);
275
276sub getpods {
277 if (/\.p(od|m)$/) {
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
282
283 die "tut $name" if $file =~ /TUT/;
284 unless (open (F, "< $_\0")) {
285 warn "bogus <$file>: $!";
286 system "ls", "-l", $file;
287 }
288 else {
289 my $line;
290 while ($line = <F>) {
291 if ($line =~ /^=head1\s+NAME\b/) {
292 push @modpods, $file;
293 #warn "GOOD $file\n";
294 return;
295 }
296 }
297 warn "$0: $file: cannot find =head1 NAME\n";
298 }
299 }
300}
301
302die "no pods" unless @modpods;
303
304for (@modpods) {
305 #($name) = /(\w+)\.p(m|od)$/;
306 $name = path2modname($_);
307 if ($name =~ /^[a-z]/) {
308 push @pragmata, $_;
309 } else {
310 if ($done{$name}++) {
311 # warn "already did $_\n";
312 next;
313 }
314 push @modules, $_;
315 push @modname, $name;
316 }
317}
318
319($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
320
321
322
323 =head1 PRAGMA DOCUMENTATION
324
325EOPOD2B
326
327podset(sort @pragmata);
328
329($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
330
331
332
333 =head1 MODULE DOCUMENTATION
334
335EOPOD2B
336
337podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] );
338
339($_= <<EOPOD2B) =~ s/^\t//gm;
340
341
342 =head1 AUXILIARY DOCUMENTATION
343
344 Here should be listed all the extra programs' documentation, but they
345 don't all have manual pages yet:
346
13a2d996 347 =over 4
4755096e 348
349 =item a2p
350
351 =item s2p
352
353 =item find2perl
354
355 =item h2ph
356
357 =item c2ph
358
359 =item h2xs
360
361 =item xsubpp
362
363 =item pod2man
364
365 =item wrapsuid
366
367 =back
368
369 =head1 AUTHOR
370
371 Larry Wall <F<larry\@wall.org>>, with the help of oodles
372 of other folks.
373
374
375EOPOD2B
376output $_;
377output "\n"; # flush $LINE
378exit;
379
380sub podset {
381 local @ARGV = @_;
382
383 while(<>) {
384 if (s/^=head1 (NAME)\s*/=head2 /) {
385 $pod = path2modname($ARGV);
386 unhead1();
387 output "\n \n\n=head2 ";
388 $_ = <>;
389 if ( /^\s*$pod\b/ ) {
390 s/$pod\.pm/$pod/; # '.pm' in NAME !?
391 output $_;
392 } else {
393 s/^/$pod, /;
394 output $_;
395 }
396 next;
397 }
398 if (s/^=head1 (.*)/=item $1/) {
399 unhead2();
13a2d996 400 output "=over 4\n\n" unless $inhead1;
4755096e 401 $inhead1 = 1;
402 output $_; nl(); next;
403 }
404 if (s/^=head2 (.*)/=item $1/) {
405 unitem();
13a2d996 406 output "=over 4\n\n" unless $inhead2;
4755096e 407 $inhead2 = 1;
408 output $_; nl(); next;
409 }
410 if (s/^=item ([^=].*)/$1/) {
411 next if $pod eq 'perldiag';
412 s/^\s*\*\s*$// && next;
413 s/^\s*\*\s*//;
414 s/\n/ /g;
415 s/\s+$//;
416 next if /^[\d.]+$/;
417 next if $pod eq 'perlmodlib' && /^ftp:/;
13a2d996 418 ##print "=over 4\n\n" unless $initem;
4755096e 419 output ", " if $initem;
420 $initem = 1;
421 s/\.$//;
422 s/^-X\b/-I<X>/;
423 output $_; next;
424 }
425 if (s/^=cut\s*\n//) {
426 unhead1();
427 next;
428 }
429 }
430}
431
432sub path2modname {
433 local $_ = shift;
434 s/\.p(m|od)$//;
435 s-.*?/(lib|ext)/--;
436 s-/-::-g;
437 s/(\w+)::\1/$1/;
438 return $_;
439}
440
441sub unhead1 {
442 unhead2();
443 if ($inhead1) {
444 output "\n\n=back\n\n";
445 }
446 $inhead1 = 0;
447}
448
449sub unhead2 {
450 unitem();
451 if ($inhead2) {
452 output "\n\n=back\n\n";
453 }
454 $inhead2 = 0;
455}
456
457sub unitem {
458 if ($initem) {
459 output "\n\n";
460 ##print "\n\n=back\n\n";
461 }
462 $initem = 0;
463}
464
465sub nl {
466 output "\n";
467}
468
469my $NEWLINE; # how many newlines have we seen recently
470my $LINE; # what remains to be printed
471
472sub output ($) {
473 for (split /(\n)/, shift) {
474 if ($_ eq "\n") {
475 if ($LINE) {
476 print OUT wrap('', '', $LINE);
477 $LINE = '';
478 }
479 if ($NEWLINE < 2) {
480 print OUT;
481 $NEWLINE++;
482 }
483 }
484 elsif (/\S/ && length) {
485 $LINE .= $_;
486 $NEWLINE = 0;
487 }
488 }
489}
490
491!NO!SUBS!
492
6bbf1b34 493close OUT or die "Can't close $file: $!";
494chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
495exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
496chdir $origdir;