]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - scripts/kernel-doc
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";
557 print "<title>$section</title>\n";
558 if ($section =~ m/EXAMPLE/i) {
559 print "<informalexample><programlisting>\n";
563 output_highlight
($args{'sections'}{$section});
564 if ($section =~ m/EXAMPLE/i) {
565 print "</programlisting></informalexample>\n";
569 print "</refsect1>\n";
573 # output function in XML DocBook
574 sub output_function_xml
(%) {
576 my ($parameter, $section);
580 $id = "API-".$args{'function'};
581 $id =~ s/[^A-Za-z0-9]/-/g;
583 print "<refentry>\n";
585 print "<refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle
>\n";
586 print "</refmeta
>\n";
587 print "<refnamediv
>\n";
588 print " <refname
>".$args{'function'}."</refname
>\n";
589 print " <refpurpose
>\n";
591 output_highlight ($args{'purpose'});
592 print " </refpurpose
>\n";
593 print "</refnamediv
>\n";
595 print "<refsynopsisdiv
>\n";
596 print " <title
>Synopsis
</title
>\n";
597 print " <funcsynopsis
><funcprototype
>\n";
598 print " <funcdef
>".$args{'functiontype'}." ";
599 print "<function
>".$args{'function'}." </function></funcdef
>\n";
602 if ($#{$args{'parameterlist'}} >= 0) {
603 foreach $parameter (@{$args{'parameterlist'}}) {
604 $type = $args{'parametertypes'}{$parameter};
605 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
606 # pointer-to-function
607 print " <paramdef
>$1<parameter
>$parameter</parameter
>)\n";
608 print " <funcparams
>$2</funcparams></paramdef
>\n";
610 print " <paramdef
>".$type;
611 print " <parameter
>$parameter</parameter></paramdef
>\n";
617 print " </funcprototype></funcsynopsis
>\n";
618 print "</refsynopsisdiv
>\n";
621 print "<refsect1
>\n <title
>Arguments
</title
>\n";
622 if ($#{$args{'parameterlist'}} >= 0) {
623 print " <variablelist
>\n";
624 foreach $parameter (@{$args{'parameterlist'}}) {
625 my $parameter_name = $parameter;
626 $parameter_name =~ s/\[.*//;
628 print " <varlistentry
>\n <term
><parameter
>$parameter</parameter></term
>\n";
629 print " <listitem
>\n <para
>\n";
631 output_highlight($args{'parameterdescs'}{$parameter_name});
632 print " </para>\n </listitem
>\n </varlistentry
>\n";
634 print " </variablelist
>\n";
636 print " <para
>\n None
\n </para
>\n";
638 print "</refsect1
>\n";
640 output_section_xml(@_);
641 print "</refentry
>\n\n";
644 # output struct in XML DocBook
645 sub output_struct_xml(%) {
647 my ($parameter, $section);
650 $id = "API-struct-
".$args{'struct'};
651 $id =~ s/[^A-Za-z0-9]/-/g;
653 print "<refentry
>\n";
655 print "<refentrytitle
><phrase id
=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
656 print "</refmeta>\n";
657 print "<refnamediv>\n";
658 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n";
659 print " <refpurpose>\n";
661 output_highlight
($args{'purpose'});
662 print " </refpurpose>\n";
663 print "</refnamediv>\n";
665 print "<refsynopsisdiv>\n";
666 print " <title>Synopsis</title>\n";
667 print " <programlisting>\n";
668 print $args{'type'}." ".$args{'struct'}." {\n";
669 foreach $parameter (@{$args{'parameterlist'}}) {
670 if ($parameter =~ /^#/) {
671 print "$parameter\n";
675 my $parameter_name = $parameter;
676 $parameter_name =~ s/\[.*//;
678 defined($args{'parameterdescs'}{$parameter_name}) || next;
679 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
680 $type = $args{'parametertypes'}{$parameter};
681 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
682 # pointer-to-function
683 print " $1 $parameter) ($2);\n";
684 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
685 print " $1 $parameter$2;\n";
687 print " ".$type." ".$parameter.";\n";
691 print " </programlisting>\n";
692 print "</refsynopsisdiv>\n";
694 print " <refsect1>\n";
695 print " <title>Members</title>\n";
697 print " <variablelist>\n";
698 foreach $parameter (@{$args{'parameterlist'}}) {
699 ($parameter =~ /^#/) && next;
701 my $parameter_name = $parameter;
702 $parameter_name =~ s/\[.*//;
704 defined($args{'parameterdescs'}{$parameter_name}) || next;
705 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
706 print " <varlistentry>";
707 print " <term>$parameter</term>\n";
708 print " <listitem><para>\n";
709 output_highlight
($args{'parameterdescs'}{$parameter_name});
710 print " </para></listitem>\n";
711 print " </varlistentry>\n";
713 print " </variablelist>\n";
714 print " </refsect1>\n";
716 output_section_xml
(@_);
718 print "</refentry>\n\n";
721 # output enum in XML DocBook
722 sub output_enum_xml
(%) {
724 my ($parameter, $section);
728 $id = "API-enum-".$args{'enum'};
729 $id =~ s/[^A-Za-z0-9]/-/g;
731 print "<refentry>\n";
733 print "<refentrytitle><phrase id=\"$id\">enum
".$args{'enum'}."</phrase></refentrytitle
>\n";
734 print "</refmeta
>\n";
735 print "<refnamediv
>\n";
736 print " <refname
>enum
".$args{'enum'}."</refname
>\n";
737 print " <refpurpose
>\n";
739 output_highlight ($args{'purpose'});
740 print " </refpurpose
>\n";
741 print "</refnamediv
>\n";
743 print "<refsynopsisdiv
>\n";
744 print " <title
>Synopsis
</title
>\n";
745 print " <programlisting
>\n";
746 print "enum
".$args{'enum'}." {\n";
748 foreach $parameter (@{$args{'parameterlist'}}) {
750 if ($count != $#{$args{'parameterlist'}}) {
757 print " </programlisting
>\n";
758 print "</refsynopsisdiv
>\n";
760 print "<refsect1
>\n";
761 print " <title
>Constants
</title
>\n";
762 print " <variablelist
>\n";
763 foreach $parameter (@{$args{'parameterlist'}}) {
764 my $parameter_name = $parameter;
765 $parameter_name =~ s/\[.*//;
767 print " <varlistentry
>";
768 print " <term
>$parameter</term
>\n";
769 print " <listitem
><para
>\n";
770 output_highlight($args{'parameterdescs'}{$parameter_name});
771 print " </para></listitem
>\n";
772 print " </varlistentry
>\n";
774 print " </variablelist
>\n";
775 print "</refsect1
>\n";
777 output_section_xml(@_);
779 print "</refentry
>\n\n";
782 # output typedef in XML DocBook
783 sub output_typedef_xml(%) {
785 my ($parameter, $section);
788 $id = "API-typedef-
".$args{'typedef'};
789 $id =~ s/[^A-Za-z0-9]/-/g;
791 print "<refentry
>\n";
793 print "<refentrytitle
><phrase id
=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
794 print "</refmeta>\n";
795 print "<refnamediv>\n";
796 print " <refname>typedef ".$args{'typedef'}."</refname>\n";
797 print " <refpurpose>\n";
799 output_highlight
($args{'purpose'});
800 print " </refpurpose>\n";
801 print "</refnamediv>\n";
803 print "<refsynopsisdiv>\n";
804 print " <title>Synopsis</title>\n";
805 print " <synopsis>typedef ".$args{'typedef'}.";</synopsis>\n";
806 print "</refsynopsisdiv>\n";
808 output_section_xml
(@_);
810 print "</refentry>\n\n";
813 # output in XML DocBook
814 sub output_intro_xml
(%) {
816 my ($parameter, $section);
819 my $id = $args{'module'};
820 $id =~ s/[^A-Za-z0-9]/-/g;
822 # print out each section
824 foreach $section (@{$args{'sectionlist'}}) {
825 print "<refsect1>\n <title>$section</title>\n <para>\n";
826 if ($section =~ m/EXAMPLE/i) {
827 print "<example><para>\n";
829 output_highlight
($args{'sections'}{$section});
830 if ($section =~ m/EXAMPLE/i) {
831 print "</para></example>\n";
833 print " </para>\n</refsect1>\n";
839 # output in XML DocBook
840 sub output_function_gnome
{
842 my ($parameter, $section);
846 $id = $args{'module'}."-".$args{'function'};
847 $id =~ s/[^A-Za-z0-9]/-/g;
850 print " <title id=\"$id\">".$args{'function'}."</title
>\n";
852 print " <funcsynopsis
>\n";
853 print " <funcdef
>".$args{'functiontype'}." ";
854 print "<function
>".$args{'function'}." ";
855 print "</function></funcdef
>\n";
858 if ($#{$args{'parameterlist'}} >= 0) {
859 foreach $parameter (@{$args{'parameterlist'}}) {
860 $type = $args{'parametertypes'}{$parameter};
861 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
862 # pointer-to-function
863 print " <paramdef
>$1 <parameter
>$parameter</parameter
>)\n";
864 print " <funcparams
>$2</funcparams></paramdef
>\n";
866 print " <paramdef
>".$type;
867 print " <parameter
>$parameter</parameter></paramdef
>\n";
873 print " </funcsynopsis
>\n";
874 if ($#{$args{'parameterlist'}} >= 0) {
875 print " <informaltable pgwide
=\"1\" frame
=\"none
\" role=\"params
\">\n";
876 print "<tgroup cols
=\"2\">\n";
877 print "<colspec colwidth
=\"2*\">\n";
878 print "<colspec colwidth
=\"8*\">\n";
880 foreach $parameter (@{$args{'parameterlist'}}) {
881 my $parameter_name = $parameter;
882 $parameter_name =~ s/\[.*//;
884 print " <row
><entry align
=\"right
\"><parameter
>$parameter</parameter></entry
>\n";
887 output_highlight($args{'parameterdescs'}{$parameter_name});
888 print " </entry></row
>\n";
890 print " </tbody></tgroup
></informaltable
>\n";
892 print " <para
>\n None
\n </para
>\n";
895 # print out each section
897 foreach $section (@{$args{'sectionlist'}}) {
898 print "<simplesect
>\n <title
>$section</title
>\n";
899 if ($section =~ m/EXAMPLE/i) {
900 print "<example
><programlisting
>\n";
904 output_highlight($args{'sections'}{$section});
906 if ($section =~ m/EXAMPLE/i) {
907 print "</programlisting></example
>\n";
910 print " </simplesect
>\n";
913 print "</sect2
>\n\n";
917 # output function in man
918 sub output_function_man(%) {
920 my ($parameter, $section);
923 print ".TH
\"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n";
926 print $args{'function'}." \\- ".$args{'purpose'}."\n";
928 print ".SH SYNOPSIS\n";
929 print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";
933 foreach my $parameter (@{$args{'parameterlist'}}) {
934 if ($count == $#{$args{'parameterlist'}}) {
937 $type = $args{'parametertypes'}{$parameter};
938 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
939 # pointer-to-function
940 print ".BI \"".$parenth.$1."\" ".$parameter." \") (".$2.")".$post."\"\n";
942 $type =~ s/([^\*])$/$1 /;
943 print ".BI \"".$parenth.$type."\" ".$parameter." \"".$post."\"\n";
949 print ".SH ARGUMENTS\n";
950 foreach $parameter (@{$args{'parameterlist'}}) {
951 my $parameter_name = $parameter;
952 $parameter_name =~ s/\[.*//;
954 print ".IP \"".$parameter."\" 12\n";
955 output_highlight
($args{'parameterdescs'}{$parameter_name});
957 foreach $section (@{$args{'sectionlist'}}) {
958 print ".SH \"", uc $section, "\"\n";
959 output_highlight
($args{'sections'}{$section});
965 sub output_enum_man
(%) {
967 my ($parameter, $section);
970 print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual
\" LINUX
\n";
973 print "enum
".$args{'enum'}." \\- ".$args{'purpose'}."\n";
975 print ".SH SYNOPSIS
\n";
976 print "enum
".$args{'enum'}." {\n";
978 foreach my $parameter (@{$args{'parameterlist'}}) {
979 print ".br
\n.BI
\" $parameter\"\n";
980 if ($count == $#{$args{'parameterlist'}}) {
990 print ".SH Constants\n";
991 foreach $parameter (@{$args{'parameterlist'}}) {
992 my $parameter_name = $parameter;
993 $parameter_name =~ s/\[.*//;
995 print ".IP \"".$parameter."\" 12\n";
996 output_highlight
($args{'parameterdescs'}{$parameter_name});
998 foreach $section (@{$args{'sectionlist'}}) {
999 print ".SH \"$section\"\n";
1000 output_highlight($args{'sections'}{$section});
1005 # output struct in man
1006 sub output_struct_man(%) {
1007 my %args = %{$_[0]};
1008 my ($parameter, $section);
1010 print ".TH
\"$args{'module'}\" 9 \"".$args{'type'}." ".$args{'struct'}."\" \"$man_date\" \"API Manual\" LINUX\n";
1013 print $args{'type'}." ".$args{'struct'}." \\- ".$args{'purpose'}."\n";
1015 print ".SH SYNOPSIS\n";
1016 print $args{'type'}." ".$args{'struct'}." {\n.br\n";
1018 foreach my $parameter (@{$args{'parameterlist'}}) {
1019 if ($parameter =~ /^#/) {
1020 print ".BI \"$parameter\"\n.br
\n";
1023 my $parameter_name = $parameter;
1024 $parameter_name =~ s/\[.*//;
1026 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1027 $type = $args{'parametertypes'}{$parameter};
1028 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1029 # pointer-to-function
1030 print ".BI
\" ".$1."\" ".$parameter." \") (".$2.")"."\"\n;\n";
1031 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1032 print ".BI
\" ".$1."\" ".$parameter.$2." \""."\"\n;\n";
1034 $type =~ s/([^\*])$/$1 /;
1035 print ".BI
\" ".$type."\" ".$parameter." \""."\"\n;\n";
1041 print ".SH Arguments
\n";
1042 foreach $parameter (@{$args{'parameterlist'}}) {
1043 ($parameter =~ /^#/) && next;
1045 my $parameter_name = $parameter;
1046 $parameter_name =~ s/\[.*//;
1048 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1049 print ".IP
\"".$parameter."\" 12\n";
1050 output_highlight($args{'parameterdescs'}{$parameter_name});
1052 foreach $section (@{$args{'sectionlist'}}) {
1053 print ".SH
\"$section\"\n";
1054 output_highlight
($args{'sections'}{$section});
1059 # output typedef in man
1060 sub output_typedef_man
(%) {
1061 my %args = %{$_[0]};
1062 my ($parameter, $section);
1064 print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual
\" LINUX
\n";
1067 print "typedef
".$args{'typedef'}." \\- ".$args{'purpose'}."\n";
1069 foreach $section (@{$args{'sectionlist'}}) {
1070 print ".SH
\"$section\"\n";
1071 output_highlight
($args{'sections'}{$section});
1075 sub output_intro_man
(%) {
1076 my %args = %{$_[0]};
1077 my ($parameter, $section);
1080 print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual
\" LINUX
\n";
1082 foreach $section (@{$args{'sectionlist'}}) {
1083 print ".SH
\"$section\"\n";
1084 output_highlight
($args{'sections'}{$section});
1090 sub output_function_text
(%) {
1091 my %args = %{$_[0]};
1092 my ($parameter, $section);
1094 print "Function:\n\n";
1095 my $start=$args{'functiontype'}." ".$args{'function'}." (";
1098 foreach my $parameter (@{$args{'parameterlist'}}) {
1099 $type = $args{'parametertypes'}{$parameter};
1100 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1101 # pointer-to-function
1102 print $1.$parameter.") (".$2;
1104 print $type." ".$parameter;
1106 if ($count != $#{$args{'parameterlist'}}) {
1109 print " " x
length($start);
1115 print "Arguments:\n\n";
1116 foreach $parameter (@{$args{'parameterlist'}}) {
1117 my $parameter_name = $parameter;
1118 $parameter_name =~ s/\[.*//;
1120 print $parameter."\n\t".$args{'parameterdescs'}{$parameter_name}."\n";
1122 output_section_text
(@_);
1125 #output sections in text
1126 sub output_section_text
(%) {
1127 my %args = %{$_[0]};
1131 foreach $section (@{$args{'sectionlist'}}) {
1132 print "$section:\n\n";
1133 output_highlight
($args{'sections'}{$section});
1138 # output enum in text
1139 sub output_enum_text
(%) {
1140 my %args = %{$_[0]};
1145 print "enum ".$args{'enum'}." {\n";
1147 foreach $parameter (@{$args{'parameterlist'}}) {
1148 print "\t$parameter";
1149 if ($count != $#{$args{'parameterlist'}}) {
1157 print "Constants:\n\n";
1158 foreach $parameter (@{$args{'parameterlist'}}) {
1159 print "$parameter\n\t";
1160 print $args{'parameterdescs'}{$parameter}."\n";
1163 output_section_text
(@_);
1166 # output typedef in text
1167 sub output_typedef_text
(%) {
1168 my %args = %{$_[0]};
1171 print "Typedef:\n\n";
1173 print "typedef ".$args{'typedef'}."\n";
1174 output_section_text
(@_);
1177 # output struct as text
1178 sub output_struct_text
(%) {
1179 my %args = %{$_[0]};
1182 print $args{'type'}." ".$args{'struct'}.":\n\n";
1183 print $args{'type'}." ".$args{'struct'}." {\n";
1184 foreach $parameter (@{$args{'parameterlist'}}) {
1185 if ($parameter =~ /^#/) {
1186 print "$parameter\n";
1190 my $parameter_name = $parameter;
1191 $parameter_name =~ s/\[.*//;
1193 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1194 $type = $args{'parametertypes'}{$parameter};
1195 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1196 # pointer-to-function
1197 print "\t$1 $parameter) ($2);\n";
1198 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1199 print "\t$1 $parameter$2;\n";
1201 print "\t".$type." ".$parameter.";\n";
1206 print "Members:\n\n";
1207 foreach $parameter (@{$args{'parameterlist'}}) {
1208 ($parameter =~ /^#/) && next;
1210 my $parameter_name = $parameter;
1211 $parameter_name =~ s/\[.*//;
1213 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1214 print "$parameter\n\t";
1215 print $args{'parameterdescs'}{$parameter_name}."\n";
1218 output_section_text
(@_);
1221 sub output_intro_text
(%) {
1222 my %args = %{$_[0]};
1223 my ($parameter, $section);
1225 foreach $section (@{$args{'sectionlist'}}) {
1226 print " $section:\n";
1228 output_highlight
($args{'sections'}{$section});
1233 # generic output function for typedefs
1234 sub output_declaration
{
1237 my $functype = shift;
1238 my $func = "output_${functype}_$output_mode";
1239 if (($function_only==0) ||
1240 ( $function_only == 1 && defined($function_table{$name})) ||
1241 ( $function_only == 2 && !defined($function_table{$name})))
1249 # generic output function - calls the right one based
1250 # on current output mode.
1253 my $func = "output_intro_".$output_mode;
1259 # takes a declaration (struct, union, enum, typedef) and
1260 # invokes the right handler. NOT called for functions.
1261 sub dump_declaration
($$) {
1263 my ($prototype, $file) = @_;
1264 my $func = "dump_".$decl_type;
1268 sub dump_union
($$) {
1272 sub dump_struct
($$) {
1276 if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) {
1277 $declaration_name = $2;
1280 # ignore embedded structs or unions
1281 $members =~ s/{.*?}//g;
1283 create_parameterlist
($members, ';', $file);
1285 output_declaration
($declaration_name,
1287 {'struct' => $declaration_name,
1288 'module' => $modulename,
1289 'parameterlist' => \
@parameterlist,
1290 'parameterdescs' => \
%parameterdescs,
1291 'parametertypes' => \
%parametertypes,
1292 'sectionlist' => \
@sectionlist,
1293 'sections' => \
%sections,
1294 'purpose' => $declaration_purpose,
1295 'type' => $decl_type
1299 print STDERR
"Error(${file}:$.): Cannot parse struct or union!\n";
1308 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1309 $declaration_name = $1;
1312 foreach my $arg (split ',', $members) {
1313 $arg =~ s/^\s*(\w+).*/$1/;
1314 push @parameterlist, $arg;
1315 if (!$parameterdescs{$arg}) {
1316 $parameterdescs{$arg} = $undescribed;
1317 print STDERR
"Warning(${file}:$.): Enum value '$arg' ".
1318 "not described in enum '$declaration_name'\n";
1323 output_declaration
($declaration_name,
1325 {'enum' => $declaration_name,
1326 'module' => $modulename,
1327 'parameterlist' => \
@parameterlist,
1328 'parameterdescs' => \
%parameterdescs,
1329 'sectionlist' => \
@sectionlist,
1330 'sections' => \
%sections,
1331 'purpose' => $declaration_purpose
1335 print STDERR
"Error(${file}:$.): Cannot parse enum!\n";
1340 sub dump_typedef
($$) {
1344 while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
1345 $x =~ s/\(*.\)\s*;$/;/;
1346 $x =~ s/\[*.\]\s*;$/;/;
1349 if ($x =~ /typedef.*\s+(\w+)\s*;/) {
1350 $declaration_name = $1;
1352 output_declaration
($declaration_name,
1354 {'typedef' => $declaration_name,
1355 'module' => $modulename,
1356 'sectionlist' => \
@sectionlist,
1357 'sections' => \
%sections,
1358 'purpose' => $declaration_purpose
1362 print STDERR
"Error(${file}:$.): Cannot parse typedef!\n";
1367 sub create_parameterlist
($$$) {
1369 my $splitter = shift;
1374 while ($args =~ /(\([^\),]+),/) {
1375 $args =~ s/(\([^\),]+),/$1#/g;
1378 foreach my $arg (split($splitter, $args)) {
1380 $arg =~ s/\/\*.*\*\///;
1381 # strip leading/trailing spaces
1387 # Treat preprocessor directive as a typeless variable just to fill
1388 # corresponding data structures "correctly". Catch it later in
1390 push_parameter
($arg, "", $file);
1391 } elsif ($arg =~ m/\(/) {
1392 # pointer-to-function
1394 $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
1397 $type =~ s/([^\(]+\(\*)$param/$1/;
1398 push_parameter
($param, $type, $file);
1400 $arg =~ s/\s*:\s*/:/g;
1401 $arg =~ s/\s*\[/\[/g;
1403 my @args = split('\s*,\s*', $arg);
1404 if ($args[0] =~ m/\*/) {
1405 $args[0] =~ s/(\*+)\s*/ $1/;
1407 my @first_arg = split('\s+', shift @args);
1408 unshift(@args, pop @first_arg);
1409 $type = join " ", @first_arg;
1411 foreach $param (@args) {
1412 if ($param =~ m/^(\*+)\s*(.*)/) {
1413 push_parameter
($2, "$type $1", $file);
1415 elsif ($param =~ m/(.*?):(\d+)/) {
1416 push_parameter
($1, "$type:$2", $file)
1419 push_parameter
($param, $type, $file);
1426 sub push_parameter
($$$) {
1431 my $param_name = $param;
1432 $param_name =~ s/\[.*//;
1434 if ($type eq "" && $param eq "...")
1438 $parameterdescs{"..."} = "variable arguments";
1440 elsif ($type eq "" && ($param eq "" or $param eq "void"))
1444 $parameterdescs{void
} = "no arguments";
1446 if (defined $type && $type && !defined $parameterdescs{$param_name}) {
1447 $parameterdescs{$param_name} = $undescribed;
1449 if (($type eq 'function') || ($type eq 'enum')) {
1450 print STDERR
"Warning(${file}:$.): Function parameter ".
1451 "or member '$param' not " .
1452 "described in '$declaration_name'\n";
1454 print STDERR
"Warning(${file}:$.):".
1455 " No description found for parameter '$param'\n";
1459 push @parameterlist, $param;
1460 $parametertypes{$param} = $type;
1464 # takes a function prototype and the name of the current file being
1465 # processed and spits out all the details stored in the global
1467 sub dump_function
($$) {
1468 my $prototype = shift;
1471 $prototype =~ s/^static +//;
1472 $prototype =~ s/^extern +//;
1473 $prototype =~ s/^fastcall +//;
1474 $prototype =~ s/^asmlinkage +//;
1475 $prototype =~ s/^inline +//;
1476 $prototype =~ s/^__inline__ +//;
1477 $prototype =~ s/^#define +//; #ak added
1478 $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//;
1480 # Yes, this truly is vile. We are looking for:
1481 # 1. Return type (may be nothing if we're looking at a macro)
1483 # 3. Function parameters.
1485 # All the while we have to watch out for function pointer parameters
1486 # (which IIRC is what the two sections are for), C types (these
1487 # regexps don't even start to express all the possibilities), and
1490 # If you mess with these regexps, it's a good idea to check that
1491 # the following functions' documentation still comes out right:
1492 # - parport_register_device (function pointer parameters)
1493 # - atomic_set (macro)
1494 # - pci_match_device (long return type)
1496 if ($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*\(([^\(]*)\)/ ||
1503 $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1504 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1505 $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1506 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1507 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1508 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1509 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
1511 $declaration_name = $2;
1514 create_parameterlist
($args, ',', $file);
1516 print STDERR
"Error(${file}:$.): cannot understand prototype: '$prototype'\n";
1521 output_declaration
($declaration_name,
1523 {'function' => $declaration_name,
1524 'module' => $modulename,
1525 'functiontype' => $return_type,
1526 'parameterlist' => \
@parameterlist,
1527 'parameterdescs' => \
%parameterdescs,
1528 'parametertypes' => \
%parametertypes,
1529 'sectionlist' => \
@sectionlist,
1530 'sections' => \
%sections,
1531 'purpose' => $declaration_purpose
1535 sub process_file
($);
1537 # Read the file that maps relative names to absolute names for
1538 # separate source and object directories and for shadow trees.
1539 if (open(SOURCE_MAP
, "<.tmp_filelist.txt")) {
1540 my ($relname, $absname);
1541 while(<SOURCE_MAP
>) {
1543 ($relname, $absname) = (split())[0..1];
1544 $relname =~ s
:^/+::;
1545 $source_map{$relname} = $absname;
1551 open(FLIST
,"<$filelist") or die "Can't open file list $filelist";
1562 if ($verbose && $errors) {
1563 print STDERR
"$errors errors\n";
1565 if ($verbose && $warnings) {
1566 print STDERR
"$warnings warnings\n";
1574 %parameterdescs = ();
1575 %parametertypes = ();
1576 @parameterlist = ();
1584 sub process_state3_function
($$) {
1588 if ($x =~ m
#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) {
1591 elsif ($x =~ /([^\{]*)/) {
1594 if (($x =~ /\{/) || ($x =~ /\#define/) || ($x =~ /;/)) {
1595 $prototype =~ s
@/\*.*?\
*/@@gos; # strip comments.
1596 $prototype =~ s
@[\r\n]+@ @gos; # strip newlines/cr's.
1597 $prototype =~ s
@^\s+@@gos; # strip leading spaces
1598 dump_function
($prototype,$file);
1603 sub process_state3_type
($$) {
1607 $x =~ s
@/\*.*?\
*/@@gos; # strip comments.
1608 $x =~ s
@[\r\n]+@ @gos; # strip newlines/cr's.
1609 $x =~ s
@^\s+@@gos; # strip leading spaces
1610 $x =~ s
@\s+$@@gos; # strip trailing spaces
1612 # To distinguish preprocessor directive from regular declaration later.
1617 if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
1618 $prototype .= $1 . $2;
1619 ($2 eq '{') && $brcount++;
1620 ($2 eq '}') && $brcount--;
1621 if (($2 eq ';') && ($brcount == 0)) {
1622 dump_declaration
($prototype,$file);
1634 # replace <, >, and &
1637 $text =~ s/\&/\\\\\\amp;/g;
1638 $text =~ s/\</\\\\\\lt;/g;
1639 $text =~ s/\>/\\\\\\gt;/g;
1643 sub process_file
($) {
1644 my ($file) = "$ENV{'SRCTREE'}@_";
1647 my $initial_section_counter = $section_counter;
1649 if (defined($source_map{$file})) {
1650 $file = $source_map{$file};
1653 if (!open(IN
,"<$file")) {
1654 print STDERR
"Error: Cannot open file $file\n";
1659 $section_counter = 0;
1662 if (/$doc_start/o) {
1663 $state = 1; # next line is always the function name
1665 } elsif ($state == 1) { # this line is the function name (always)
1666 if (/$doc_block/o) {
1670 $section = $section_intro;
1675 elsif (/$doc_decl/o) {
1677 if (/\s*([\w\s]+?)\s*-/) {
1683 $declaration_purpose = xml_escape
($1);
1685 $declaration_purpose = "";
1687 if ($identifier =~ m/^struct/) {
1688 $decl_type = 'struct';
1689 } elsif ($identifier =~ m/^union/) {
1690 $decl_type = 'union';
1691 } elsif ($identifier =~ m/^enum/) {
1692 $decl_type = 'enum';
1693 } elsif ($identifier =~ m/^typedef/) {
1694 $decl_type = 'typedef';
1696 $decl_type = 'function';
1700 print STDERR
"Info(${file}:$.): Scanning doc for $identifier\n";
1703 print STDERR
"Warning(${file}:$.): Cannot understand $_ on line $.",
1704 " - I thought it was a doc line\n";
1708 } elsif ($state == 2) { # look for head: lines, and include content
1713 if ($contents ne "") {
1714 dump_section
($section, xml_escape
($contents));
1715 $section = $section_default;
1718 $contents = $newcontents;
1719 if ($contents ne "") {
1722 $section = $newsection;
1723 } elsif (/$doc_end/) {
1725 if ($contents ne "") {
1726 dump_section
($section, xml_escape
($contents));
1727 $section = $section_default;
1734 # print STDERR "end of doc comment, looking for prototype\n";
1735 } elsif (/$doc_content/) {
1736 # miguel-style comment kludge, look for blank lines after
1737 # @parameter line to signify start of description
1739 ($section =~ m/^@/ || $section eq $section_context)) {
1740 dump_section
($section, xml_escape
($contents));
1741 $section = $section_default;
1744 $contents .= $1."\n";
1747 # i dont know - bad line? ignore.
1748 print STDERR
"Warning(${file}:$.): bad line: $_";
1751 } elsif ($state == 3) { # scanning for function { (end of prototype)
1752 if ($decl_type eq 'function') {
1753 process_state3_function
($_, $file);
1755 process_state3_type
($_, $file);
1757 } elsif ($state == 4) {
1758 # Documentation block
1760 dump_section
($section, $contents);
1761 output_intro
({'sectionlist' => \
@sectionlist,
1762 'sections' => \
%sections });
1766 %parameterdescs = ();
1767 %parametertypes = ();
1768 @parameterlist = ();
1773 $section = $section_intro;
1780 dump_section
($section, $contents);
1781 output_intro
({'sectionlist' => \
@sectionlist,
1782 'sections' => \
%sections });
1786 %parameterdescs = ();
1787 %parametertypes = ();
1788 @parameterlist = ();
1794 elsif (/$doc_content/)
1798 $contents .= $blankline;
1802 $contents .= $1 . "\n";
1807 if ($initial_section_counter == $section_counter) {
1808 print STDERR
"Warning(${file}): no structured comments found\n";
1809 if ($output_mode eq "xml") {
1810 # The template wants at least one RefEntry here; make one.
1811 print "<refentry>\n";
1812 print " <refnamediv>\n";
1813 print " <refname>\n";
1815 print " </refname>\n";
1816 print " <refpurpose>\n";
1817 print " Document generation inconsistency\n";
1818 print " </refpurpose>\n";
1819 print " </refnamediv>\n";
1820 print " <refsect1>\n";
1823 print " </title>\n";
1824 print " <warning>\n";
1826 print " The template for this document tried to insert\n";
1827 print " the structured comment from the file\n";
1828 print " <filename>${file}</filename> at this point,\n";
1829 print " but none was found.\n";
1830 print " This dummy section is inserted to allow\n";
1831 print " generation to continue.\n";
1833 print " </warning>\n";
1834 print " </refsect1>\n";
1835 print "</refentry>\n";