2 ################################################################################
4 # mkapidoc.sh -- generate apidoc.fnc from scanning the Perl source
6 # Should be called from the base directory for Devel::PPPort.
7 # If that happens to be in the /dist directory of a perl build structure, and
8 # you're doing the standard thing, no parameters are required. Otherwise
9 # (again with the standard things, it can be called with one parameter:
10 # sh devel/mkapidoc.sh /path/to/the/embed.fnc/you/want
12 ################################################################################
14 # Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
15 # Version 2.x, Copyright (C) 2001, Paul Marquess.
16 # Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
18 # This program is free software; you can redistribute it and/or
19 # modify it under the same terms as Perl itself.
21 ################################################################################
25 [ -f "$1/embed.fnc" ] && [ -f "$1/perl.h" ]
30 echo "USAGE: $0 [perlroot] [output-file] [input embed.fnc] [input config_h.SH]"
35 if isperlroot "../../.."; then
43 if [ -f "parts/apidoc.fnc" ]; then
44 OUTPUT="parts/apidoc.fnc"
53 EMBED="$PERLROOT/embed.fnc"
59 CONFIG="$PERLROOT/config_h.SH"
64 if isperlroot $PERLROOT; then
66 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
68 : !!!! Do NOT edit this file directly! -- Edit devel/mkapidoc.sh instead. !!!!
70 : This file was automatically generated from the API documentation scattered
71 : all over the Perl source code. To learn more about how all this works,
72 : please read the F<HACKERS> file that came with this distribution.
74 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
77 : This file lists all API functions/macros that are documented in the Perl
78 : source code, but are not contained in F<embed.fnc>.
81 : This line needs to be in this file for things to work, even though it's been
82 : removed from later embed.fnc versions
83 ApTod |int |my_sprintf |NN char *buffer|NN const char *pat|...
86 grep -hr '^=for apidoc' $PERLROOT | sed -e 's/=for apidoc //' \
91 | perl -e 'use warnings;
97 # Populate %h with the embed.fnc entry names
98 open(F,$f) || die "$f:$!";
99 while (<F>) { # In embed.fnc,
100 next unless /^[A-Za-z]+\t/; # skip lines that arent defns
101 ( split /\s*\|\s*/ ) [2] =~ /(\w+)/;
102 $h{$1}++; # Note in %h that $1 is in $EMBED
106 # STDIN consists of the =for apidoc lines. Those in embed.fnc
107 # already give us their prototypes, so skip. Otherwise massage the
108 # input somewhat and save them
111 s/\|/d|/ unless /^[^|]*d/; # Many of the entries omit the "d"
112 # flag to indicate they are
113 # documented, but we wouldnt have
114 # found this unless it was
115 # documented in the source
117 ( split /\s*\|\s*/ ) [2] =~ /(\w+)/;
118 push @entries, $_ unless $h{$1}
121 # The entries in config_h.SH are also (documented) macros that are
122 # accessible to XS code, and ppport.h backports some of them. We
123 # use only the unconditionally compiled parameterless ones (as
124 # that"s all that"s backported so far, and we don"t have to know
125 # the types of the parameters.
126 open(C, "<", $c) or die "$c: $!";
127 my $if_depth = 0; # We don"t use the ones within #if statements
128 # The #ifndef that guards the whole file is not
129 # noticed by the code below
131 $if_depth ++ if / ^ \# [[:blank:]]* (ifdef | if\ defined ) /x;
132 $if_depth -- if $if_depth > 0 && / ^ \# [[:blank:]]* endif /x;
133 next unless $if_depth <= 0;
135 # We are only interested in #defines with no parameters
136 next unless /^ \# [[:blank:]]* define [[:blank:]]+
137 ( [A-Za-z][A-Za-z0-9]* )
140 next if $h{$1}; # Ignore duplicates
141 push @entries, "Amnd||$1\n";
146 require "./parts/inc/inctools";
147 print sort sort_api_lines @entries;
148 ' $EMBED $CONFIG >> $OUTPUT
150 echo "$0: First parameter must be a directory containing embed.fnc and perl.h"