summaryrefslogtreecommitdiff
path: root/pod/buildtoc
blob: 9ca5e920fdf9d2d33cf8e63d19c92e11c604bf26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
use File::Find;
use Cwd;

@pods = qw{
	    perl perldata perlsyn perlop perlre perlrun perlfunc perlvar
	    perlsub perlmod perlref perldsc perllol perlobj perltie
	    perlbot perldebug perldiag perlform perlipc perlsec perltrap
	    perlstyle perlxs perlxstut perlguts perlcall perlembed perlpod
	    perlbook 
	};
for (@pods) { s/$/.pod/ } 

$/ = '';
@ARGV = @pods;

($_= <<EOPOD2B) =~ s/^\t//gm && print;

	=head1 NAME

	perltoc - perl documentation table of contents

	=head1 DESCRIPTION

	This page provides a brief table of contents for the rest of the Perl 
	documentation set.  It is meant to be be quickly scanned or grepped 
	through to locate the proper section you're looking for.

	=head1 BASIC DOCUMENTATION

EOPOD2B

podset(@pods);

find \&getpods => qw(../lib ../ext);
sub getpods {
    if (/\.p(od|m)$/) { 
	my $tmp;
	# 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

	my $file = $File::Find::name;
	die "tut $name" if $file =~ /TUT/;
	unless (open (F, "< $_\0")) {
	    warn "bogus <$file>: $!";
	    system "ls", "-l", $file;
	}  else { 
	    my $line;
	    while ($line = <F>) {
		if ($line =~ /^=head1\s+NAME\b/) {
		    push @modpods, $file;
		    #warn "GOOD $file\n";
		    return;
		} 
	    } 
	    warn "EVIL $file\n";
	}
    }
}

die "no pods" unless @modpods;

for (@modpods) {
    #($name) = /(\w+)\.p(m|od)$/;
    $name = path2modname($_);
    if ($name =~ /^[a-z]/) {
	push @pragmata, $_;
    } else {
	if ($done{$name}++) {
	    # warn "already did $_\n";
	    next;
	} 
	push @modules, $_;
	push @modname, $name;
    } 
} 

($_= <<EOPOD2B) =~ s/^\t//gm && print;
 


	=head1 PRAGMA DOCUMENTATION

EOPOD2B

podset(sort @pragmata);

($_= <<EOPOD2B) =~ s/^\t//gm && print;
 


	=head1 MODULE DOCUMENTATION

EOPOD2B

podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] );

($_= <<EOPOD2B) =~ s/^\t//gm;
 

	=head1 AUXILIARY DOCUMENTATION

	Here should be listed all the extra program's docs, but they
	don't all have man pages yet:

	=item a2p

	=item s2p

	=item find2perl
	
	=item h2ph
	
	=item c2ph

	=item h2xs

	=item xsubpp

	=item pod2man 

	=item wrapsuid


	=head1 AUTHOR

	Larry Wall E<lt>F<lwall\@sems.com>E<gt>, with the help of oodles 
	of other folks.


EOPOD2B
print;

exit;

sub podset {
    local @ARGV = @_;

    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 ";
	    $_ = <>;
	    if ( /^\s*$pod\b/ ) {
		print;
	    } else {
		s/^/$pod, /;
		print;
	    } 
	    next;
	}
	if (s/^=head1 (.*)/=item $1/) {
	    unitem(); unhead2();
	    print; nl(); next;
	} 
	if (s/^=head2 (.*)/=item $1/) {
	    unitem();
	    print "=over\n\n" unless $inhead2;
	    $inhead2 = 1;
	    print; nl(); next;

	} 
	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:/;
	    ##print "=over\n\n" unless $initem;
	    print ", " if $initem;
	    $initem = 1;
	    s/\.$//;
	    print; next;
	} 
    } 

} 

sub unhead2 {
    if ($inhead2) {
	print "\n\n=back\n\n";
    } 
    $inhead2 = 0; 
    $initem = 0;
} 

sub unitem {
    if ($initem) {
	print "\n\n";
	##print "\n\n=back\n\n";
    } 
    $initem = 0;
} 

sub nl {
    print "\n";
}