3 require 5.003; # keep this compatible, an old perl is all we may have before
8 require 'regen_lib.pl';
13 # See database of global and static function prototypes in embed.fnc
14 # This is used to generate prototype headers under various configurations,
15 # export symbols lists for different platforms, and macros to provide an
16 # implicit interpreter context argument.
19 open IN, "embed.fnc" or die $!;
21 # walk table providing an array of components in each line to
22 # subroutine, printing the result
25 my $filename = shift || '-';
30 if (ref $filename) { # filehandle
34 safer_unlink $filename;
35 open F, ">$filename" or die "Can't open $filename: $!";
39 print $F $leader if $leader;
40 seek IN, 0, 0; # so we may restart
53 @args = split /\s*\|\s*/, $_;
55 print $F $function->(@args);
57 print $F $trailer if $trailer;
58 unless (ref $filename) {
59 close $F or die "Error closing $filename: $!";
67 my $curheader = "Unknown section";
69 sub autodoc ($$) { # parse a file and extract documentation info
73 while (defined($in = <$fh>)) {
74 if ($in=~ /^=head1 (.*)/) {
79 if ($in =~ /^=for\s+apidoc\s+(.*?)\s*\n/) {
81 $proto = "||$proto" unless $proto =~ /\|/;
82 my($flags, $ret, $name, @args) = split /\|/, $proto;
85 while (defined($doc = <$fh>)) {
87 last DOC if $doc =~ /^=\w+/;
88 if ($doc =~ m:^\*/$:) {
89 warn "=cut missing? $file:$line:$doc";;
94 $docs = "\n$docs" if $docs and $docs !~ /^\n/;
97 $apidocs{$curheader}{$name} = [$flags, $docs, $ret, $file, @args];
100 $gutsdocs{$curheader}{$name} = [$flags, $docs, $ret, $file, @args];
104 $docfuncs{$name} = [$flags, $docs, $ret, $file, $curheader, @args];
107 if ($doc =~ /^=(?:for|head)/) {
112 warn "$file:$line:$in";
118 sub docout ($$$) { # output the docs for one function
119 my($fh, $name, $docref) = @_;
120 my($flags, $docs, $ret, $file, @args) = @$docref;
122 $docs .= "NOTE: this function is experimental and may change or be
123 removed without notice.\n\n" if $flags =~ /x/;
124 $docs .= "NOTE: the perl_ form of this function is deprecated.\n\n"
127 print $fh "=item $name\n$docs";
129 if ($flags =~ /U/) { # no usage
131 } elsif ($flags =~ /s/) { # semicolon ("dTHR;")
132 print $fh "\t\t$name;\n\n";
133 } elsif ($flags =~ /n/) { # no args
134 print $fh "\t$ret\t$name\n\n";
135 } else { # full usage
136 print $fh "\t$ret\t$name";
137 print $fh "(" . join(", ", @args) . ")";
140 print $fh "=for hackers\nFound in file $file\n\n";
144 # glob() picks up docs from extra .c or .h files that may be in unclean
148 open FH, "MANIFEST" or die "Can't open MANIFEST: $!";
152 for $file (($MANIFEST =~ /^(\S+\.c)\t/gm), ($MANIFEST =~ /^(\S+\.h)\t/gm)) {
153 open F, "< $file" or die "Cannot open $file for docs: $!\n";
154 $curheader = "Functions in file $file\n";
156 close F or die "Error closing $file: $!\n";
159 safer_unlink "pod/perlapi.pod";
160 open (DOC, ">pod/perlapi.pod") or
161 die "Can't create pod/perlapi.pod: $!\n";
164 walk_table { # load documented functions into approriate hash
166 my($flags, $retval, $func, @args) = @_;
167 return "" unless $flags =~ /d/;
168 $func =~ s/\t//g; $flags =~ s/p//; # clean up fields from embed.pl
170 my $docref = delete $docfuncs{$func};
171 if ($docref and @$docref) {
173 $docref->[0].="x" if $flags =~ /M/;
174 $apidocs{$docref->[4]}{$func} =
175 [$docref->[0] . 'A', $docref->[1], $retval,
176 $docref->[3], @args];
178 $gutsdocs{$docref->[4]}{$func} =
179 [$docref->[0], $docref->[1], $retval, $docref->[3], @args];
183 warn "no docs for $func\n" unless $docref and @$docref;
189 for (sort keys %docfuncs) {
190 # Have you used a full for apidoc or just a func name?
191 # Have you used Ap instead of Am in the for apidoc?
192 warn "Unable to place $_!\n";
198 perlapi - autogenerated documentation for the perl public API
202 This file contains the documentation of the perl public API generated by
203 embed.pl, specifically a listing of functions, macros, flags, and variables
204 that may be used by extension writers. The interfaces of any functions that
205 are not listed here are subject to change without notice. For this reason,
206 blindly using functions listed in proto.h is to be avoided when writing
209 Note that all Perl API global variables must be referenced with the C<PL_>
210 prefix. Some macros are provided for compatibility with the older,
211 unadorned names, but this support may be disabled in a future release.
213 The listing is alphabetical, case insensitive.
218 # case insensitive sort, with fallback for determinacy
219 for $key (sort { uc($a) cmp uc($b) || $a cmp $b } keys %apidocs) {
220 my $section = $apidocs{$key};
221 print DOC "\n=head1 $key\n\n=over 8\n\n";
222 for my $key (sort { uc($a) cmp uc($b); } keys %$section) {
223 docout(\*DOC, $key, $section->{$key});
225 print DOC "\n=back\n";
232 Until May 1997, this document was maintained by Jeff Okamoto
233 <okamoto@corp.hp.com>. It is now maintained as part of Perl itself.
235 With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
236 Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
237 Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
238 Stephen McCamant, and Gurusamy Sarathy.
240 API Listing originally by Dean Roehrich <roehrich@cray.com>.
242 Updated to be autogenerated from comments in the source by Benjamin Stuhl.
246 perlguts(1), perlxs(1), perlxstut(1), perlintern(1)
251 close(DOC) or die "Error closing pod/perlapi.pod: $!";
253 safer_unlink "pod/perlintern.pod";
254 open(GUTS, ">pod/perlintern.pod") or
255 die "Unable to create pod/perlintern.pod: $!\n";
260 perlintern - autogenerated documentation of purely B<internal>
265 This file is the autogenerated documentation of functions in the
266 Perl interpreter that are documented using Perl's internal documentation
267 format but are not marked as part of the Perl API. In other words,
268 B<they are not for use in extensions>!
272 for $key (sort { uc($a) cmp uc($b); } keys %gutsdocs) {
273 my $section = $gutsdocs{$key};
274 print GUTS "\n=head1 $key\n\n=over 8\n\n";
275 for my $key (sort { uc($a) cmp uc($b); } keys %$section) {
276 docout(\*GUTS, $key, $section->{$key});
278 print GUTS "\n=back\n";
285 The autodocumentation system was originally added to the Perl core by
286 Benjamin Stuhl. Documentation is by whoever was kind enough to
287 document their functions.
291 perlguts(1), perlapi(1)
295 close GUTS or die "Error closing pod/perlintern.pod: $!";