5 ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
6 ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
7 ## Copyright (C) 2001 Simon Huggins ##
9 ## #define enhancements by Armin Kuster <akuster@mvista.com> ##
10 ## Copyright (c) 2000 MontaVista Software, Inc. ##
12 ## This software falls under the GNU General Public License. ##
13 ## Please read the COPYING file for more information ##
15 # w.o. 03-11-2000: added the '-filelist' option.
17 # 18/01/2001 - Cleanups
18 # Functions prototyped as foo(void) same as foo()
19 # Stop eval'ing where we don't need to.
22 # 27/06/2001 - Allowed whitespace after initial "/**" and
23 # allowed comments before function declarations.
24 # -- Christian Kreibich <ck@whoop.org>
27 # - add perldoc documentation
28 # - Look more closely at some of the scarier bits :)
30 # 26/05/2001 - Support for separate source and object trees.
32 # Keith Owens <kaos@ocs.com.au>
34 # 23/09/2001 - Added support for typedefs, structs, enums and unions
35 # Support for Context section; can be terminated using empty line
36 # Small fixes (like spaces vs. \s in regex)
37 # -- Tim Jansen <tim@tjansen.de>
41 # This will read a 'c' file and scan for embedded comments in the
42 # style of gnome comments (+minor extensions - see below).
45 # Note: This only supports 'c'.
48 # kerneldoc [ -docbook | -html | -text | -man ]
49 # [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
51 # [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile
53 # Set output format using one of -docbook -html -text or -man. Default is man.
56 # If set, then only generate documentation for the given function(s). All
57 # other functions are ignored.
59 # -nofunction funcname
60 # If set, then only generate documentation for the other function(s). All
61 # other functions are ignored. Cannot be used with -function together
62 # (yes thats a bug - perl hackers can fix it 8))
64 # c files - list of 'c' files to process
66 # All output goes to stdout, with errors to stderr.
70 # In the following table, (...)? signifies optional structure.
71 # (...)* signifies 0 or more structure elements
73 # * function_name(:)? (- short description)?
74 # (* @parameterx: (description of parameter x)?)*
76 # * (Description:)? (Description of function)?
77 # * (section header: (section description)? )*
80 # So .. the trivial example would be:
86 # If the Description: header tag is ommitted, then there must be a blank line
87 # after the last parameter specification.
90 # * my_function - does my stuff
91 # * @my_arg: its mine damnit
93 # * Does my stuff explained.
98 # * my_function - does my stuff
99 # * @my_arg: its mine damnit
100 # * Description: Does my stuff explained.
104 # Beside functions you can also write documentation for structs, unions,
105 # enums and typedefs. Instead of the function name you must write the name
106 # of the declaration; the struct/union/enum/typedef must always precede
107 # the name. Nesting of declarations is not supported.
108 # Use the argument mechanism to document members or constants.
111 # * struct my_struct - short description
113 # * @b: second member
115 # * Longer description
122 # All descriptions can be multiline, except the short function description.
124 # You can also add additional sections. When documenting kernel functions you
125 # should document the "Context:" of the function, e.g. whether the functions
126 # can be called form interrupts. Unlike other sections you can end it with an
128 # Example-sections should contain the string EXAMPLE so that they are marked
129 # appropriately in DocBook.
133 # * user_function - function that can only be called in user context
134 # * @a: some argument
135 # * Context: !in_interrupt()
139 # * user_function(22);
144 # All descriptive text is further processed, scanning for the following special
145 # patterns, which are highlighted appropriately.
147 # 'funcname()' - function
148 # '$ENVVAR' - environmental variable
149 # '&struct_name' - name of a structure (up to two words including 'struct')
150 # '@parameter' - name of a parameter
151 # '%CONST' - name of a constant.
156 # match expressions used to find embedded type information
157 my $type_constant = '\%([-_\w]+)';
158 my $type_func = '(\w+)\(\)';
159 my $type_param = '\@(\w+)';
160 my $type_struct = '\&((struct\s*)?[_\w]+)';
161 my $type_env = '(\$\w+)';
163 # Output conversion substitutions.
164 # One for each output format
166 # these work fairly well
167 my %highlights_html = ( $type_constant, "<i>\$1</i>",
168 $type_func, "<b>\$1</b>",
169 $type_struct, "<i>\$1</i>",
170 $type_param, "<tt><b>\$1</b></tt>" );
171 my $blankline_html = "<p>";
173 # XML, docbook format
174 my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>",
175 $type_constant, "<constant>\$1</constant>",
176 $type_func, "<function>\$1</function>",
177 $type_struct, "<structname>\$1</structname>",
178 $type_env, "<envar>\$1</envar>",
179 $type_param, "<parameter>\$1</parameter>" );
180 my $blankline_xml = "</para><para>\n";
182 # gnome, docbook format
183 my %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>",
184 $type_func, "<function>\$1</function>",
185 $type_struct, "<structname>\$1</structname>",
186 $type_env, "<envar>\$1</envar>",
187 $type_param, "<parameter>\$1</parameter>" );
188 my $blankline_gnome = "</para><para>\n";
190 # these are pretty rough
191 my %highlights_man = ( $type_constant, "\$1",
192 $type_func, "\\\\fB\$1\\\\fP",
193 $type_struct, "\\\\fI\$1\\\\fP",
194 $type_param, "\\\\fI\$1\\\\fP" );
195 my $blankline_man = "";
198 my %highlights_text = ( $type_constant, "\$1",
201 $type_param, "\$1" );
202 my $blankline_text = "";
206 print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ]\n";
207 print " [ -function funcname [ -function funcname ...] ]\n";
208 print " [ -nofunction funcname [ -nofunction funcname ...] ]\n";
209 print " c source file(s) > outputfile\n";
219 my $output_mode = "man";
220 my %highlights = %highlights_man;
221 my $blankline = $blankline_man;
222 my $modulename = "Kernel API";
223 my $function_only = 0;
224 my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
225 'July', 'August', 'September', 'October',
226 'November', 'December')[(localtime)[4]] .
227 " " . ((localtime)[5]+1900);
229 # Essentially these are globals
230 # They probably want to be tidied up made more localised or summat.
231 # CAVEAT EMPTOR! Some of the others I localised may not want to be which
232 # could cause "use of undefined value" or other bugs.
233 my ($function, %function_table,%parametertypes,$declaration_purpose);
234 my ($type,$declaration_name,$return_type);
235 my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map);
237 # Generated docbook code is inserted in a template at a point where
238 # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
239 # http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
240 # We keep track of number of generated entries and generate a dummy
241 # if needs be to ensure the expanded template can be postprocessed
243 my $section_counter = 0;
249 # 1 - looking for function name
250 # 2 - scanning field start.
251 # 3 - scanning prototype.
252 # 4 - documentation block
255 #declaration types: can be
256 # 'function', 'struct', 'union', 'enum', 'typedef'
259 my $doc_special = "\@\%\$\&";
261 my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
263 my $doc_com = '\s*\*\s*';
264 my $doc_decl = $doc_com.'(\w+)';
265 my $doc_sect = $doc_com.'(['.$doc_special.']?[\w ]+):(.*)';
266 my $doc_content = $doc_com.'(.*)';
267 my $doc_block = $doc_com.'DOC:\s*(.*)?';
276 my $section_default = "Description"; # default section
277 my $section_intro = "Introduction";
278 my $section = $section_default;
279 my $section_context = "Context";
281 my $undescribed = "-- undescribed --";
285 while ($ARGV[0] =~ m/^-(.*)/) {
286 my $cmd = shift @ARGV;
287 if ($cmd eq "-html") {
288 $output_mode = "html";
289 %highlights = %highlights_html;
290 $blankline = $blankline_html;
291 } elsif ($cmd eq "-man") {
292 $output_mode = "man";
293 %highlights = %highlights_man;
294 $blankline = $blankline_man;
295 } elsif ($cmd eq "-text") {
296 $output_mode = "text";
297 %highlights = %highlights_text;
298 $blankline = $blankline_text;
299 } elsif ($cmd eq "-docbook") {
300 $output_mode = "xml";
301 %highlights = %highlights_xml;
302 $blankline = $blankline_xml;
303 } elsif ($cmd eq "-gnome") {
304 $output_mode = "gnome";
305 %highlights = %highlights_gnome;
306 $blankline = $blankline_gnome;
307 } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document
308 $modulename = shift @ARGV;
309 } elsif ($cmd eq "-function") { # to only output specific functions
311 $function = shift @ARGV;
312 $function_table{$function} = 1;
313 } elsif ($cmd eq "-nofunction") { # to only output specific functions
315 $function = shift @ARGV;
316 $function_table{$function} = 1;
317 } elsif ($cmd eq "-v") {
319 } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
321 } elsif ($cmd eq '-filelist') {
322 $filelist = shift @ARGV;
327 # generate a sequence of code that will splice in highlighting information
328 # using the s// operator.
329 my $dohighlight = "";
330 foreach my $pattern (keys %highlights) {
331 # print "scanning pattern $pattern ($highlights{$pattern})\n";
332 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
336 # dumps section contents to arrays/hashes intended for that purpose.
340 my $contents = join "\n", @_;
342 if ($name =~ m/$type_constant/) {
344 # print STDERR "constant section '$1' = '$contents'\n";
345 $constants{$name} = $contents;
346 } elsif ($name =~ m/$type_param/) {
347 # print STDERR "parameter def '$1' = '$contents'\n";
349 $parameterdescs{$name} = $contents;
351 # print STDERR "other section '$name' = '$contents'\n";
352 $sections{$name} = $contents;
353 push @sectionlist, $name;
360 # parameterdescs, a hash.
361 # function => "function name"
362 # parameterlist => @list of parameters
363 # parameterdescs => %parameter descriptions
364 # sectionlist => @list of sections
365 # sections => %descriont descriptions
368 sub output_highlight
{
369 my $contents = join "\n",@_;
373 # if (!defined $contents) {
375 # confess "output_highlight got called with no args?\n";
380 foreach $line (split "\n", $contents) {
382 print $lineprefix, $blankline;
384 $line =~ s/\\\\\\/\&/g;
385 print $lineprefix, $line;
391 #output sections in html
392 sub output_section_html
(%) {
396 foreach $section (@
{$args{'sectionlist'}}) {
397 print "<h3>$section</h3>\n";
398 print "<blockquote>\n";
399 output_highlight
($args{'sections'}{$section});
400 print "</blockquote>\n";
404 # output enum in html
405 sub output_enum_html
(%) {
409 print "<h2>enum ".$args{'enum'}."</h2>\n";
411 print "<b>enum ".$args{'enum'}."</b> {<br>\n";
413 foreach $parameter (@
{$args{'parameterlist'}}) {
414 print " <b>".$parameter."</b>";
415 if ($count != $#{$args{'parameterlist'}}) {
423 print "<h3>Constants</h3>\n";
425 foreach $parameter (@
{$args{'parameterlist'}}) {
426 print "<dt><b>".$parameter."</b>\n";
428 output_highlight
($args{'parameterdescs'}{$parameter});
431 output_section_html
(@_);
435 # output tyepdef in html
436 sub output_typedef_html
(%) {
440 print "<h2>typedef ".$args{'typedef'}."</h2>\n";
442 print "<b>typedef ".$args{'typedef'}."</b>\n";
443 output_section_html
(@_);
447 # output struct in html
448 sub output_struct_html
(%) {
452 print "<h2>".$args{'type'}." ".$args{'struct'}."</h2>\n";
453 print "<b>".$args{'type'}." ".$args{'struct'}."</b> {<br>\n";
454 foreach $parameter (@
{$args{'parameterlist'}}) {
455 if ($parameter =~ /^#/) {
456 print "$parameter<br>\n";
459 my $parameter_name = $parameter;
460 $parameter_name =~ s/\[.*//;
462 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
463 $type = $args{'parametertypes'}{$parameter};
464 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
465 # pointer-to-function
466 print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
467 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
468 print " <i>$1</i> <b>$parameter</b>$2;<br>\n";
470 print " <i>$type</i> <b>$parameter</b>;<br>\n";
475 print "<h3>Members</h3>\n";
477 foreach $parameter (@
{$args{'parameterlist'}}) {
478 ($parameter =~ /^#/) && next;
480 my $parameter_name = $parameter;
481 $parameter_name =~ s/\[.*//;
483 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
484 print "<dt><b>".$parameter."</b>\n";
486 output_highlight
($args{'parameterdescs'}{$parameter_name});
489 output_section_html
(@_);
493 # output function in html
494 sub output_function_html
(%) {
496 my ($parameter, $section);
498 print "<h2>Function</h2>\n";
500 print "<i>".$args{'functiontype'}."</i>\n";
501 print "<b>".$args{'function'}."</b>\n";
504 foreach $parameter (@
{$args{'parameterlist'}}) {
505 $type = $args{'parametertypes'}{$parameter};
506 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
507 # pointer-to-function
508 print "<i>$1</i><b>$parameter</b>) <i>($2)</i>";
510 print "<i>".$type."</i> <b>".$parameter."</b>";
512 if ($count != $#{$args{'parameterlist'}}) {
519 print "<h3>Arguments</h3>\n";
521 foreach $parameter (@
{$args{'parameterlist'}}) {
522 my $parameter_name = $parameter;
523 $parameter_name =~ s/\[.*//;
525 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
526 print "<dt><b>".$parameter."</b>\n";
528 output_highlight
($args{'parameterdescs'}{$parameter_name});
531 output_section_html
(@_);
535 # output intro in html
536 sub output_intro_html
(%) {
538 my ($parameter, $section);
541 foreach $section (@
{$args{'sectionlist'}}) {
542 print "<h3>$section</h3>\n";
544 output_highlight
($args{'sections'}{$section});
550 sub output_section_xml
(%) {
553 # print out each section
555 foreach $section (@
{$args{'sectionlist'}}) {
556 print "<refsect1>\n <title>$section</title>\n <para>\n";
557 if ($section =~ m/EXAMPLE/i) {
558 print "<example><para>\n";
560 output_highlight
($args{'sections'}{$section});
561 if ($section =~ m/EXAMPLE/i) {
562 print "</para></example>\n";
564 print " </para>\n</refsect1>\n";
568 # output function in XML DocBook
569 sub output_function_xml
(%) {
571 my ($parameter, $section);
575 $id = "API-".$args{'function'};
576 $id =~ s/[^A-Za-z0-9]/-/g;
578 print "<refentry>\n";
580 print "<refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n";
581 print "</refmeta>\n";
582 print "<refnamediv>\n";
583 print " <refname>".$args{'function'}."</refname>\n";
584 print " <refpurpose>\n";
586 output_highlight
($args{'purpose'});
587 print " </refpurpose>\n";
588 print "</refnamediv>\n";
590 print "<refsynopsisdiv>\n";
591 print " <title>Synopsis</title>\n";
592 print " <funcsynopsis><funcprototype>\n";
593 print " <funcdef>".$args{'functiontype'}." ";
594 print "<function>".$args{'function'}." </function></funcdef>\n";
597 if ($#{$args{'parameterlist'}} >= 0) {
598 foreach $parameter (@
{$args{'parameterlist'}}) {
599 $type = $args{'parametertypes'}{$parameter};
600 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
601 # pointer-to-function
602 print " <paramdef>$1<parameter>$parameter</parameter>)\n";
603 print " <funcparams>$2</funcparams></paramdef>\n";
605 print " <paramdef>".$type;
606 print " <parameter>$parameter</parameter></paramdef>\n";
612 print " </funcprototype></funcsynopsis>\n";
613 print "</refsynopsisdiv>\n";
616 print "<refsect1>\n <title>Arguments</title>\n";
617 if ($#{$args{'parameterlist'}} >= 0) {
618 print " <variablelist>\n";
619 foreach $parameter (@
{$args{'parameterlist'}}) {
620 my $parameter_name = $parameter;
621 $parameter_name =~ s/\[.*//;
623 print " <varlistentry>\n <term><parameter>$parameter</parameter></term>\n";
624 print " <listitem>\n <para>\n";
626 output_highlight
($args{'parameterdescs'}{$parameter_name});
627 print " </para>\n </listitem>\n </varlistentry>\n";
629 print " </variablelist>\n";
631 print " <para>\n None\n </para>\n";
633 print "</refsect1>\n";
635 output_section_xml
(@_);
636 print "</refentry>\n\n";
639 # output struct in XML DocBook
640 sub output_struct_xml
(%) {
642 my ($parameter, $section);
645 $id = "API-struct-".$args{'struct'};
646 $id =~ s/[^A-Za-z0-9]/-/g;
648 print "<refentry>\n";
650 print "<refentrytitle><phrase id=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
651 print "</refmeta>\n";
652 print "<refnamediv>\n";
653 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n";
654 print " <refpurpose>\n";
656 output_highlight
($args{'purpose'});
657 print " </refpurpose>\n";
658 print "</refnamediv>\n";
660 print "<refsynopsisdiv>\n";
661 print " <title>Synopsis</title>\n";
662 print " <programlisting>\n";
663 print $args{'type'}." ".$args{'struct'}." {\n";
664 foreach $parameter (@
{$args{'parameterlist'}}) {
665 if ($parameter =~ /^#/) {
666 print "$parameter\n";
670 my $parameter_name = $parameter;
671 $parameter_name =~ s/\[.*//;
673 defined($args{'parameterdescs'}{$parameter_name}) || next;
674 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
675 $type = $args{'parametertypes'}{$parameter};
676 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
677 # pointer-to-function
678 print " $1 $parameter) ($2);\n";
679 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
680 print " $1 $parameter$2;\n";
682 print " ".$type." ".$parameter.";\n";
686 print " </programlisting>\n";
687 print "</refsynopsisdiv>\n";
689 print " <refsect1>\n";
690 print " <title>Members</title>\n";
692 print " <variablelist>\n";
693 foreach $parameter (@
{$args{'parameterlist'}}) {
694 ($parameter =~ /^#/) && next;
696 my $parameter_name = $parameter;
697 $parameter_name =~ s/\[.*//;
699 defined($args{'parameterdescs'}{$parameter_name}) || next;
700 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
701 print " <varlistentry>";
702 print " <term>$parameter</term>\n";
703 print " <listitem><para>\n";
704 output_highlight
($args{'parameterdescs'}{$parameter_name});
705 print " </para></listitem>\n";
706 print " </varlistentry>\n";
708 print " </variablelist>\n";
709 print " </refsect1>\n";
711 output_section_xml
(@_);
713 print "</refentry>\n\n";
716 # output enum in XML DocBook
717 sub output_enum_xml
(%) {
719 my ($parameter, $section);
723 $id = "API-enum-".$args{'enum'};
724 $id =~ s/[^A-Za-z0-9]/-/g;
726 print "<refentry>\n";
728 print "<refentrytitle><phrase id=\"$id\">enum ".$args{'enum'}."</phrase></refentrytitle>\n";
729 print "</refmeta>\n";
730 print "<refnamediv>\n";
731 print " <refname>enum ".$args{'enum'}."</refname>\n";
732 print " <refpurpose>\n";
734 output_highlight
($args{'purpose'});
735 print " </refpurpose>\n";
736 print "</refnamediv>\n";
738 print "<refsynopsisdiv>\n";
739 print " <title>Synopsis</title>\n";
740 print " <programlisting>\n";
741 print "enum ".$args{'enum'}." {\n";
743 foreach $parameter (@
{$args{'parameterlist'}}) {
745 if ($count != $#{$args{'parameterlist'}}) {
752 print " </programlisting>\n";
753 print "</refsynopsisdiv>\n";
755 print "<refsect1>\n";
756 print " <title>Constants</title>\n";
757 print " <variablelist>\n";
758 foreach $parameter (@
{$args{'parameterlist'}}) {
759 my $parameter_name = $parameter;
760 $parameter_name =~ s/\[.*//;
762 print " <varlistentry>";
763 print " <term>$parameter</term>\n";
764 print " <listitem><para>\n";
765 output_highlight
($args{'parameterdescs'}{$parameter_name});
766 print " </para></listitem>\n";
767 print " </varlistentry>\n";
769 print " </variablelist>\n";
770 print "</refsect1>\n";
772 output_section_xml
(@_);
774 print "</refentry>\n\n";
777 # output typedef in XML DocBook
778 sub output_typedef_xml
(%) {
780 my ($parameter, $section);
783 $id = "API-typedef-".$args{'typedef'};
784 $id =~ s/[^A-Za-z0-9]/-/g;
786 print "<refentry>\n";
788 print "<refentrytitle><phrase id=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
789 print "</refmeta>\n";
790 print "<refnamediv>\n";
791 print " <refname>typedef ".$args{'typedef'}."</refname>\n";
792 print " <refpurpose>\n";
794 output_highlight
($args{'purpose'});
795 print " </refpurpose>\n";
796 print "</refnamediv>\n";
798 print "<refsynopsisdiv>\n";
799 print " <title>Synopsis</title>\n";
800 print " <synopsis>typedef ".$args{'typedef'}.";</synopsis>\n";
801 print "</refsynopsisdiv>\n";
803 output_section_xml
(@_);
805 print "</refentry>\n\n";
808 # output in XML DocBook
809 sub output_intro_xml
(%) {
811 my ($parameter, $section);
814 my $id = $args{'module'};
815 $id =~ s/[^A-Za-z0-9]/-/g;
817 # print out each section
819 foreach $section (@
{$args{'sectionlist'}}) {
820 print "<refsect1>\n <title>$section</title>\n <para>\n";
821 if ($section =~ m/EXAMPLE/i) {
822 print "<example><para>\n";
824 output_highlight
($args{'sections'}{$section});
825 if ($section =~ m/EXAMPLE/i) {
826 print "</para></example>\n";
828 print " </para>\n</refsect1>\n";
834 # output in XML DocBook
835 sub output_function_gnome
{
837 my ($parameter, $section);
841 $id = $args{'module'}."-".$args{'function'};
842 $id =~ s/[^A-Za-z0-9]/-/g;
845 print " <title id=\"$id\">".$args{'function'}."</title>\n";
847 print " <funcsynopsis>\n";
848 print " <funcdef>".$args{'functiontype'}." ";
849 print "<function>".$args{'function'}." ";
850 print "</function></funcdef>\n";
853 if ($#{$args{'parameterlist'}} >= 0) {
854 foreach $parameter (@
{$args{'parameterlist'}}) {
855 $type = $args{'parametertypes'}{$parameter};
856 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
857 # pointer-to-function
858 print " <paramdef>$1 <parameter>$parameter</parameter>)\n";
859 print " <funcparams>$2</funcparams></paramdef>\n";
861 print " <paramdef>".$type;
862 print " <parameter>$parameter</parameter></paramdef>\n";
868 print " </funcsynopsis>\n";
869 if ($#{$args{'parameterlist'}} >= 0) {
870 print " <informaltable pgwide=\"1\" frame=\"none\" role=\"params\">\n";
871 print "<tgroup cols=\"2\">\n";
872 print "<colspec colwidth=\"2*\">\n";
873 print "<colspec colwidth=\"8*\">\n";
875 foreach $parameter (@
{$args{'parameterlist'}}) {
876 my $parameter_name = $parameter;
877 $parameter_name =~ s/\[.*//;
879 print " <row><entry align=\"right\"><parameter>$parameter</parameter></entry>\n";
882 output_highlight
($args{'parameterdescs'}{$parameter_name});
883 print " </entry></row>\n";
885 print " </tbody></tgroup></informaltable>\n";
887 print " <para>\n None\n </para>\n";
890 # print out each section
892 foreach $section (@
{$args{'sectionlist'}}) {
893 print "<simplesect>\n <title>$section</title>\n";
894 if ($section =~ m/EXAMPLE/i) {
895 print "<example><programlisting>\n";
899 output_highlight
($args{'sections'}{$section});
901 if ($section =~ m/EXAMPLE/i) {
902 print "</programlisting></example>\n";
905 print " </simplesect>\n";
908 print "</sect2>\n\n";
912 # output function in man
913 sub output_function_man
(%) {
915 my ($parameter, $section);
918 print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n";
921 print $args{'function'}." \\- ".$args{'purpose'}."\n";
923 print ".SH SYNOPSIS\n";
924 print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";
928 foreach my $parameter (@
{$args{'parameterlist'}}) {
929 if ($count == $#{$args{'parameterlist'}}) {
932 $type = $args{'parametertypes'}{$parameter};
933 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
934 # pointer-to-function
935 print ".BI \"".$parenth.$1."\" ".$parameter." \") (".$2.")".$post."\"\n";
937 $type =~ s/([^\*])$/$1 /;
938 print ".BI \"".$parenth.$type."\" ".$parameter." \"".$post."\"\n";
944 print ".SH ARGUMENTS\n";
945 foreach $parameter (@
{$args{'parameterlist'}}) {
946 my $parameter_name = $parameter;
947 $parameter_name =~ s/\[.*//;
949 print ".IP \"".$parameter."\" 12\n";
950 output_highlight
($args{'parameterdescs'}{$parameter_name});
952 foreach $section (@
{$args{'sectionlist'}}) {
953 print ".SH \"", uc $section, "\"\n";
954 output_highlight
($args{'sections'}{$section});
960 sub output_enum_man
(%) {
962 my ($parameter, $section);
965 print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual\" LINUX\n";
968 print "enum ".$args{'enum'}." \\- ".$args{'purpose'}."\n";
970 print ".SH SYNOPSIS\n";
971 print "enum ".$args{'enum'}." {\n";
973 foreach my $parameter (@
{$args{'parameterlist'}}) {
974 print ".br\n.BI \" $parameter\"\n";
975 if ($count == $#{$args{'parameterlist'}}) {
985 print ".SH Constants\n";
986 foreach $parameter (@
{$args{'parameterlist'}}) {
987 my $parameter_name = $parameter;
988 $parameter_name =~ s/\[.*//;
990 print ".IP \"".$parameter."\" 12\n";
991 output_highlight
($args{'parameterdescs'}{$parameter_name});
993 foreach $section (@
{$args{'sectionlist'}}) {
994 print ".SH \"$section\"\n";
995 output_highlight
($args{'sections'}{$section});
1000 # output struct in man
1001 sub output_struct_man
(%) {
1002 my %args = %{$_[0]};
1003 my ($parameter, $section);
1005 print ".TH \"$args{'module'}\" 9 \"".$args{'type'}." ".$args{'struct'}."\" \"$man_date\" \"API Manual\" LINUX\n";
1008 print $args{'type'}." ".$args{'struct'}." \\- ".$args{'purpose'}."\n";
1010 print ".SH SYNOPSIS\n";
1011 print $args{'type'}." ".$args{'struct'}." {\n.br\n";
1013 foreach my $parameter (@
{$args{'parameterlist'}}) {
1014 if ($parameter =~ /^#/) {
1015 print ".BI \"$parameter\"\n.br\n";
1018 my $parameter_name = $parameter;
1019 $parameter_name =~ s/\[.*//;
1021 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1022 $type = $args{'parametertypes'}{$parameter};
1023 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1024 # pointer-to-function
1025 print ".BI \" ".$1."\" ".$parameter." \") (".$2.")"."\"\n;\n";
1026 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1027 print ".BI \" ".$1."\" ".$parameter.$2." \""."\"\n;\n";
1029 $type =~ s/([^\*])$/$1 /;
1030 print ".BI \" ".$type."\" ".$parameter." \""."\"\n;\n";
1036 print ".SH Arguments\n";
1037 foreach $parameter (@
{$args{'parameterlist'}}) {
1038 ($parameter =~ /^#/) && next;
1040 my $parameter_name = $parameter;
1041 $parameter_name =~ s/\[.*//;
1043 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1044 print ".IP \"".$parameter."\" 12\n";
1045 output_highlight
($args{'parameterdescs'}{$parameter_name});
1047 foreach $section (@
{$args{'sectionlist'}}) {
1048 print ".SH \"$section\"\n";
1049 output_highlight
($args{'sections'}{$section});
1054 # output typedef in man
1055 sub output_typedef_man
(%) {
1056 my %args = %{$_[0]};
1057 my ($parameter, $section);
1059 print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual\" LINUX\n";
1062 print "typedef ".$args{'typedef'}." \\- ".$args{'purpose'}."\n";
1064 foreach $section (@
{$args{'sectionlist'}}) {
1065 print ".SH \"$section\"\n";
1066 output_highlight
($args{'sections'}{$section});
1070 sub output_intro_man
(%) {
1071 my %args = %{$_[0]};
1072 my ($parameter, $section);
1075 print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual\" LINUX\n";
1077 foreach $section (@
{$args{'sectionlist'}}) {
1078 print ".SH \"$section\"\n";
1079 output_highlight
($args{'sections'}{$section});
1085 sub output_function_text
(%) {
1086 my %args = %{$_[0]};
1087 my ($parameter, $section);
1089 print "Function:\n\n";
1090 my $start=$args{'functiontype'}." ".$args{'function'}." (";
1093 foreach my $parameter (@
{$args{'parameterlist'}}) {
1094 $type = $args{'parametertypes'}{$parameter};
1095 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1096 # pointer-to-function
1097 print $1.$parameter.") (".$2;
1099 print $type." ".$parameter;
1101 if ($count != $#{$args{'parameterlist'}}) {
1104 print " " x
length($start);
1110 print "Arguments:\n\n";
1111 foreach $parameter (@
{$args{'parameterlist'}}) {
1112 my $parameter_name = $parameter;
1113 $parameter_name =~ s/\[.*//;
1115 print $parameter."\n\t".$args{'parameterdescs'}{$parameter_name}."\n";
1117 output_section_text
(@_);
1120 #output sections in text
1121 sub output_section_text
(%) {
1122 my %args = %{$_[0]};
1126 foreach $section (@
{$args{'sectionlist'}}) {
1127 print "$section:\n\n";
1128 output_highlight
($args{'sections'}{$section});
1133 # output enum in text
1134 sub output_enum_text
(%) {
1135 my %args = %{$_[0]};
1140 print "enum ".$args{'enum'}." {\n";
1142 foreach $parameter (@
{$args{'parameterlist'}}) {
1143 print "\t$parameter";
1144 if ($count != $#{$args{'parameterlist'}}) {
1152 print "Constants:\n\n";
1153 foreach $parameter (@
{$args{'parameterlist'}}) {
1154 print "$parameter\n\t";
1155 print $args{'parameterdescs'}{$parameter}."\n";
1158 output_section_text
(@_);
1161 # output typedef in text
1162 sub output_typedef_text
(%) {
1163 my %args = %{$_[0]};
1166 print "Typedef:\n\n";
1168 print "typedef ".$args{'typedef'}."\n";
1169 output_section_text
(@_);
1172 # output struct as text
1173 sub output_struct_text
(%) {
1174 my %args = %{$_[0]};
1177 print $args{'type'}." ".$args{'struct'}.":\n\n";
1178 print $args{'type'}." ".$args{'struct'}." {\n";
1179 foreach $parameter (@
{$args{'parameterlist'}}) {
1180 if ($parameter =~ /^#/) {
1181 print "$parameter\n";
1185 my $parameter_name = $parameter;
1186 $parameter_name =~ s/\[.*//;
1188 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1189 $type = $args{'parametertypes'}{$parameter};
1190 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1191 # pointer-to-function
1192 print "\t$1 $parameter) ($2);\n";
1193 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1194 print "\t$1 $parameter$2;\n";
1196 print "\t".$type." ".$parameter.";\n";
1201 print "Members:\n\n";
1202 foreach $parameter (@
{$args{'parameterlist'}}) {
1203 ($parameter =~ /^#/) && next;
1205 my $parameter_name = $parameter;
1206 $parameter_name =~ s/\[.*//;
1208 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1209 print "$parameter\n\t";
1210 print $args{'parameterdescs'}{$parameter_name}."\n";
1213 output_section_text
(@_);
1216 sub output_intro_text
(%) {
1217 my %args = %{$_[0]};
1218 my ($parameter, $section);
1220 foreach $section (@
{$args{'sectionlist'}}) {
1221 print " $section:\n";
1223 output_highlight
($args{'sections'}{$section});
1228 # generic output function for typedefs
1229 sub output_declaration
{
1232 my $functype = shift;
1233 my $func = "output_${functype}_$output_mode";
1234 if (($function_only==0) ||
1235 ( $function_only == 1 && defined($function_table{$name})) ||
1236 ( $function_only == 2 && !defined($function_table{$name})))
1244 # generic output function - calls the right one based
1245 # on current output mode.
1248 my $func = "output_intro_".$output_mode;
1254 # takes a declaration (struct, union, enum, typedef) and
1255 # invokes the right handler. NOT called for functions.
1256 sub dump_declaration
($$) {
1258 my ($prototype, $file) = @_;
1259 my $func = "dump_".$decl_type;
1263 sub dump_union
($$) {
1267 sub dump_struct
($$) {
1271 if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) {
1272 $declaration_name = $2;
1275 # ignore embedded structs or unions
1276 $members =~ s/{.*?}//g;
1278 create_parameterlist
($members, ';', $file);
1280 output_declaration
($declaration_name,
1282 {'struct' => $declaration_name,
1283 'module' => $modulename,
1284 'parameterlist' => \
@parameterlist,
1285 'parameterdescs' => \
%parameterdescs,
1286 'parametertypes' => \
%parametertypes,
1287 'sectionlist' => \
@sectionlist,
1288 'sections' => \
%sections,
1289 'purpose' => $declaration_purpose,
1290 'type' => $decl_type
1294 print STDERR
"Error(${file}:$.): Cannot parse struct or union!\n";
1303 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1304 $declaration_name = $1;
1307 foreach my $arg (split ',', $members) {
1308 $arg =~ s/^\s*(\w+).*/$1/;
1309 push @parameterlist, $arg;
1310 if (!$parameterdescs{$arg}) {
1311 $parameterdescs{$arg} = $undescribed;
1312 print STDERR
"Warning(${file}:$.): Enum value '$arg' ".
1313 "not described in enum '$declaration_name'\n";
1318 output_declaration
($declaration_name,
1320 {'enum' => $declaration_name,
1321 'module' => $modulename,
1322 'parameterlist' => \
@parameterlist,
1323 'parameterdescs' => \
%parameterdescs,
1324 'sectionlist' => \
@sectionlist,
1325 'sections' => \
%sections,
1326 'purpose' => $declaration_purpose
1330 print STDERR
"Error(${file}:$.): Cannot parse enum!\n";
1335 sub dump_typedef
($$) {
1339 while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
1340 $x =~ s/\(*.\)\s*;$/;/;
1341 $x =~ s/\[*.\]\s*;$/;/;
1344 if ($x =~ /typedef.*\s+(\w+)\s*;/) {
1345 $declaration_name = $1;
1347 output_declaration
($declaration_name,
1349 {'typedef' => $declaration_name,
1350 'module' => $modulename,
1351 'sectionlist' => \
@sectionlist,
1352 'sections' => \
%sections,
1353 'purpose' => $declaration_purpose
1357 print STDERR
"Error(${file}:$.): Cannot parse typedef!\n";
1362 sub create_parameterlist
($$$) {
1364 my $splitter = shift;
1369 while ($args =~ /(\([^\),]+),/) {
1370 $args =~ s/(\([^\),]+),/$1#/g;
1373 foreach my $arg (split($splitter, $args)) {
1375 $arg =~ s/\/\*.*\*\///;
1376 # strip leading/trailing spaces
1382 # Treat preprocessor directive as a typeless variable just to fill
1383 # corresponding data structures "correctly". Catch it later in
1385 push_parameter
($arg, "", $file);
1386 } elsif ($arg =~ m/\(/) {
1387 # pointer-to-function
1389 $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
1392 $type =~ s/([^\(]+\(\*)$param/$1/;
1393 push_parameter
($param, $type, $file);
1395 $arg =~ s/\s*:\s*/:/g;
1396 $arg =~ s/\s*\[/\[/g;
1398 my @args = split('\s*,\s*', $arg);
1399 if ($args[0] =~ m/\*/) {
1400 $args[0] =~ s/(\*+)\s*/ $1/;
1402 my @first_arg = split('\s+', shift @args);
1403 unshift(@args, pop @first_arg);
1404 $type = join " ", @first_arg;
1406 foreach $param (@args) {
1407 if ($param =~ m/^(\*+)\s*(.*)/) {
1408 push_parameter
($2, "$type $1", $file);
1410 elsif ($param =~ m/(.*?):(\d+)/) {
1411 push_parameter
($1, "$type:$2", $file)
1414 push_parameter
($param, $type, $file);
1421 sub push_parameter
($$$) {
1426 my $param_name = $param;
1427 $param_name =~ s/\[.*//;
1429 if ($type eq "" && $param eq "...")
1433 $parameterdescs{"..."} = "variable arguments";
1435 elsif ($type eq "" && ($param eq "" or $param eq "void"))
1439 $parameterdescs{void
} = "no arguments";
1441 if (defined $type && $type && !defined $parameterdescs{$param_name}) {
1442 $parameterdescs{$param_name} = $undescribed;
1444 if (($type eq 'function') || ($type eq 'enum')) {
1445 print STDERR
"Warning(${file}:$.): Function parameter ".
1446 "or member '$param' not " .
1447 "described in '$declaration_name'\n";
1449 print STDERR
"Warning(${file}:$.):".
1450 " No description found for parameter '$param'\n";
1454 push @parameterlist, $param;
1455 $parametertypes{$param} = $type;
1459 # takes a function prototype and the name of the current file being
1460 # processed and spits out all the details stored in the global
1462 sub dump_function
($$) {
1463 my $prototype = shift;
1466 $prototype =~ s/^static +//;
1467 $prototype =~ s/^extern +//;
1468 $prototype =~ s/^inline +//;
1469 $prototype =~ s/^__inline__ +//;
1470 $prototype =~ s/^#define +//; #ak added
1471 $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//;
1473 # Yes, this truly is vile. We are looking for:
1474 # 1. Return type (may be nothing if we're looking at a macro)
1476 # 3. Function parameters.
1478 # All the while we have to watch out for function pointer parameters
1479 # (which IIRC is what the two sections are for), C types (these
1480 # regexps don't even start to express all the possibilities), and
1483 # If you mess with these regexps, it's a good idea to check that
1484 # the following functions' documentation still comes out right:
1485 # - parport_register_device (function pointer parameters)
1486 # - atomic_set (macro)
1487 # - pci_match_device (long return type)
1489 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1490 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1491 $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1492 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1493 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1494 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1495 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1496 $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1497 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1498 $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1499 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1500 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1501 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1502 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
1504 $declaration_name = $2;
1507 create_parameterlist
($args, ',', $file);
1509 print STDERR
"Error(${file}:$.): cannot understand prototype: '$prototype'\n";
1514 output_declaration
($declaration_name,
1516 {'function' => $declaration_name,
1517 'module' => $modulename,
1518 'functiontype' => $return_type,
1519 'parameterlist' => \
@parameterlist,
1520 'parameterdescs' => \
%parameterdescs,
1521 'parametertypes' => \
%parametertypes,
1522 'sectionlist' => \
@sectionlist,
1523 'sections' => \
%sections,
1524 'purpose' => $declaration_purpose
1528 sub process_file
($);
1530 # Read the file that maps relative names to absolute names for
1531 # separate source and object directories and for shadow trees.
1532 if (open(SOURCE_MAP
, "<.tmp_filelist.txt")) {
1533 my ($relname, $absname);
1534 while(<SOURCE_MAP
>) {
1536 ($relname, $absname) = (split())[0..1];
1537 $relname =~ s
:^/+::;
1538 $source_map{$relname} = $absname;
1544 open(FLIST
,"<$filelist") or die "Can't open file list $filelist";
1555 if ($verbose && $errors) {
1556 print STDERR
"$errors errors\n";
1558 if ($verbose && $warnings) {
1559 print STDERR
"$warnings warnings\n";
1567 %parameterdescs = ();
1568 %parametertypes = ();
1569 @parameterlist = ();
1577 sub process_state3_function
($$) {
1581 if ($x =~ m
#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) {
1584 elsif ($x =~ /([^\{]*)/) {
1587 if (($x =~ /\{/) || ($x =~ /\#define/) || ($x =~ /;/)) {
1588 $prototype =~ s@
/\*.*?\*/@
@gos; # strip comments.
1589 $prototype =~ s@
[\r\n]+@
@gos; # strip newlines/cr's.
1590 $prototype =~ s@
^\s
+@
@gos; # strip leading spaces
1591 dump_function
($prototype,$file);
1596 sub process_state3_type
($$) {
1600 $x =~ s@
/\*.*?\*/@
@gos; # strip comments.
1601 $x =~ s@
[\r\n]+@
@gos; # strip newlines/cr's.
1602 $x =~ s@
^\s
+@
@gos; # strip leading spaces
1603 $x =~ s@\s
+$@
@gos; # strip trailing spaces
1605 # To distinguish preprocessor directive from regular declaration later.
1610 if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
1611 $prototype .= $1 . $2;
1612 ($2 eq '{') && $brcount++;
1613 ($2 eq '}') && $brcount--;
1614 if (($2 eq ';') && ($brcount == 0)) {
1615 dump_declaration
($prototype,$file);
1627 # replace <, >, and &
1630 $text =~ s/\&/\\\\\\amp;/g;
1631 $text =~ s/\</\\\\\\lt;/g;
1632 $text =~ s/\>/\\\\\\gt;/g;
1636 sub process_file
($) {
1637 my ($file) = "$ENV{'SRCTREE'}@_";
1640 my $initial_section_counter = $section_counter;
1642 if (defined($source_map{$file})) {
1643 $file = $source_map{$file};
1646 if (!open(IN
,"<$file")) {
1647 print STDERR
"Error: Cannot open file $file\n";
1652 $section_counter = 0;
1655 if (/$doc_start/o) {
1656 $state = 1; # next line is always the function name
1658 } elsif ($state == 1) { # this line is the function name (always)
1659 if (/$doc_block/o) {
1663 $section = $section_intro;
1668 elsif (/$doc_decl/o) {
1670 if (/\s*([\w\s]+?)\s*-/) {
1676 $declaration_purpose = xml_escape
($1);
1678 $declaration_purpose = "";
1680 if ($identifier =~ m/^struct/) {
1681 $decl_type = 'struct';
1682 } elsif ($identifier =~ m/^union/) {
1683 $decl_type = 'union';
1684 } elsif ($identifier =~ m/^enum/) {
1685 $decl_type = 'enum';
1686 } elsif ($identifier =~ m/^typedef/) {
1687 $decl_type = 'typedef';
1689 $decl_type = 'function';
1693 print STDERR
"Info(${file}:$.): Scanning doc for $identifier\n";
1696 print STDERR
"Warning(${file}:$.): Cannot understand $_ on line $.",
1697 " - I thought it was a doc line\n";
1701 } elsif ($state == 2) { # look for head: lines, and include content
1706 if ($contents ne "") {
1707 dump_section
($section, xml_escape
($contents));
1708 $section = $section_default;
1711 $contents = $newcontents;
1712 if ($contents ne "") {
1715 $section = $newsection;
1716 } elsif (/$doc_end/) {
1718 if ($contents ne "") {
1719 dump_section
($section, xml_escape
($contents));
1720 $section = $section_default;
1727 # print STDERR "end of doc comment, looking for prototype\n";
1728 } elsif (/$doc_content/) {
1729 # miguel-style comment kludge, look for blank lines after
1730 # @parameter line to signify start of description
1732 ($section =~ m/^@/ || $section eq $section_context)) {
1733 dump_section
($section, xml_escape
($contents));
1734 $section = $section_default;
1737 $contents .= $1."\n";
1740 # i dont know - bad line? ignore.
1741 print STDERR
"Warning(${file}:$.): bad line: $_";
1744 } elsif ($state == 3) { # scanning for function { (end of prototype)
1745 if ($decl_type eq 'function') {
1746 process_state3_function
($_, $file);
1748 process_state3_type
($_, $file);
1750 } elsif ($state == 4) {
1751 # Documentation block
1753 dump_section
($section, $contents);
1754 output_intro
({'sectionlist' => \
@sectionlist,
1755 'sections' => \
%sections });
1759 %parameterdescs = ();
1760 %parametertypes = ();
1761 @parameterlist = ();
1766 $section = $section_intro;
1773 dump_section
($section, $contents);
1774 output_intro
({'sectionlist' => \
@sectionlist,
1775 'sections' => \
%sections });
1779 %parameterdescs = ();
1780 %parametertypes = ();
1781 @parameterlist = ();
1787 elsif (/$doc_content/)
1791 $contents .= $blankline;
1795 $contents .= $1 . "\n";
1800 if ($initial_section_counter == $section_counter) {
1801 print STDERR
"Warning(${file}): no structured comments found\n";
1802 if ($output_mode eq "xml") {
1803 # The template wants at least one RefEntry here; make one.
1804 print "<refentry>\n";
1805 print " <refnamediv>\n";
1806 print " <refname>\n";
1808 print " </refname>\n";
1809 print " <refpurpose>\n";
1810 print " Document generation inconsistency\n";
1811 print " </refpurpose>\n";
1812 print " </refnamediv>\n";
1813 print " <refsect1>\n";
1816 print " </title>\n";
1817 print " <warning>\n";
1819 print " The template for this document tried to insert\n";
1820 print " the structured comment from the file\n";
1821 print " <filename>${file}</filename> at this point,\n";
1822 print " but none was found.\n";
1823 print " This dummy section is inserted to allow\n";
1824 print " generation to continue.\n";
1826 print " </warning>\n";
1827 print " </refsect1>\n";
1828 print "</refentry>\n";