3 require 5.003; # keep this compatible, an old perl is all we may have before
8 require 'regen_lib.pl';
9 } # glob() below requires File::Glob
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: $!";
38 print $F $leader if $leader;
39 seek IN, 0, 0; # so we may restart
52 @args = split /\s*\|\s*/, $_;
54 print $F $function->(@args);
56 print $F $trailer if $trailer;
57 unless (ref $filename) {
58 close $F or die "Error closing $filename: $!";
66 my $curheader = "Unknown section";
68 sub autodoc ($$) { # parse a file and extract documentation info
72 while (defined($in = <$fh>)) {
73 if ($in=~ /^=head1 (.*)/) {
78 if ($in =~ /^=for\s+apidoc\s+(.*?)\s*\n/) {
80 $proto = "||$proto" unless $proto =~ /\|/;
81 my($flags, $ret, $name, @args) = split /\|/, $proto;
84 while (defined($doc = <$fh>)) {
85 if ($doc =~ /^=head1 (.*)/) {
90 last DOC if $doc =~ /^=\w+/;
91 if ($doc =~ m:^\*/$:) {
92 warn "=cut missing? $file:$line:$doc";;
97 $docs = "\n$docs" if $docs and $docs !~ /^\n/;
100 $apidocs{$curheader}{$name} = [$flags, $docs, $ret, $file, @args];
103 $gutsdocs{$curheader}{$name} = [$flags, $docs, $ret, $file, @args];
107 $docfuncs{$name} = [$flags, $docs, $ret, $file, $curheader, @args];
110 if ($doc =~ /^=for/) {
115 warn "$file:$line:$in";
121 sub docout ($$$) { # output the docs for one function
122 my($fh, $name, $docref) = @_;
123 my($flags, $docs, $ret, $file, @args) = @$docref;
125 $docs .= "NOTE: this function is experimental and may change or be
126 removed without notice.\n\n" if $flags =~ /x/;
127 $docs .= "NOTE: the perl_ form of this function is deprecated.\n\n"
130 print $fh "=item $name\n$docs";
132 if ($flags =~ /U/) { # no usage
134 } elsif ($flags =~ /s/) { # semicolon ("dTHR;")
135 print $fh "\t\t$name;\n\n";
136 } elsif ($flags =~ /n/) { # no args
137 print $fh "\t$ret\t$name\n\n";
138 } else { # full usage
139 print $fh "\t$ret\t$name";
140 print $fh "(" . join(", ", @args) . ")";
143 print $fh "=for hackers\nFound in file $file\n\n";
147 for $file (glob('*.c'), glob('*.h')) {
148 open F, "< $file" or die "Cannot open $file for docs: $!\n";
149 $curheader = "Functions in file $file\n";
151 close F or die "Error closing $file: $!\n";
154 safer_unlink "pod/perlapi.pod";
155 open (DOC, ">pod/perlapi.pod") or
156 die "Can't create pod/perlapi.pod: $!\n";
158 walk_table { # load documented functions into approriate hash
160 my($flags, $retval, $func, @args) = @_;
161 return "" unless $flags =~ /d/;
162 $func =~ s/\t//g; $flags =~ s/p//; # clean up fields from embed.pl
164 my $docref = delete $docfuncs{$func};
165 if ($docref and @$docref) {
167 $docref->[0].="x" if $flags =~ /M/;
168 $apidocs{$docref->[4]}{$func} =
169 [$docref->[0] . 'A', $docref->[1], $retval,
170 $docref->[3], @args];
172 $gutsdocs{$docref->[4]}{$func} =
173 [$docref->[0], $docref->[1], $retval, $docref->[3], @args];
177 warn "no docs for $func\n" unless $docref and @$docref;
183 for (sort keys %docfuncs) {
184 # Have you used a full for apidoc or just a func name?
185 # Have you used Ap instead of Am in the for apidoc?
186 warn "Unable to place $_!\n";
192 perlapi - autogenerated documentation for the perl public API
196 This file contains the documentation of the perl public API generated by
197 embed.pl, specifically a listing of functions, macros, flags, and variables
198 that may be used by extension writers. The interfaces of any functions that
199 are not listed here are subject to change without notice. For this reason,
200 blindly using functions listed in proto.h is to be avoided when writing
203 Note that all Perl API global variables must be referenced with the C<PL_>
204 prefix. Some macros are provided for compatibility with the older,
205 unadorned names, but this support may be disabled in a future release.
207 The listing is alphabetical, case insensitive.
212 # case insensitive sort, with fallback for determinacy
213 for $key (sort { uc($a) cmp uc($b) || $a cmp $b } keys %apidocs) {
214 my $section = $apidocs{$key};
215 print DOC "\n=head1 $key\n\n=over 8\n\n";
216 for my $key (sort { uc($a) cmp uc($b); } keys %$section) {
217 docout(\*DOC, $key, $section->{$key});
219 print DOC "\n=back\n";
226 Until May 1997, this document was maintained by Jeff Okamoto
227 <okamoto@corp.hp.com>. It is now maintained as part of Perl itself.
229 With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
230 Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
231 Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
232 Stephen McCamant, and Gurusamy Sarathy.
234 API Listing originally by Dean Roehrich <roehrich@cray.com>.
236 Updated to be autogenerated from comments in the source by Benjamin Stuhl.
240 perlguts(1), perlxs(1), perlxstut(1), perlintern(1)
245 close(DOC) or die "Error closing pod/perlapi.pod: $!";
247 safer_unlink "pod/perlintern.pod";
248 open(GUTS, ">pod/perlintern.pod") or
249 die "Unable to create pod/perlintern.pod: $!\n";
253 perlintern - autogenerated documentation of purely B<internal>
258 This file is the autogenerated documentation of functions in the
259 Perl interpreter that are documented using Perl's internal documentation
260 format but are not marked as part of the Perl API. In other words,
261 B<they are not for use in extensions>!
265 for $key (sort { uc($a) cmp uc($b); } keys %gutsdocs) {
266 my $section = $gutsdocs{$key};
267 print GUTS "\n=head1 $key\n\n=over 8\n\n";
268 for my $key (sort { uc($a) cmp uc($b); } keys %$section) {
269 docout(\*GUTS, $key, $section->{$key});
271 print GUTS "\n=back\n";
278 The autodocumentation system was originally added to the Perl core by
279 Benjamin Stuhl. Documentation is by whoever was kind enough to
280 document their functions.
284 perlguts(1), perlapi(1)
288 close GUTS or die "Error closing pod/perlintern.pod: $!";