X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fbuildtoc;h=bd880c379d62318629a5dd03eb548b6c2cd922a5;hb=9c4d0f167fb7643c3ff9ccfd4b79b6aeb9763e43;hp=daf26c1c57c74996f3b99f80867f4ea089d5c7a1;hpb=55497cffdd24c959994f9a8ddd56db8ce85e1c5b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/buildtoc b/pod/buildtoc index daf26c1..bd880c3 100644 --- a/pod/buildtoc +++ b/pod/buildtoc @@ -1,21 +1,26 @@ use File::Find; use Cwd; +use Text::Wrap; -@pods = qw{ - perl - perldata perlsyn perlop perlre perlrun perlfunc perlvar - perlsub perlmod perlform - perlref perldsc perllol perlobj perltie perlbot perlipc - perldebug perldiag perlsec perltrap perlstyle - perlpod perlbook - perlembed perlapio perlxs perlxstut perlguts perlcall - }; -for (@pods) { s/$/.pod/ } +sub output ($); + +@pods = qw( + perl perlfaq perlfaq1 perlfaq2 perlfaq3 perlfaq4 perlfaq5 + perlfaq6 perlfaq7 perlfaq8 perlfaq9 perldelta perldata + perlsyn perlop perlre perlrun perlfunc perlvar perlsub + perlmod perlmodlib perlform perllocale perlref perldsc + perllol perltoot perlobj perltie perlbot perlipc perldebug + perldiag perlsec perltrap perlstyle perlpod perlbook + perlembed perlapio perlxs perlxstut perlguts perlcall + perlhist + ); + +for (@pods) { s/$/.pod/ } $/ = ''; @ARGV = @pods; -($_= < qw(../lib ../ext); + sub getpods { - if (/\.p(od|m)$/) { - my $tmp; + if (/\.p(od|m)$/) { # Skip .pm files that have corresponding .pod files, and Functions.pm. - return if (($tmp = $_) =~ s/\.pm$/.pod/ && -f $tmp); - return if ($_ eq '../lib/Pod/Functions.pm');####Used only by pod itself - + return if /(.*)\.pm$/ && -f "$1.pod"; my $file = $File::Find::name; + return if $file eq '../lib/Pod/Functions.pm'; # Used only by pod itself + die "tut $name" if $file =~ /TUT/; unless (open (F, "< $_\0")) { warn "bogus <$file>: $!"; system "ls", "-l", $file; - } else { + } + else { my $line; while ($line = ) { if ($line =~ /^=head1\s+NAME\b/) { push @modpods, $file; #warn "GOOD $file\n"; return; - } - } + } + } warn "EVIL $file\n"; } } @@ -71,14 +78,14 @@ for (@modpods) { if ($done{$name}++) { # warn "already did $_\n"; next; - } + } push @modules, $_; push @modname, $name; - } -} + } +} + +($_= <FE, with the help of oodles + Larry Wall >, with the help of oodles of other folks. EOPOD2B -print; - +output $_; +output "\n"; # flush $LINE exit; sub podset { @@ -141,69 +148,94 @@ sub podset { while(<>) { if (s/^=head1 (NAME)\s*/=head2 /) { $pod = path2modname($ARGV); - sub path2modname { - local $_ = shift; - s/\.p(m|od)$//; - s-.*?/(lib|ext)/--; - s-/-::-g; - s/(\w+)::\1/$1/; - return $_; - } - unitem(); unhead2(); - print "\n \n\n=head2 "; + unitem(); + unhead2(); + output "\n \n\n=head2 "; $_ = <>; if ( /^\s*$pod\b/ ) { - print; + s/$pod\.pm/$pod/; # '.pm' in NAME !? + output $_; } else { s/^/$pod, /; - print; - } + output $_; + } next; } if (s/^=head1 (.*)/=item $1/) { unitem(); unhead2(); - print; nl(); next; - } + output $_; nl(); next; + } if (s/^=head2 (.*)/=item $1/) { unitem(); - print "=over\n\n" unless $inhead2; + output "=over\n\n" unless $inhead2; $inhead2 = 1; - print; nl(); next; + output $_; nl(); next; - } - if (s/^=item (.*)\n/$1/) { + } + if (s/^=item ([^=].*)\n/$1/) { next if $pod eq 'perldiag'; s/^\s*\*\s*$// && next; s/^\s*\*\s*//; s/\s+$//; next if /^[\d.]+$/; - next if $pod eq 'perlmod' && /^ftp:/; + next if $pod eq 'perlmodlib' && /^ftp:/; ##print "=over\n\n" unless $initem; - print ", " if $initem; + output ", " if $initem; $initem = 1; s/\.$//; - print; next; - } - } + s/^-X\b/-I/; + output $_; next; + } + } +} -} +sub path2modname { + local $_ = shift; + s/\.p(m|od)$//; + s-.*?/(lib|ext)/--; + s-/-::-g; + s/(\w+)::\1/$1/; + return $_; +} sub unhead2 { if ($inhead2) { - print "\n\n=back\n\n"; - } - $inhead2 = 0; - $initem = 0; -} + output "\n\n=back\n\n"; + } + $inhead2 = 0; + $initem = 0; +} sub unitem { if ($initem) { - print "\n\n"; + output "\n\n"; ##print "\n\n=back\n\n"; - } + } $initem = 0; -} +} sub nl { - print "\n"; -} + output "\n"; +} + +my $NEWLINE; # how many newlines have we seen recently +my $LINE; # what remains to be printed + +sub output ($) { + for (split /(\n)/, shift) { + if ($_ eq "\n") { + if ($LINE) { + print wrap('', '', $LINE); + $LINE = ''; + } + if ($NEWLINE < 2) { + print; + $NEWLINE++; + } + } + elsif (/\S/ && length) { + $LINE .= $_; + $NEWLINE = 0; + } + } +}