3 use ExtUtils::Manifest 'maniread';
5 my $outname = shift || '-';
8 my @funcs = make_func_list();
9 my %funcs = map { $_ => 1 } @funcs;
11 # look for files to parse
14 my @files = grep /\.(c|im)$/, keys %$mani;
16 # scan each file for =item <func>\b
27 for my $file (@files) {
29 or die "Cannot open $file for documentation: $!\n";
31 if (/^=item (\w+)\b/ && $funcs{$1}) {
36 elsif ($func && /^=(cut|head)/) {
37 if ($funcs{$func}) { # only save the API functions
38 $alldocs{$func} = [ @funcdocs ];
39 $from{$func} = "File $file";
41 $funccats{$func} = $category;
42 push @{$cats{$category}}, $func;
45 $funcsyns{$func} = $synopsis;
53 if (/^=category (.*)/) {
56 elsif (/^=synopsis (.*)/) {
65 die "Documentation for $func not followed by =cut or =head in $file\n";
70 open OUT, "> $outname"
71 or die "Cannot open $outname: $!";
74 Do not edit this file, it is generated automatically by apidocs.perl
75 from Imager's source files.
77 Each function description has a comment listing the source file where
78 you can find the documentation.
82 Imager::APIRef - Imager's C API.
87 color.rgba.red = 255; color.rgba.green = 0; color.rgba.blue = 255;
91 for my $cat (sort { lc $a cmp lc $b } keys %cats) {
92 print OUT "\n # $cat\n";
93 for my $func (grep $funcsyns{$_}, sort @{$cats{$cat}}) {
94 my $syn = $funcsyns{$func};
108 for my $cat (sort { lc $a cmp lc $b } keys %cats) {
109 print OUT "=head2 $cat\n\n=over\n\n";
110 for my $func (sort @{$cats{$cat}}) {
111 print OUT @{$alldocs{$func}}, "\n";
112 print OUT "=for comment\nFrom: $from{$func}\n\n";
113 delete $undoc{$func};
115 print OUT "\n=back\n\n";
118 # see if we have an uncategorized section
119 if (grep $alldocs{$_}, keys %undoc) {
120 print OUT "=head2 Uncategorized functions\n\n=over\n\n";
121 for my $func (sort @funcs) {
122 if ($undoc{$func} && $alldocs{$func}) {
123 print OUT @{$alldocs{$func}}, "\n";
124 print OUT "=for comment\nFrom: $from{$func}\n\n";
125 delete $undoc{$func};
128 print OUT "\n\n=back\n\n";
136 The following API functions are undocumented so far, hopefully this
143 print OUT "=item *\n\nB<$_>\n\n" for sort keys %undoc;
145 print OUT "\n\n=back\n\n";
152 Tony Cook <tony@imager.perl.org>
156 Imager, Imager::ExtUtils, Imager::Inline
166 open FUNCS, "< imexttypes.h"
167 or die "Cannot open imexttypes.h: $!\n";
170 /^typedef struct/ && ++$in_struct;
171 if ($in_struct && /\(\*f_(i_\w+)/) {
174 if (/^\} im_ext_funcs;$/) {
176 or die "Found end of functions structure but not the start";
183 die "Found start of the functions structure but not the end\n";
186 die "Found neither the start nor end of the functions structure\n";