Commit | Line | Data |
---|---|---|
cb1a09d0 AD |
1 | use File::Find; |
2 | use Cwd; | |
8ebc5c01 | 3 | use Text::Wrap; |
cb1a09d0 | 4 | |
8ebc5c01 | 5 | sub output ($); |
6 | ||
7 | @pods = qw( | |
68dc0745 | 8 | perl perlfaq perlfaq1 perlfaq2 perlfaq3 perlfaq4 perlfaq5 |
9 | perlfaq6 perlfaq7 perlfaq8 perlfaq9 perldelta perldata | |
10 | perlsyn perlop perlre perlrun perlfunc perlvar perlsub | |
7766f137 | 11 | perlmod perlmodlib perlmodinstall perlfork perlform perllocale |
a1e2a320 | 12 | perlref perlreftut perldsc |
694468e3 | 13 | perllol perlboot perltoot perltootc perlobj perltie perlbot perlipc |
ac65edd0 | 14 | perldbmfilter perldebug perlnumber |
fb9cefb4 | 15 | perldiag perlsec perltrap perlport perlstyle perlpod perlbook |
54a137f5 | 16 | perlembed perlapio perlxs perlxstut perlguts perlcall perlcompile |
954c1994 | 17 | perlapi perlintern perlhist |
8ebc5c01 | 18 | ); |
19 | ||
20 | for (@pods) { s/$/.pod/ } | |
cb1a09d0 AD |
21 | |
22 | $/ = ''; | |
23 | @ARGV = @pods; | |
24 | ||
8ebc5c01 | 25 | ($_= <<EOPOD2B) =~ s/^\t//gm && output($_); |
cb1a09d0 AD |
26 | |
27 | =head1 NAME | |
28 | ||
29 | perltoc - perl documentation table of contents | |
30 | ||
31 | =head1 DESCRIPTION | |
32 | ||
8ebc5c01 | 33 | This page provides a brief table of contents for the rest of the Perl |
28757baa | 34 | documentation set. It is meant to be scanned quickly or grepped |
cb1a09d0 AD |
35 | through to locate the proper section you're looking for. |
36 | ||
37 | =head1 BASIC DOCUMENTATION | |
38 | ||
39 | EOPOD2B | |
8ebc5c01 | 40 | #' make emacs happy |
cb1a09d0 AD |
41 | |
42 | podset(@pods); | |
43 | ||
44 | find \&getpods => qw(../lib ../ext); | |
8ebc5c01 | 45 | |
cb1a09d0 | 46 | sub getpods { |
8ebc5c01 | 47 | if (/\.p(od|m)$/) { |
903a5071 | 48 | # Skip .pm files that have corresponding .pod files, and Functions.pm. |
8ebc5c01 | 49 | return if /(.*)\.pm$/ && -f "$1.pod"; |
cb1a09d0 | 50 | my $file = $File::Find::name; |
8ebc5c01 | 51 | return if $file eq '../lib/Pod/Functions.pm'; # Used only by pod itself |
52 | ||
cb1a09d0 AD |
53 | die "tut $name" if $file =~ /TUT/; |
54 | unless (open (F, "< $_\0")) { | |
55 | warn "bogus <$file>: $!"; | |
56 | system "ls", "-l", $file; | |
8ebc5c01 | 57 | } |
58 | else { | |
cb1a09d0 AD |
59 | my $line; |
60 | while ($line = <F>) { | |
61 | if ($line =~ /^=head1\s+NAME\b/) { | |
62 | push @modpods, $file; | |
63 | #warn "GOOD $file\n"; | |
64 | return; | |
8ebc5c01 | 65 | } |
66 | } | |
cb1a09d0 AD |
67 | warn "EVIL $file\n"; |
68 | } | |
69 | } | |
70 | } | |
71 | ||
72 | die "no pods" unless @modpods; | |
73 | ||
74 | for (@modpods) { | |
75 | #($name) = /(\w+)\.p(m|od)$/; | |
76 | $name = path2modname($_); | |
77 | if ($name =~ /^[a-z]/) { | |
78 | push @pragmata, $_; | |
79 | } else { | |
80 | if ($done{$name}++) { | |
81 | # warn "already did $_\n"; | |
82 | next; | |
8ebc5c01 | 83 | } |
cb1a09d0 AD |
84 | push @modules, $_; |
85 | push @modname, $name; | |
8ebc5c01 | 86 | } |
87 | } | |
88 | ||
89 | ($_= <<EOPOD2B) =~ s/^\t//gm && output($_); | |
cb1a09d0 | 90 | |
cb1a09d0 AD |
91 | |
92 | ||
93 | =head1 PRAGMA DOCUMENTATION | |
94 | ||
95 | EOPOD2B | |
96 | ||
97 | podset(sort @pragmata); | |
98 | ||
8ebc5c01 | 99 | ($_= <<EOPOD2B) =~ s/^\t//gm && output($_); |
100 | ||
cb1a09d0 AD |
101 | |
102 | ||
103 | =head1 MODULE DOCUMENTATION | |
104 | ||
105 | EOPOD2B | |
106 | ||
107 | podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] ); | |
108 | ||
109 | ($_= <<EOPOD2B) =~ s/^\t//gm; | |
8ebc5c01 | 110 | |
cb1a09d0 AD |
111 | |
112 | =head1 AUXILIARY DOCUMENTATION | |
113 | ||
8ebc5c01 | 114 | Here should be listed all the extra programs' documentation, but they |
115 | don't all have manual pages yet: | |
cb1a09d0 | 116 | |
a45bd81d GS |
117 | =over |
118 | ||
cb1a09d0 AD |
119 | =item a2p |
120 | ||
121 | =item s2p | |
122 | ||
123 | =item find2perl | |
8ebc5c01 | 124 | |
cb1a09d0 | 125 | =item h2ph |
8ebc5c01 | 126 | |
cb1a09d0 AD |
127 | =item c2ph |
128 | ||
129 | =item h2xs | |
130 | ||
131 | =item xsubpp | |
132 | ||
8ebc5c01 | 133 | =item pod2man |
cb1a09d0 AD |
134 | |
135 | =item wrapsuid | |
136 | ||
a45bd81d | 137 | =back |
cb1a09d0 AD |
138 | |
139 | =head1 AUTHOR | |
140 | ||
352854fa | 141 | Larry Wall <F<larry\@wall.org>>, with the help of oodles |
cb1a09d0 AD |
142 | of other folks. |
143 | ||
144 | ||
145 | EOPOD2B | |
8ebc5c01 | 146 | output $_; |
147 | output "\n"; # flush $LINE | |
cb1a09d0 AD |
148 | exit; |
149 | ||
150 | sub podset { | |
151 | local @ARGV = @_; | |
152 | ||
153 | while(<>) { | |
154 | if (s/^=head1 (NAME)\s*/=head2 /) { | |
155 | $pod = path2modname($ARGV); | |
a45bd81d | 156 | unhead1(); |
8ebc5c01 | 157 | output "\n \n\n=head2 "; |
cb1a09d0 AD |
158 | $_ = <>; |
159 | if ( /^\s*$pod\b/ ) { | |
8ebc5c01 | 160 | s/$pod\.pm/$pod/; # '.pm' in NAME !? |
161 | output $_; | |
cb1a09d0 AD |
162 | } else { |
163 | s/^/$pod, /; | |
8ebc5c01 | 164 | output $_; |
165 | } | |
cb1a09d0 AD |
166 | next; |
167 | } | |
168 | if (s/^=head1 (.*)/=item $1/) { | |
a45bd81d GS |
169 | unhead2(); |
170 | output "=over\n\n" unless $inhead1; | |
171 | $inhead1 = 1; | |
8ebc5c01 | 172 | output $_; nl(); next; |
173 | } | |
cb1a09d0 AD |
174 | if (s/^=head2 (.*)/=item $1/) { |
175 | unitem(); | |
8ebc5c01 | 176 | output "=over\n\n" unless $inhead2; |
cb1a09d0 | 177 | $inhead2 = 1; |
8ebc5c01 | 178 | output $_; nl(); next; |
8ebc5c01 | 179 | } |
d516a115 | 180 | if (s/^=item ([^=].*)\n/$1/) { |
cb1a09d0 AD |
181 | next if $pod eq 'perldiag'; |
182 | s/^\s*\*\s*$// && next; | |
183 | s/^\s*\*\s*//; | |
184 | s/\s+$//; | |
185 | next if /^[\d.]+$/; | |
f102b883 | 186 | next if $pod eq 'perlmodlib' && /^ftp:/; |
cb1a09d0 | 187 | ##print "=over\n\n" unless $initem; |
8ebc5c01 | 188 | output ", " if $initem; |
cb1a09d0 AD |
189 | $initem = 1; |
190 | s/\.$//; | |
8ebc5c01 | 191 | s/^-X\b/-I<X>/; |
192 | output $_; next; | |
193 | } | |
a45bd81d GS |
194 | if (s/^=cut\s*\n//) { |
195 | unhead1(); | |
196 | next; | |
197 | } | |
8ebc5c01 | 198 | } |
199 | } | |
cb1a09d0 | 200 | |
8ebc5c01 | 201 | sub path2modname { |
202 | local $_ = shift; | |
203 | s/\.p(m|od)$//; | |
204 | s-.*?/(lib|ext)/--; | |
205 | s-/-::-g; | |
206 | s/(\w+)::\1/$1/; | |
207 | return $_; | |
208 | } | |
cb1a09d0 | 209 | |
a45bd81d GS |
210 | sub unhead1 { |
211 | unhead2(); | |
212 | if ($inhead1) { | |
213 | output "\n\n=back\n\n"; | |
214 | } | |
215 | $inhead1 = 0; | |
216 | } | |
217 | ||
cb1a09d0 | 218 | sub unhead2 { |
a45bd81d | 219 | unitem(); |
cb1a09d0 | 220 | if ($inhead2) { |
8ebc5c01 | 221 | output "\n\n=back\n\n"; |
222 | } | |
223 | $inhead2 = 0; | |
8ebc5c01 | 224 | } |
cb1a09d0 AD |
225 | |
226 | sub unitem { | |
227 | if ($initem) { | |
8ebc5c01 | 228 | output "\n\n"; |
cb1a09d0 | 229 | ##print "\n\n=back\n\n"; |
8ebc5c01 | 230 | } |
cb1a09d0 | 231 | $initem = 0; |
8ebc5c01 | 232 | } |
cb1a09d0 AD |
233 | |
234 | sub nl { | |
8ebc5c01 | 235 | output "\n"; |
236 | } | |
237 | ||
238 | my $NEWLINE; # how many newlines have we seen recently | |
239 | my $LINE; # what remains to be printed | |
240 | ||
241 | sub output ($) { | |
242 | for (split /(\n)/, shift) { | |
243 | if ($_ eq "\n") { | |
244 | if ($LINE) { | |
245 | print wrap('', '', $LINE); | |
246 | $LINE = ''; | |
247 | } | |
248 | if ($NEWLINE < 2) { | |
249 | print; | |
250 | $NEWLINE++; | |
251 | } | |
252 | } | |
253 | elsif (/\S/ && length) { | |
254 | $LINE .= $_; | |
255 | $NEWLINE = 0; | |
256 | } | |
257 | } | |
258 | } |