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;
88 i_fill_t *fill = i_new_fill_...(...);
92 for my $cat (sort { lc $a cmp lc $b } keys %cats) {
93 print OUT "\n # $cat\n";
94 for my $func (grep $funcsyns{$_}, sort @{$cats{$cat}}) {
95 my $syn = $funcsyns{$func};
103 i_fill_destroy(fill);
111 for my $cat (sort { lc $a cmp lc $b } keys %cats) {
112 print OUT "=head2 $cat\n\n=over\n\n";
113 for my $func (sort @{$cats{$cat}}) {
114 print OUT @{$alldocs{$func}}, "\n";
115 print OUT "=for comment\nFrom: $from{$func}\n\n";
116 delete $undoc{$func};
118 print OUT "\n=back\n\n";
121 # see if we have an uncategorized section
122 if (grep $alldocs{$_}, keys %undoc) {
123 print OUT "=head2 Uncategorized functions\n\n=over\n\n";
124 for my $func (sort @funcs) {
125 if ($undoc{$func} && $alldocs{$func}) {
126 print OUT @{$alldocs{$func}}, "\n";
127 print OUT "=for comment\nFrom: $from{$func}\n\n";
128 delete $undoc{$func};
131 print OUT "\n\n=back\n\n";
139 The following API functions are undocumented so far, hopefully this
146 print OUT "=item *\n\nB<$_>\n\n" for sort keys %undoc;
148 print OUT "\n\n=back\n\n";
155 Tony Cook <tony@imager.perl.org>
159 Imager, Imager::ExtUtils, Imager::Inline
169 open FUNCS, "< imexttypes.h"
170 or die "Cannot open imexttypes.h: $!\n";
173 /^typedef struct/ && ++$in_struct;
174 if ($in_struct && /\(\*f_(i_\w+)/) {
177 if (/^\} im_ext_funcs;$/) {
179 or die "Found end of functions structure but not the start";
186 die "Found start of the functions structure but not the end\n";
189 die "Found neither the start nor end of the functions structure\n";