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 ##
8 ## Copyright (C) 2005-2012 Randy Dunlap ##
9 ## Copyright (C) 2012 Dan Luedtke ##
11 ## #define enhancements by Armin Kuster <akuster@mvista.com> ##
12 ## Copyright (c) 2000 MontaVista Software, Inc. ##
14 ## This software falls under the GNU General Public License. ##
15 ## Please read the COPYING file for more information ##
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>
39 # 25/07/2012 - Added support for HTML5
40 # -- Dan Luedtke <mail@danrl.de>
43 # This will read a 'c' file and scan for embedded comments in the
44 # style of gnome comments (+minor extensions - see below).
47 # Note: This only supports 'c'.
50 # kernel-doc [ -docbook | -html | -html5 | -text | -man | -list ]
51 # [ -no-doc-sections ]
52 # [ -function funcname [ -function funcname ...] ]
53 # c file(s)s > outputfile
55 # [ -nofunction funcname [ -function funcname ...] ]
56 # c file(s)s > outputfile
58 # Set output format using one of -docbook -html -html5 -text or -man.
60 # The -list format is for internal use by docproc.
63 # Do not output DOC: sections
66 # If set, then only generate documentation for the given function(s) or
67 # DOC: section titles. All other functions and DOC: sections are ignored.
69 # -nofunction funcname
70 # If set, then only generate documentation for the other function(s)/DOC:
71 # sections. Cannot be used together with -function (yes, that's a bug --
72 # perl hackers can fix it 8))
74 # c files - list of 'c' files to process
76 # All output goes to stdout, with errors to stderr.
80 # In the following table, (...)? signifies optional structure.
81 # (...)* signifies 0 or more structure elements
83 # * function_name(:)? (- short description)?
84 # (* @parameterx: (description of parameter x)?)*
86 # * (Description:)? (Description of function)?
87 # * (section header: (section description)? )*
90 # So .. the trivial example would be:
96 # If the Description: header tag is omitted, then there must be a blank line
97 # after the last parameter specification.
100 # * my_function - does my stuff
101 # * @my_arg: its mine damnit
103 # * Does my stuff explained.
106 # or, could also use:
108 # * my_function - does my stuff
109 # * @my_arg: its mine damnit
110 # * Description: Does my stuff explained.
114 # Besides functions you can also write documentation for structs, unions,
115 # enums and typedefs. Instead of the function name you must write the name
116 # of the declaration; the struct/union/enum/typedef must always precede
117 # the name. Nesting of declarations is not supported.
118 # Use the argument mechanism to document members or constants.
121 # * struct my_struct - short description
123 # * @b: second member
125 # * Longer description
134 # All descriptions can be multiline, except the short function description.
136 # You can also add additional sections. When documenting kernel functions you
137 # should document the "Context:" of the function, e.g. whether the functions
138 # can be called form interrupts. Unlike other sections you can end it with an
140 # Example-sections should contain the string EXAMPLE so that they are marked
141 # appropriately in DocBook.
145 # * user_function - function that can only be called in user context
146 # * @a: some argument
147 # * Context: !in_interrupt()
151 # * user_function(22);
156 # All descriptive text is further processed, scanning for the following special
157 # patterns, which are highlighted appropriately.
159 # 'funcname()' - function
160 # '$ENVVAR' - environmental variable
161 # '&struct_name' - name of a structure (up to two words including 'struct')
162 # '@parameter' - name of a parameter
163 # '%CONST' - name of a constant.
169 my $anon_struct_union = 0;
171 # match expressions used to find embedded type information
172 my $type_constant = '\%([-_\w]+)';
173 my $type_func = '(\w+)\(\)';
174 my $type_param = '\@(\w+)';
175 my $type_struct = '\&((struct\s*)*[_\w]+)';
176 my $type_struct_xml = '\\&((struct\s*)*[_\w]+)';
177 my $type_env = '(\$\w+)';
179 # Output conversion substitutions.
180 # One for each output format
182 # these work fairly well
183 my %highlights_html = ( $type_constant, "<i>\$1</i>",
184 $type_func, "<b>\$1</b>",
185 $type_struct_xml, "<i>\$1</i>",
186 $type_env, "<b><i>\$1</i></b>",
187 $type_param, "<tt><b>\$1</b></tt>" );
188 my $local_lt = "\\\\\\\\lt:";
189 my $local_gt = "\\\\\\\\gt:";
190 my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"
193 my %highlights_html5 = ( $type_constant, "<span class=\"const\">\$1</span>",
194 $type_func, "<span class=\"func\">\$1</span>",
195 $type_struct_xml, "<span class=\"struct\">\$1</span>",
196 $type_env, "<span class=\"env\">\$1</span>",
197 $type_param, "<span class=\"param\">\$1</span>" );
198 my $blankline_html5 = $local_lt . "br /" . $local_gt;
200 # XML, docbook format
201 my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>",
202 $type_constant, "<constant>\$1</constant>",
203 $type_func, "<function>\$1</function>",
204 $type_struct_xml, "<structname>\$1</structname>",
205 $type_env, "<envar>\$1</envar>",
206 $type_param, "<parameter>\$1</parameter>" );
207 my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n";
209 # gnome, docbook format
210 my %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>",
211 $type_func, "<function>\$1</function>",
212 $type_struct, "<structname>\$1</structname>",
213 $type_env, "<envar>\$1</envar>",
214 $type_param, "<parameter>\$1</parameter>" );
215 my $blankline_gnome = "</para><para>\n";
217 # these are pretty rough
218 my %highlights_man = ( $type_constant, "\$1",
219 $type_func, "\\\\fB\$1\\\\fP",
220 $type_struct, "\\\\fI\$1\\\\fP",
221 $type_param, "\\\\fI\$1\\\\fP" );
222 my $blankline_man = "";
225 my %highlights_text = ( $type_constant, "\$1",
228 $type_param, "\$1" );
229 my $blankline_text = "";
232 my %highlights_list = ( $type_constant, "\$1",
235 $type_param, "\$1" );
236 my $blankline_list = "";
244 my $dohighlight = "";
247 my $output_mode = "man";
248 my $output_preformatted = 0;
249 my $no_doc_sections = 0;
250 my %highlights = %highlights_man;
251 my $blankline = $blankline_man;
252 my $modulename = "Kernel API";
253 my $function_only = 0;
254 my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
255 'July', 'August', 'September', 'October',
256 'November', 'December')[(localtime)[4]] .
257 " " . ((localtime)[5]+1900);
259 # Essentially these are globals.
260 # They probably want to be tidied up, made more localised or something.
261 # CAVEAT EMPTOR! Some of the others I localised may not want to be, which
262 # could cause "use of undefined value" or other bugs.
263 my ($function, %function_table, %parametertypes, $declaration_purpose);
264 my ($type, $declaration_name, $return_type);
265 my ($newsection, $newcontents, $prototype, $brcount, %source_map);
267 if (defined($ENV{'KBUILD_VERBOSE'})) {
268 $verbose = "$ENV{'KBUILD_VERBOSE'}";
271 # Generated docbook code is inserted in a template at a point where
272 # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
273 # http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
274 # We keep track of number of generated entries and generate a dummy
275 # if needs be to ensure the expanded template can be postprocessed
277 my $section_counter = 0;
283 # 1 - looking for function name
284 # 2 - scanning field start.
285 # 3 - scanning prototype.
286 # 4 - documentation block
290 #declaration types: can be
291 # 'function', 'struct', 'union', 'enum', 'typedef'
294 my $doc_special = "\@\%\$\&";
296 my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
298 my $doc_com = '\s*\*\s*';
299 my $doc_com_body = '\s*\* ?';
300 my $doc_decl = $doc_com . '(\w+)';
301 my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)';
302 my $doc_content = $doc_com_body . '(.*)';
303 my $doc_block = $doc_com . 'DOC:\s*(.*)?';
314 my $section_default = "Description"; # default section
315 my $section_intro = "Introduction";
316 my $section = $section_default;
317 my $section_context = "Context";
319 my $undescribed = "-- undescribed --";
323 while ($ARGV[0] =~ m/^-(.*)/) {
324 my $cmd = shift @ARGV;
325 if ($cmd eq "-html") {
326 $output_mode = "html";
327 %highlights = %highlights_html;
328 $blankline = $blankline_html;
329 } elsif ($cmd eq "-html5") {
330 $output_mode = "html5";
331 %highlights = %highlights_html5;
332 $blankline = $blankline_html5;
333 } elsif ($cmd eq "-man") {
334 $output_mode = "man";
335 %highlights = %highlights_man;
336 $blankline = $blankline_man;
337 } elsif ($cmd eq "-text") {
338 $output_mode = "text";
339 %highlights = %highlights_text;
340 $blankline = $blankline_text;
341 } elsif ($cmd eq "-docbook") {
342 $output_mode = "xml";
343 %highlights = %highlights_xml;
344 $blankline = $blankline_xml;
345 } elsif ($cmd eq "-list") {
346 $output_mode = "list";
347 %highlights = %highlights_list;
348 $blankline = $blankline_list;
349 } elsif ($cmd eq "-gnome") {
350 $output_mode = "gnome";
351 %highlights = %highlights_gnome;
352 $blankline = $blankline_gnome;
353 } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document
354 $modulename = shift @ARGV;
355 } elsif ($cmd eq "-function") { # to only output specific functions
357 $function = shift @ARGV;
358 $function_table{$function} = 1;
359 } elsif ($cmd eq "-nofunction") { # to only output specific functions
361 $function = shift @ARGV;
362 $function_table{$function} = 1;
363 } elsif ($cmd eq "-v") {
365 } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
367 } elsif ($cmd eq '-no-doc-sections') {
368 $no_doc_sections = 1;
372 # continue execution near EOF;
375 print "Usage: $0 [ -docbook | -html | -html5 | -text | -man | -list ]\n";
376 print " [ -no-doc-sections ]\n";
377 print " [ -function funcname [ -function funcname ...] ]\n";
378 print " [ -nofunction funcname [ -nofunction funcname ...] ]\n";
380 print " c source file(s) > outputfile\n";
381 print " -v : verbose output, more warnings & other info listed\n";
385 # get kernel version from env
386 sub get_kernel_version() {
387 my $version = 'unknown kernel version';
389 if (defined($ENV{'KERNELVERSION'})) {
390 $version = $ENV{'KERNELVERSION'};
396 # dumps section contents to arrays/hashes intended for that purpose.
401 my $contents = join "\n", @_;
403 if ($name =~ m/$type_constant/) {
405 # print STDERR "constant section '$1' = '$contents'\n";
406 $constants{$name} = $contents;
407 } elsif ($name =~ m/$type_param/) {
408 # print STDERR "parameter def '$1' = '$contents'\n";
410 $parameterdescs{$name} = $contents;
411 $sectcheck = $sectcheck . $name . " ";
412 } elsif ($name eq "@\.\.\.") {
413 # print STDERR "parameter def '...' = '$contents'\n";
415 $parameterdescs{$name} = $contents;
416 $sectcheck = $sectcheck . $name . " ";
418 # print STDERR "other section '$name' = '$contents'\n";
419 if (defined($sections{$name}) && ($sections{$name} ne "")) {
420 print STDERR "Error(${file}:$.): duplicate section name '$name'\n";
423 $sections{$name} = $contents;
424 push @sectionlist, $name;
429 # dump DOC: section after checking that it should go out
431 sub dump_doc_section {
434 my $contents = join "\n", @_;
436 if ($no_doc_sections) {
440 if (($function_only == 0) ||
441 ( $function_only == 1 && defined($function_table{$name})) ||
442 ( $function_only == 2 && !defined($function_table{$name})))
444 dump_section($file, $name, $contents);
445 output_blockhead({'sectionlist' => \@sectionlist,
446 'sections' => \%sections,
447 'module' => $modulename,
448 'content-only' => ($function_only != 0), });
455 # parameterdescs, a hash.
456 # function => "function name"
457 # parameterlist => @list of parameters
458 # parameterdescs => %parameter descriptions
459 # sectionlist => @list of sections
460 # sections => %section descriptions
463 sub output_highlight {
464 my $contents = join "\n",@_;
468 # if (!defined $contents) {
470 # confess "output_highlight got called with no args?\n";
473 if ($output_mode eq "html" || $output_mode eq "html5" ||
474 $output_mode eq "xml") {
475 $contents = local_unescape($contents);
476 # convert data read & converted thru xml_escape() into &xyz; format:
477 $contents =~ s/\\\\\\/\&/g;
479 # print STDERR "contents b4:$contents\n";
482 # print STDERR "contents af:$contents\n";
484 # strip whitespaces when generating html5
485 if ($output_mode eq "html5") {
486 $contents =~ s/^\s+//;
487 $contents =~ s/\s+$//;
489 foreach $line (split "\n", $contents) {
490 if (! $output_preformatted) {
494 if (! $output_preformatted) {
495 print $lineprefix, local_unescape($blankline);
498 $line =~ s/\\\\\\/\&/g;
499 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
502 print $lineprefix, $line;
509 # output sections in html
510 sub output_section_html(%) {
514 foreach $section (@{$args{'sectionlist'}}) {
515 print "<h3>$section</h3>\n";
516 print "<blockquote>\n";
517 output_highlight($args{'sections'}{$section});
518 print "</blockquote>\n";
522 # output enum in html
523 sub output_enum_html(%) {
527 print "<h2>enum " . $args{'enum'} . "</h2>\n";
529 print "<b>enum " . $args{'enum'} . "</b> {<br>\n";
531 foreach $parameter (@{$args{'parameterlist'}}) {
532 print " <b>" . $parameter . "</b>";
533 if ($count != $#{$args{'parameterlist'}}) {
541 print "<h3>Constants</h3>\n";
543 foreach $parameter (@{$args{'parameterlist'}}) {
544 print "<dt><b>" . $parameter . "</b>\n";
546 output_highlight($args{'parameterdescs'}{$parameter});
549 output_section_html(@_);
553 # output typedef in html
554 sub output_typedef_html(%) {
558 print "<h2>typedef " . $args{'typedef'} . "</h2>\n";
560 print "<b>typedef " . $args{'typedef'} . "</b>\n";
561 output_section_html(@_);
565 # output struct in html
566 sub output_struct_html(%) {
570 print "<h2>" . $args{'type'} . " " . $args{'struct'} . " - " . $args{'purpose'} . "</h2>\n";
571 print "<b>" . $args{'type'} . " " . $args{'struct'} . "</b> {<br>\n";
572 foreach $parameter (@{$args{'parameterlist'}}) {
573 if ($parameter =~ /^#/) {
574 print "$parameter<br>\n";
577 my $parameter_name = $parameter;
578 $parameter_name =~ s/\[.*//;
580 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
581 $type = $args{'parametertypes'}{$parameter};
582 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
583 # pointer-to-function
584 print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
585 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
587 print " <i>$1</i> <b>$parameter</b>$2;<br>\n";
589 print " <i>$type</i> <b>$parameter</b>;<br>\n";
594 print "<h3>Members</h3>\n";
596 foreach $parameter (@{$args{'parameterlist'}}) {
597 ($parameter =~ /^#/) && next;
599 my $parameter_name = $parameter;
600 $parameter_name =~ s/\[.*//;
602 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
603 print "<dt><b>" . $parameter . "</b>\n";
605 output_highlight($args{'parameterdescs'}{$parameter_name});
608 output_section_html(@_);
612 # output function in html
613 sub output_function_html(%) {
615 my ($parameter, $section);
618 print "<h2>" . $args{'function'} . " - " . $args{'purpose'} . "</h2>\n";
619 print "<i>" . $args{'functiontype'} . "</i>\n";
620 print "<b>" . $args{'function'} . "</b>\n";
623 foreach $parameter (@{$args{'parameterlist'}}) {
624 $type = $args{'parametertypes'}{$parameter};
625 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
626 # pointer-to-function
627 print "<i>$1</i><b>$parameter</b>) <i>($2)</i>";
629 print "<i>" . $type . "</i> <b>" . $parameter . "</b>";
631 if ($count != $#{$args{'parameterlist'}}) {
638 print "<h3>Arguments</h3>\n";
640 foreach $parameter (@{$args{'parameterlist'}}) {
641 my $parameter_name = $parameter;
642 $parameter_name =~ s/\[.*//;
644 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
645 print "<dt><b>" . $parameter . "</b>\n";
647 output_highlight($args{'parameterdescs'}{$parameter_name});
650 output_section_html(@_);
654 # output DOC: block header in html
655 sub output_blockhead_html(%) {
657 my ($parameter, $section);
660 foreach $section (@{$args{'sectionlist'}}) {
661 print "<h3>$section</h3>\n";
663 output_highlight($args{'sections'}{$section});
669 # output sections in html5
670 sub output_section_html5(%) {
674 foreach $section (@{$args{'sectionlist'}}) {
676 print "<h1>$section</h1>\n";
678 output_highlight($args{'sections'}{$section});
680 print "</section>\n";
684 # output enum in html5
685 sub output_enum_html5(%) {
691 $html5id = $args{'enum'};
692 $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
693 print "<article class=\"enum\" id=\"enum:". $html5id . "\">";
694 print "<h1>enum " . $args{'enum'} . "</h1>\n";
695 print "<ol class=\"code\">\n";
697 print "<span class=\"keyword\">enum</span> ";
698 print "<span class=\"identifier\">" . $args{'enum'} . "</span> {";
701 foreach $parameter (@{$args{'parameterlist'}}) {
702 print "<li class=\"indent\">";
703 print "<span class=\"param\">" . $parameter . "</span>";
704 if ($count != $#{$args{'parameterlist'}}) {
710 print "<li>};</li>\n";
714 print "<h1>Constants</h1>\n";
716 foreach $parameter (@{$args{'parameterlist'}}) {
717 print "<dt>" . $parameter . "</dt>\n";
719 output_highlight($args{'parameterdescs'}{$parameter});
723 print "</section>\n";
724 output_section_html5(@_);
725 print "</article>\n";
728 # output typedef in html5
729 sub output_typedef_html5(%) {
735 $html5id = $args{'typedef'};
736 $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
737 print "<article class=\"typedef\" id=\"typedef:" . $html5id . "\">\n";
738 print "<h1>typedef " . $args{'typedef'} . "</h1>\n";
740 print "<ol class=\"code\">\n";
742 print "<span class=\"keyword\">typedef</span> ";
743 print "<span class=\"identifier\">" . $args{'typedef'} . "</span>";
746 output_section_html5(@_);
747 print "</article>\n";
750 # output struct in html5
751 sub output_struct_html5(%) {
756 $html5id = $args{'struct'};
757 $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
758 print "<article class=\"struct\" id=\"struct:" . $html5id . "\">\n";
760 print "<h1>" . $args{'type'} . " " . $args{'struct'} . "</h1>";
761 print "<h2>". $args{'purpose'} . "</h2>\n";
763 print "<ol class=\"code\">\n";
765 print "<span class=\"type\">" . $args{'type'} . "</span> ";
766 print "<span class=\"identifier\">" . $args{'struct'} . "</span> {";
768 foreach $parameter (@{$args{'parameterlist'}}) {
769 print "<li class=\"indent\">";
770 if ($parameter =~ /^#/) {
771 print "<span class=\"param\">" . $parameter ."</span>\n";
775 my $parameter_name = $parameter;
776 $parameter_name =~ s/\[.*//;
778 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
779 $type = $args{'parametertypes'}{$parameter};
780 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
781 # pointer-to-function
782 print "<span class=\"type\">$1</span> ";
783 print "<span class=\"param\">$parameter</span>";
784 print "<span class=\"type\">)</span> ";
785 print "(<span class=\"args\">$2</span>);";
786 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
788 print "<span class=\"type\">$1</span> ";
789 print "<span class=\"param\">$parameter</span>";
790 print "<span class=\"bits\">$2</span>;";
792 print "<span class=\"type\">$type</span> ";
793 print "<span class=\"param\">$parameter</span>;";
797 print "<li>};</li>\n";
801 print "<h1>Members</h1>\n";
803 foreach $parameter (@{$args{'parameterlist'}}) {
804 ($parameter =~ /^#/) && next;
806 my $parameter_name = $parameter;
807 $parameter_name =~ s/\[.*//;
809 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
810 print "<dt>" . $parameter . "</dt>\n";
812 output_highlight($args{'parameterdescs'}{$parameter_name});
816 print "</section>\n";
817 output_section_html5(@_);
818 print "</article>\n";
821 # output function in html5
822 sub output_function_html5(%) {
824 my ($parameter, $section);
828 $html5id = $args{'function'};
829 $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
830 print "<article class=\"function\" id=\"func:". $html5id . "\">\n";
832 print "<h1>" . $args{'function'} . "</h1>";
833 print "<h2>" . $args{'purpose'} . "</h2>\n";
835 print "<ol class=\"code\">\n";
837 print "<span class=\"type\">" . $args{'functiontype'} . "</span> ";
838 print "<span class=\"identifier\">" . $args{'function'} . "</span> (";
841 foreach $parameter (@{$args{'parameterlist'}}) {
842 print "<li class=\"indent\">";
843 $type = $args{'parametertypes'}{$parameter};
844 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
845 # pointer-to-function
846 print "<span class=\"type\">$1</span> ";
847 print "<span class=\"param\">$parameter</span>";
848 print "<span class=\"type\">)</span> ";
849 print "(<span class=\"args\">$2</span>)";
851 print "<span class=\"type\">$type</span> ";
852 print "<span class=\"param\">$parameter</span>";
854 if ($count != $#{$args{'parameterlist'}}) {
860 print "<li>)</li>\n";
864 print "<h1>Arguments</h1>\n";
867 foreach $parameter (@{$args{'parameterlist'}}) {
868 my $parameter_name = $parameter;
869 $parameter_name =~ s/\[.*//;
871 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
872 print "<dt>" . $parameter . "</dt>\n";
874 output_highlight($args{'parameterdescs'}{$parameter_name});
878 print "</section>\n";
879 output_section_html5(@_);
880 print "</article>\n";
883 # output DOC: block header in html5
884 sub output_blockhead_html5(%) {
886 my ($parameter, $section);
890 foreach $section (@{$args{'sectionlist'}}) {
892 $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
893 print "<article class=\"doc\" id=\"doc:". $html5id . "\">\n";
894 print "<h1>$section</h1>\n";
896 output_highlight($args{'sections'}{$section});
899 print "</article>\n";
902 sub output_section_xml(%) {
905 # print out each section
907 foreach $section (@{$args{'sectionlist'}}) {
908 print "<refsect1>\n";
909 print "<title>$section</title>\n";
910 if ($section =~ m/EXAMPLE/i) {
911 print "<informalexample><programlisting>\n";
912 $output_preformatted = 1;
916 output_highlight($args{'sections'}{$section});
917 $output_preformatted = 0;
918 if ($section =~ m/EXAMPLE/i) {
919 print "</programlisting></informalexample>\n";
923 print "</refsect1>\n";
927 # output function in XML DocBook
928 sub output_function_xml(%) {
930 my ($parameter, $section);
934 $id = "API-" . $args{'function'};
935 $id =~ s/[^A-Za-z0-9]/-/g;
937 print "<refentry id=\"$id\">\n";
938 print "<refentryinfo>\n";
939 print " <title>LINUX</title>\n";
940 print " <productname>Kernel Hackers Manual</productname>\n";
941 print " <date>$man_date</date>\n";
942 print "</refentryinfo>\n";
944 print " <refentrytitle><phrase>" . $args{'function'} . "</phrase></refentrytitle>\n";
945 print " <manvolnum>9</manvolnum>\n";
946 print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
947 print "</refmeta>\n";
948 print "<refnamediv>\n";
949 print " <refname>" . $args{'function'} . "</refname>\n";
950 print " <refpurpose>\n";
952 output_highlight ($args{'purpose'});
953 print " </refpurpose>\n";
954 print "</refnamediv>\n";
956 print "<refsynopsisdiv>\n";
957 print " <title>Synopsis</title>\n";
958 print " <funcsynopsis><funcprototype>\n";
959 print " <funcdef>" . $args{'functiontype'} . " ";
960 print "<function>" . $args{'function'} . " </function></funcdef>\n";
963 if ($#{$args{'parameterlist'}} >= 0) {
964 foreach $parameter (@{$args{'parameterlist'}}) {
965 $type = $args{'parametertypes'}{$parameter};
966 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
967 # pointer-to-function
968 print " <paramdef>$1<parameter>$parameter</parameter>)\n";
969 print " <funcparams>$2</funcparams></paramdef>\n";
971 print " <paramdef>" . $type;
972 print " <parameter>$parameter</parameter></paramdef>\n";
978 print " </funcprototype></funcsynopsis>\n";
979 print "</refsynopsisdiv>\n";
982 print "<refsect1>\n <title>Arguments</title>\n";
983 if ($#{$args{'parameterlist'}} >= 0) {
984 print " <variablelist>\n";
985 foreach $parameter (@{$args{'parameterlist'}}) {
986 my $parameter_name = $parameter;
987 $parameter_name =~ s/\[.*//;
989 print " <varlistentry>\n <term><parameter>$parameter</parameter></term>\n";
990 print " <listitem>\n <para>\n";
992 output_highlight($args{'parameterdescs'}{$parameter_name});
993 print " </para>\n </listitem>\n </varlistentry>\n";
995 print " </variablelist>\n";
997 print " <para>\n None\n </para>\n";
999 print "</refsect1>\n";
1001 output_section_xml(@_);
1002 print "</refentry>\n\n";
1005 # output struct in XML DocBook
1006 sub output_struct_xml(%) {
1007 my %args = %{$_[0]};
1008 my ($parameter, $section);
1011 $id = "API-struct-" . $args{'struct'};
1012 $id =~ s/[^A-Za-z0-9]/-/g;
1014 print "<refentry id=\"$id\">\n";
1015 print "<refentryinfo>\n";
1016 print " <title>LINUX</title>\n";
1017 print " <productname>Kernel Hackers Manual</productname>\n";
1018 print " <date>$man_date</date>\n";
1019 print "</refentryinfo>\n";
1020 print "<refmeta>\n";
1021 print " <refentrytitle><phrase>" . $args{'type'} . " " . $args{'struct'} . "</phrase></refentrytitle>\n";
1022 print " <manvolnum>9</manvolnum>\n";
1023 print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
1024 print "</refmeta>\n";
1025 print "<refnamediv>\n";
1026 print " <refname>" . $args{'type'} . " " . $args{'struct'} . "</refname>\n";
1027 print " <refpurpose>\n";
1029 output_highlight ($args{'purpose'});
1030 print " </refpurpose>\n";
1031 print "</refnamediv>\n";
1033 print "<refsynopsisdiv>\n";
1034 print " <title>Synopsis</title>\n";
1035 print " <programlisting>\n";
1036 print $args{'type'} . " " . $args{'struct'} . " {\n";
1037 foreach $parameter (@{$args{'parameterlist'}}) {
1038 if ($parameter =~ /^#/) {
1039 my $prm = $parameter;
1040 # convert data read & converted thru xml_escape() into &xyz; format:
1041 # This allows us to have #define macros interspersed in a struct.
1042 $prm =~ s/\\\\\\/\&/g;
1047 my $parameter_name = $parameter;
1048 $parameter_name =~ s/\[.*//;
1050 defined($args{'parameterdescs'}{$parameter_name}) || next;
1051 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1052 $type = $args{'parametertypes'}{$parameter};
1053 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1054 # pointer-to-function
1055 print " $1 $parameter) ($2);\n";
1056 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1058 print " $1 $parameter$2;\n";
1060 print " " . $type . " " . $parameter . ";\n";
1064 print " </programlisting>\n";
1065 print "</refsynopsisdiv>\n";
1067 print " <refsect1>\n";
1068 print " <title>Members</title>\n";
1070 if ($#{$args{'parameterlist'}} >= 0) {
1071 print " <variablelist>\n";
1072 foreach $parameter (@{$args{'parameterlist'}}) {
1073 ($parameter =~ /^#/) && next;
1075 my $parameter_name = $parameter;
1076 $parameter_name =~ s/\[.*//;
1078 defined($args{'parameterdescs'}{$parameter_name}) || next;
1079 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1080 print " <varlistentry>";
1081 print " <term>$parameter</term>\n";
1082 print " <listitem><para>\n";
1083 output_highlight($args{'parameterdescs'}{$parameter_name});
1084 print " </para></listitem>\n";
1085 print " </varlistentry>\n";
1087 print " </variablelist>\n";
1089 print " <para>\n None\n </para>\n";
1091 print " </refsect1>\n";
1093 output_section_xml(@_);
1095 print "</refentry>\n\n";
1098 # output enum in XML DocBook
1099 sub output_enum_xml(%) {
1100 my %args = %{$_[0]};
1101 my ($parameter, $section);
1105 $id = "API-enum-" . $args{'enum'};
1106 $id =~ s/[^A-Za-z0-9]/-/g;
1108 print "<refentry id=\"$id\">\n";
1109 print "<refentryinfo>\n";
1110 print " <title>LINUX</title>\n";
1111 print " <productname>Kernel Hackers Manual</productname>\n";
1112 print " <date>$man_date</date>\n";
1113 print "</refentryinfo>\n";
1114 print "<refmeta>\n";
1115 print " <refentrytitle><phrase>enum " . $args{'enum'} . "</phrase></refentrytitle>\n";
1116 print " <manvolnum>9</manvolnum>\n";
1117 print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
1118 print "</refmeta>\n";
1119 print "<refnamediv>\n";
1120 print " <refname>enum " . $args{'enum'} . "</refname>\n";
1121 print " <refpurpose>\n";
1123 output_highlight ($args{'purpose'});
1124 print " </refpurpose>\n";
1125 print "</refnamediv>\n";
1127 print "<refsynopsisdiv>\n";
1128 print " <title>Synopsis</title>\n";
1129 print " <programlisting>\n";
1130 print "enum " . $args{'enum'} . " {\n";
1132 foreach $parameter (@{$args{'parameterlist'}}) {
1133 print " $parameter";
1134 if ($count != $#{$args{'parameterlist'}}) {
1141 print " </programlisting>\n";
1142 print "</refsynopsisdiv>\n";
1144 print "<refsect1>\n";
1145 print " <title>Constants</title>\n";
1146 print " <variablelist>\n";
1147 foreach $parameter (@{$args{'parameterlist'}}) {
1148 my $parameter_name = $parameter;
1149 $parameter_name =~ s/\[.*//;
1151 print " <varlistentry>";
1152 print " <term>$parameter</term>\n";
1153 print " <listitem><para>\n";
1154 output_highlight($args{'parameterdescs'}{$parameter_name});
1155 print " </para></listitem>\n";
1156 print " </varlistentry>\n";
1158 print " </variablelist>\n";
1159 print "</refsect1>\n";
1161 output_section_xml(@_);
1163 print "</refentry>\n\n";
1166 # output typedef in XML DocBook
1167 sub output_typedef_xml(%) {
1168 my %args = %{$_[0]};
1169 my ($parameter, $section);
1172 $id = "API-typedef-" . $args{'typedef'};
1173 $id =~ s/[^A-Za-z0-9]/-/g;
1175 print "<refentry id=\"$id\">\n";
1176 print "<refentryinfo>\n";
1177 print " <title>LINUX</title>\n";
1178 print " <productname>Kernel Hackers Manual</productname>\n";
1179 print " <date>$man_date</date>\n";
1180 print "</refentryinfo>\n";
1181 print "<refmeta>\n";
1182 print " <refentrytitle><phrase>typedef " . $args{'typedef'} . "</phrase></refentrytitle>\n";
1183 print " <manvolnum>9</manvolnum>\n";
1184 print "</refmeta>\n";
1185 print "<refnamediv>\n";
1186 print " <refname>typedef " . $args{'typedef'} . "</refname>\n";
1187 print " <refpurpose>\n";
1189 output_highlight ($args{'purpose'});
1190 print " </refpurpose>\n";
1191 print "</refnamediv>\n";
1193 print "<refsynopsisdiv>\n";
1194 print " <title>Synopsis</title>\n";
1195 print " <synopsis>typedef " . $args{'typedef'} . ";</synopsis>\n";
1196 print "</refsynopsisdiv>\n";
1198 output_section_xml(@_);
1200 print "</refentry>\n\n";
1203 # output in XML DocBook
1204 sub output_blockhead_xml(%) {
1205 my %args = %{$_[0]};
1206 my ($parameter, $section);
1209 my $id = $args{'module'};
1210 $id =~ s/[^A-Za-z0-9]/-/g;
1212 # print out each section
1214 foreach $section (@{$args{'sectionlist'}}) {
1215 if (!$args{'content-only'}) {
1216 print "<refsect1>\n <title>$section</title>\n";
1218 if ($section =~ m/EXAMPLE/i) {
1219 print "<example><para>\n";
1220 $output_preformatted = 1;
1224 output_highlight($args{'sections'}{$section});
1225 $output_preformatted = 0;
1226 if ($section =~ m/EXAMPLE/i) {
1227 print "</para></example>\n";
1231 if (!$args{'content-only'}) {
1232 print "\n</refsect1>\n";
1239 # output in XML DocBook
1240 sub output_function_gnome {
1241 my %args = %{$_[0]};
1242 my ($parameter, $section);
1246 $id = $args{'module'} . "-" . $args{'function'};
1247 $id =~ s/[^A-Za-z0-9]/-/g;
1250 print " <title id=\"$id\">" . $args{'function'} . "</title>\n";
1252 print " <funcsynopsis>\n";
1253 print " <funcdef>" . $args{'functiontype'} . " ";
1254 print "<function>" . $args{'function'} . " ";
1255 print "</function></funcdef>\n";
1258 if ($#{$args{'parameterlist'}} >= 0) {
1259 foreach $parameter (@{$args{'parameterlist'}}) {
1260 $type = $args{'parametertypes'}{$parameter};
1261 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1262 # pointer-to-function
1263 print " <paramdef>$1 <parameter>$parameter</parameter>)\n";
1264 print " <funcparams>$2</funcparams></paramdef>\n";
1266 print " <paramdef>" . $type;
1267 print " <parameter>$parameter</parameter></paramdef>\n";
1273 print " </funcsynopsis>\n";
1274 if ($#{$args{'parameterlist'}} >= 0) {
1275 print " <informaltable pgwide=\"1\" frame=\"none\" role=\"params\">\n";
1276 print "<tgroup cols=\"2\">\n";
1277 print "<colspec colwidth=\"2*\">\n";
1278 print "<colspec colwidth=\"8*\">\n";
1280 foreach $parameter (@{$args{'parameterlist'}}) {
1281 my $parameter_name = $parameter;
1282 $parameter_name =~ s/\[.*//;
1284 print " <row><entry align=\"right\"><parameter>$parameter</parameter></entry>\n";
1287 output_highlight($args{'parameterdescs'}{$parameter_name});
1288 print " </entry></row>\n";
1290 print " </tbody></tgroup></informaltable>\n";
1292 print " <para>\n None\n </para>\n";
1295 # print out each section
1297 foreach $section (@{$args{'sectionlist'}}) {
1298 print "<simplesect>\n <title>$section</title>\n";
1299 if ($section =~ m/EXAMPLE/i) {
1300 print "<example><programlisting>\n";
1301 $output_preformatted = 1;
1305 output_highlight($args{'sections'}{$section});
1306 $output_preformatted = 0;
1308 if ($section =~ m/EXAMPLE/i) {
1309 print "</programlisting></example>\n";
1312 print " </simplesect>\n";
1315 print "</sect2>\n\n";
1319 # output function in man
1320 sub output_function_man(%) {
1321 my %args = %{$_[0]};
1322 my ($parameter, $section);
1325 print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n";
1328 print $args{'function'} . " \\- " . $args{'purpose'} . "\n";
1330 print ".SH SYNOPSIS\n";
1331 if ($args{'functiontype'} ne "") {
1332 print ".B \"" . $args{'functiontype'} . "\" " . $args{'function'} . "\n";
1334 print ".B \"" . $args{'function'} . "\n";
1339 foreach my $parameter (@{$args{'parameterlist'}}) {
1340 if ($count == $#{$args{'parameterlist'}}) {
1343 $type = $args{'parametertypes'}{$parameter};
1344 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1345 # pointer-to-function
1346 print ".BI \"" . $parenth . $1 . "\" " . $parameter . " \") (" . $2 . ")" . $post . "\"\n";
1348 $type =~ s/([^\*])$/$1 /;
1349 print ".BI \"" . $parenth . $type . "\" " . $parameter . " \"" . $post . "\"\n";
1355 print ".SH ARGUMENTS\n";
1356 foreach $parameter (@{$args{'parameterlist'}}) {
1357 my $parameter_name = $parameter;
1358 $parameter_name =~ s/\[.*//;
1360 print ".IP \"" . $parameter . "\" 12\n";
1361 output_highlight($args{'parameterdescs'}{$parameter_name});
1363 foreach $section (@{$args{'sectionlist'}}) {
1364 print ".SH \"", uc $section, "\"\n";
1365 output_highlight($args{'sections'}{$section});
1370 # output enum in man
1371 sub output_enum_man(%) {
1372 my %args = %{$_[0]};
1373 my ($parameter, $section);
1376 print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual\" LINUX\n";
1379 print "enum " . $args{'enum'} . " \\- " . $args{'purpose'} . "\n";
1381 print ".SH SYNOPSIS\n";
1382 print "enum " . $args{'enum'} . " {\n";
1384 foreach my $parameter (@{$args{'parameterlist'}}) {
1385 print ".br\n.BI \" $parameter\"\n";
1386 if ($count == $#{$args{'parameterlist'}}) {
1396 print ".SH Constants\n";
1397 foreach $parameter (@{$args{'parameterlist'}}) {
1398 my $parameter_name = $parameter;
1399 $parameter_name =~ s/\[.*//;
1401 print ".IP \"" . $parameter . "\" 12\n";
1402 output_highlight($args{'parameterdescs'}{$parameter_name});
1404 foreach $section (@{$args{'sectionlist'}}) {
1405 print ".SH \"$section\"\n";
1406 output_highlight($args{'sections'}{$section});
1411 # output struct in man
1412 sub output_struct_man(%) {
1413 my %args = %{$_[0]};
1414 my ($parameter, $section);
1416 print ".TH \"$args{'module'}\" 9 \"" . $args{'type'} . " " . $args{'struct'} . "\" \"$man_date\" \"API Manual\" LINUX\n";
1419 print $args{'type'} . " " . $args{'struct'} . " \\- " . $args{'purpose'} . "\n";
1421 print ".SH SYNOPSIS\n";
1422 print $args{'type'} . " " . $args{'struct'} . " {\n.br\n";
1424 foreach my $parameter (@{$args{'parameterlist'}}) {
1425 if ($parameter =~ /^#/) {
1426 print ".BI \"$parameter\"\n.br\n";
1429 my $parameter_name = $parameter;
1430 $parameter_name =~ s/\[.*//;
1432 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1433 $type = $args{'parametertypes'}{$parameter};
1434 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1435 # pointer-to-function
1436 print ".BI \" " . $1 . "\" " . $parameter . " \") (" . $2 . ")" . "\"\n;\n";
1437 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1439 print ".BI \" " . $1 . "\ \" " . $parameter . $2 . " \"" . "\"\n;\n";
1441 $type =~ s/([^\*])$/$1 /;
1442 print ".BI \" " . $type . "\" " . $parameter . " \"" . "\"\n;\n";
1448 print ".SH Members\n";
1449 foreach $parameter (@{$args{'parameterlist'}}) {
1450 ($parameter =~ /^#/) && next;
1452 my $parameter_name = $parameter;
1453 $parameter_name =~ s/\[.*//;
1455 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1456 print ".IP \"" . $parameter . "\" 12\n";
1457 output_highlight($args{'parameterdescs'}{$parameter_name});
1459 foreach $section (@{$args{'sectionlist'}}) {
1460 print ".SH \"$section\"\n";
1461 output_highlight($args{'sections'}{$section});
1466 # output typedef in man
1467 sub output_typedef_man(%) {
1468 my %args = %{$_[0]};
1469 my ($parameter, $section);
1471 print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual\" LINUX\n";
1474 print "typedef " . $args{'typedef'} . " \\- " . $args{'purpose'} . "\n";
1476 foreach $section (@{$args{'sectionlist'}}) {
1477 print ".SH \"$section\"\n";
1478 output_highlight($args{'sections'}{$section});
1482 sub output_blockhead_man(%) {
1483 my %args = %{$_[0]};
1484 my ($parameter, $section);
1487 print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual\" LINUX\n";
1489 foreach $section (@{$args{'sectionlist'}}) {
1490 print ".SH \"$section\"\n";
1491 output_highlight($args{'sections'}{$section});
1497 sub output_function_text(%) {
1498 my %args = %{$_[0]};
1499 my ($parameter, $section);
1503 print $args{'function'} . " - " . $args{'purpose'} . "\n";
1505 print "\nSynopsis:\n\n";
1506 if ($args{'functiontype'} ne "") {
1507 $start = $args{'functiontype'} . " " . $args{'function'} . " (";
1509 $start = $args{'function'} . " (";
1514 foreach my $parameter (@{$args{'parameterlist'}}) {
1515 $type = $args{'parametertypes'}{$parameter};
1516 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1517 # pointer-to-function
1518 print $1 . $parameter . ") (" . $2;
1520 print $type . " " . $parameter;
1522 if ($count != $#{$args{'parameterlist'}}) {
1525 print " " x length($start);
1531 print "Arguments:\n\n";
1532 foreach $parameter (@{$args{'parameterlist'}}) {
1533 my $parameter_name = $parameter;
1534 $parameter_name =~ s/\[.*//;
1536 print $parameter . "\n\t" . $args{'parameterdescs'}{$parameter_name} . "\n";
1538 output_section_text(@_);
1541 #output sections in text
1542 sub output_section_text(%) {
1543 my %args = %{$_[0]};
1547 foreach $section (@{$args{'sectionlist'}}) {
1548 print "$section:\n\n";
1549 output_highlight($args{'sections'}{$section});
1554 # output enum in text
1555 sub output_enum_text(%) {
1556 my %args = %{$_[0]};
1561 print "enum " . $args{'enum'} . " - " . $args{'purpose'} . "\n\n";
1562 print "enum " . $args{'enum'} . " {\n";
1564 foreach $parameter (@{$args{'parameterlist'}}) {
1565 print "\t$parameter";
1566 if ($count != $#{$args{'parameterlist'}}) {
1574 print "Constants:\n\n";
1575 foreach $parameter (@{$args{'parameterlist'}}) {
1576 print "$parameter\n\t";
1577 print $args{'parameterdescs'}{$parameter} . "\n";
1580 output_section_text(@_);
1583 # output typedef in text
1584 sub output_typedef_text(%) {
1585 my %args = %{$_[0]};
1588 print "Typedef:\n\n";
1590 print "typedef " . $args{'typedef'} . " - " . $args{'purpose'} . "\n";
1591 output_section_text(@_);
1594 # output struct as text
1595 sub output_struct_text(%) {
1596 my %args = %{$_[0]};
1599 print $args{'type'} . " " . $args{'struct'} . " - " . $args{'purpose'} . "\n\n";
1600 print $args{'type'} . " " . $args{'struct'} . " {\n";
1601 foreach $parameter (@{$args{'parameterlist'}}) {
1602 if ($parameter =~ /^#/) {
1603 print "$parameter\n";
1607 my $parameter_name = $parameter;
1608 $parameter_name =~ s/\[.*//;
1610 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1611 $type = $args{'parametertypes'}{$parameter};
1612 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1613 # pointer-to-function
1614 print "\t$1 $parameter) ($2);\n";
1615 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1617 print "\t$1 $parameter$2;\n";
1619 print "\t" . $type . " " . $parameter . ";\n";
1624 print "Members:\n\n";
1625 foreach $parameter (@{$args{'parameterlist'}}) {
1626 ($parameter =~ /^#/) && next;
1628 my $parameter_name = $parameter;
1629 $parameter_name =~ s/\[.*//;
1631 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1632 print "$parameter\n\t";
1633 print $args{'parameterdescs'}{$parameter_name} . "\n";
1636 output_section_text(@_);
1639 sub output_blockhead_text(%) {
1640 my %args = %{$_[0]};
1641 my ($parameter, $section);
1643 foreach $section (@{$args{'sectionlist'}}) {
1644 print " $section:\n";
1646 output_highlight($args{'sections'}{$section});
1650 ## list mode output functions
1652 sub output_function_list(%) {
1653 my %args = %{$_[0]};
1655 print $args{'function'} . "\n";
1658 # output enum in list
1659 sub output_enum_list(%) {
1660 my %args = %{$_[0]};
1661 print $args{'enum'} . "\n";
1664 # output typedef in list
1665 sub output_typedef_list(%) {
1666 my %args = %{$_[0]};
1667 print $args{'typedef'} . "\n";
1670 # output struct as list
1671 sub output_struct_list(%) {
1672 my %args = %{$_[0]};
1674 print $args{'struct'} . "\n";
1677 sub output_blockhead_list(%) {
1678 my %args = %{$_[0]};
1679 my ($parameter, $section);
1681 foreach $section (@{$args{'sectionlist'}}) {
1682 print "DOC: $section\n";
1687 # generic output function for all types (function, struct/union, typedef, enum);
1688 # calls the generated, variable output_ function name based on
1689 # functype and output_mode
1690 sub output_declaration {
1693 my $functype = shift;
1694 my $func = "output_${functype}_$output_mode";
1695 if (($function_only==0) ||
1696 ( $function_only == 1 && defined($function_table{$name})) ||
1697 ( $function_only == 2 && !defined($function_table{$name})))
1705 # generic output function - calls the right one based on current output mode.
1706 sub output_blockhead {
1708 my $func = "output_blockhead_" . $output_mode;
1714 # takes a declaration (struct, union, enum, typedef) and
1715 # invokes the right handler. NOT called for functions.
1716 sub dump_declaration($$) {
1718 my ($prototype, $file) = @_;
1719 my $func = "dump_" . $decl_type;
1723 sub dump_union($$) {
1727 sub dump_struct($$) {
1732 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
1733 #my $decl_type = $1;
1734 $declaration_name = $2;
1737 # ignore embedded structs or unions
1738 $members =~ s/({.*})//g;
1741 # ignore members marked private:
1742 $members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gos;
1743 $members =~ s/\/\*\s*private:.*//gos;
1745 $members =~ s/\/\*.*?\*\///gos;
1746 $nested =~ s/\/\*.*?\*\///gos;
1747 # strip kmemcheck_bitfield_{begin,end}.*;
1748 $members =~ s/kmemcheck_bitfield_.*?;//gos;
1750 $members =~ s/__aligned\s*\(\d+\)//gos;
1752 create_parameterlist($members, ';', $file);
1753 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
1755 output_declaration($declaration_name,
1757 {'struct' => $declaration_name,
1758 'module' => $modulename,
1759 'parameterlist' => \@parameterlist,
1760 'parameterdescs' => \%parameterdescs,
1761 'parametertypes' => \%parametertypes,
1762 'sectionlist' => \@sectionlist,
1763 'sections' => \%sections,
1764 'purpose' => $declaration_purpose,
1765 'type' => $decl_type
1769 print STDERR "Error(${file}:$.): Cannot parse struct or union!\n";
1778 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1779 $x =~ s/^#\s*define\s+.*$//; # strip #define macros inside enums
1781 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1782 $declaration_name = $1;
1785 foreach my $arg (split ',', $members) {
1786 $arg =~ s/^\s*(\w+).*/$1/;
1787 push @parameterlist, $arg;
1788 if (!$parameterdescs{$arg}) {
1789 $parameterdescs{$arg} = $undescribed;
1790 print STDERR "Warning(${file}:$.): Enum value '$arg' ".
1791 "not described in enum '$declaration_name'\n";
1796 output_declaration($declaration_name,
1798 {'enum' => $declaration_name,
1799 'module' => $modulename,
1800 'parameterlist' => \@parameterlist,
1801 'parameterdescs' => \%parameterdescs,
1802 'sectionlist' => \@sectionlist,
1803 'sections' => \%sections,
1804 'purpose' => $declaration_purpose
1808 print STDERR "Error(${file}:$.): Cannot parse enum!\n";
1813 sub dump_typedef($$) {
1817 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1818 while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
1819 $x =~ s/\(*.\)\s*;$/;/;
1820 $x =~ s/\[*.\]\s*;$/;/;
1823 if ($x =~ /typedef.*\s+(\w+)\s*;/) {
1824 $declaration_name = $1;
1826 output_declaration($declaration_name,
1828 {'typedef' => $declaration_name,
1829 'module' => $modulename,
1830 'sectionlist' => \@sectionlist,
1831 'sections' => \%sections,
1832 'purpose' => $declaration_purpose
1836 print STDERR "Error(${file}:$.): Cannot parse typedef!\n";
1841 sub save_struct_actual($) {
1844 # strip all spaces from the actual param so that it looks like one string item
1845 $actual =~ s/\s*//g;
1846 $struct_actual = $struct_actual . $actual . " ";
1849 sub create_parameterlist($$$) {
1851 my $splitter = shift;
1856 # temporarily replace commas inside function pointer definition
1857 while ($args =~ /(\([^\),]+),/) {
1858 $args =~ s/(\([^\),]+),/$1#/g;
1861 foreach my $arg (split($splitter, $args)) {
1863 $arg =~ s/\/\*.*\*\///;
1864 # strip leading/trailing spaces
1870 # Treat preprocessor directive as a typeless variable just to fill
1871 # corresponding data structures "correctly". Catch it later in
1873 push_parameter($arg, "", $file);
1874 } elsif ($arg =~ m/\(.+\)\s*\(/) {
1875 # pointer-to-function
1877 $arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/;
1880 $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
1881 save_struct_actual($param);
1882 push_parameter($param, $type, $file);
1884 $arg =~ s/\s*:\s*/:/g;
1885 $arg =~ s/\s*\[/\[/g;
1887 my @args = split('\s*,\s*', $arg);
1888 if ($args[0] =~ m/\*/) {
1889 $args[0] =~ s/(\*+)\s*/ $1/;
1893 if ($args[0] =~ /^(.*\s+)(.*?\[.*\].*)$/) {
1895 push(@first_arg, split('\s+', $1));
1896 push(@first_arg, $2);
1898 @first_arg = split('\s+', shift @args);
1901 unshift(@args, pop @first_arg);
1902 $type = join " ", @first_arg;
1904 foreach $param (@args) {
1905 if ($param =~ m/^(\*+)\s*(.*)/) {
1906 save_struct_actual($2);
1907 push_parameter($2, "$type $1", $file);
1909 elsif ($param =~ m/(.*?):(\d+)/) {
1910 if ($type ne "") { # skip unnamed bit-fields
1911 save_struct_actual($1);
1912 push_parameter($1, "$type:$2", $file)
1916 save_struct_actual($param);
1917 push_parameter($param, $type, $file);
1924 sub push_parameter($$$) {
1929 if (($anon_struct_union == 1) && ($type eq "") &&
1931 return; # ignore the ending }; from anon. struct/union
1934 $anon_struct_union = 0;
1935 my $param_name = $param;
1936 $param_name =~ s/\[.*//;
1938 if ($type eq "" && $param =~ /\.\.\.$/)
1940 if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") {
1941 $parameterdescs{$param} = "variable arguments";
1944 elsif ($type eq "" && ($param eq "" or $param eq "void"))
1947 $parameterdescs{void} = "no arguments";
1949 elsif ($type eq "" && ($param eq "struct" or $param eq "union"))
1950 # handle unnamed (anonymous) union or struct:
1953 $param = "{unnamed_" . $param . "}";
1954 $parameterdescs{$param} = "anonymous\n";
1955 $anon_struct_union = 1;
1958 # warn if parameter has no description
1959 # (but ignore ones starting with # as these are not parameters
1960 # but inline preprocessor statements);
1961 # also ignore unnamed structs/unions;
1962 if (!$anon_struct_union) {
1963 if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) {
1965 $parameterdescs{$param_name} = $undescribed;
1967 if (($type eq 'function') || ($type eq 'enum')) {
1968 print STDERR "Warning(${file}:$.): Function parameter ".
1969 "or member '$param' not " .
1970 "described in '$declaration_name'\n";
1972 print STDERR "Warning(${file}:$.):" .
1973 " No description found for parameter '$param'\n";
1978 $param = xml_escape($param);
1980 # strip spaces from $param so that it is one continuous string
1981 # on @parameterlist;
1982 # this fixes a problem where check_sections() cannot find
1983 # a parameter like "addr[6 + 2]" because it actually appears
1984 # as "addr[6", "+", "2]" on the parameter list;
1985 # but it's better to maintain the param string unchanged for output,
1986 # so just weaken the string compare in check_sections() to ignore
1987 # "[blah" in a parameter string;
1988 ###$param =~ s/\s*//g;
1989 push @parameterlist, $param;
1990 $parametertypes{$param} = $type;
1993 sub check_sections($$$$$$) {
1994 my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck, $nested) = @_;
1995 my @sects = split ' ', $sectcheck;
1996 my @prms = split ' ', $prmscheck;
1999 my $prm_clean; # strip trailing "[array size]" and/or beginning "*"
2001 foreach $sx (0 .. $#sects) {
2003 foreach $px (0 .. $#prms) {
2004 $prm_clean = $prms[$px];
2005 $prm_clean =~ s/\[.*\]//;
2006 $prm_clean =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i;
2007 # ignore array size in a parameter string;
2008 # however, the original param string may contain
2009 # spaces, e.g.: addr[6 + 2]
2010 # and this appears in @prms as "addr[6" since the
2011 # parameter list is split at spaces;
2012 # hence just ignore "[..." for the sections check;
2013 $prm_clean =~ s/\[.*//;
2015 ##$prm_clean =~ s/^\**//;
2016 if ($prm_clean eq $sects[$sx]) {
2022 if ($decl_type eq "function") {
2023 print STDERR "Warning(${file}:$.): " .
2024 "Excess function parameter " .
2026 "description in '$decl_name'\n";
2029 if ($nested !~ m/\Q$sects[$sx]\E/) {
2030 print STDERR "Warning(${file}:$.): " .
2031 "Excess struct/union/enum/typedef member " .
2033 "description in '$decl_name'\n";
2042 # takes a function prototype and the name of the current file being
2043 # processed and spits out all the details stored in the global
2045 sub dump_function($$) {
2046 my $prototype = shift;
2049 $prototype =~ s/^static +//;
2050 $prototype =~ s/^extern +//;
2051 $prototype =~ s/^asmlinkage +//;
2052 $prototype =~ s/^inline +//;
2053 $prototype =~ s/^__inline__ +//;
2054 $prototype =~ s/^__inline +//;
2055 $prototype =~ s/^__always_inline +//;
2056 $prototype =~ s/^noinline +//;
2057 $prototype =~ s/__devinit +//;
2058 $prototype =~ s/__init +//;
2059 $prototype =~ s/__init_or_module +//;
2060 $prototype =~ s/__must_check +//;
2061 $prototype =~ s/__weak +//;
2062 $prototype =~ s/^#\s*define\s+//; #ak added
2063 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
2065 # Yes, this truly is vile. We are looking for:
2066 # 1. Return type (may be nothing if we're looking at a macro)
2068 # 3. Function parameters.
2070 # All the while we have to watch out for function pointer parameters
2071 # (which IIRC is what the two sections are for), C types (these
2072 # regexps don't even start to express all the possibilities), and
2075 # If you mess with these regexps, it's a good idea to check that
2076 # the following functions' documentation still comes out right:
2077 # - parport_register_device (function pointer parameters)
2078 # - atomic_set (macro)
2079 # - pci_match_device, __copy_to_user (long return type)
2081 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2082 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2083 $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2084 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2085 $prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2086 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2087 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2088 $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2089 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2090 $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2091 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2092 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2093 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2094 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2095 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2096 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
2097 $prototype =~ m/^(\w+\s+\w+\s*\*\s*\w+\s*\*\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
2099 $declaration_name = $2;
2102 create_parameterlist($args, ',', $file);
2104 print STDERR "Error(${file}:$.): cannot understand prototype: '$prototype'\n";
2109 my $prms = join " ", @parameterlist;
2110 check_sections($file, $declaration_name, "function", $sectcheck, $prms, "");
2112 output_declaration($declaration_name,
2114 {'function' => $declaration_name,
2115 'module' => $modulename,
2116 'functiontype' => $return_type,
2117 'parameterlist' => \@parameterlist,
2118 'parameterdescs' => \%parameterdescs,
2119 'parametertypes' => \%parametertypes,
2120 'sectionlist' => \@sectionlist,
2121 'sections' => \%sections,
2122 'purpose' => $declaration_purpose
2129 %parameterdescs = ();
2130 %parametertypes = ();
2131 @parameterlist = ();
2135 $struct_actual = "";
2141 sub tracepoint_munge($) {
2143 my $tracepointname = 0;
2144 my $tracepointargs = 0;
2146 if ($prototype =~ m/TRACE_EVENT\((.*?),/) {
2147 $tracepointname = $1;
2149 if ($prototype =~ m/DEFINE_SINGLE_EVENT\((.*?),/) {
2150 $tracepointname = $1;
2152 if ($prototype =~ m/DEFINE_EVENT\((.*?),(.*?),/) {
2153 $tracepointname = $2;
2155 $tracepointname =~ s/^\s+//; #strip leading whitespace
2156 if ($prototype =~ m/TP_PROTO\((.*?)\)/) {
2157 $tracepointargs = $1;
2159 if (($tracepointname eq 0) || ($tracepointargs eq 0)) {
2160 print STDERR "Warning(${file}:$.): Unrecognized tracepoint format: \n".
2163 $prototype = "static inline void trace_$tracepointname($tracepointargs)";
2167 sub syscall_munge() {
2170 $prototype =~ s@[\r\n\t]+@ @gos; # strip newlines/CR's/tabs
2171 ## if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) {
2172 if ($prototype =~ m/SYSCALL_DEFINE0/) {
2174 ## $prototype = "long sys_$1(void)";
2177 $prototype =~ s/SYSCALL_DEFINE.*\(/long sys_/; # fix return type & func name
2178 if ($prototype =~ m/long (sys_.*?),/) {
2179 $prototype =~ s/,/\(/;
2181 $prototype =~ s/\)/\(void\)/;
2184 # now delete all of the odd-number commas in $prototype
2185 # so that arg types & arg names don't have a comma between them
2187 my $len = length($prototype);
2189 $len = 0; # skip the for-loop
2191 for (my $ix = 0; $ix < $len; $ix++) {
2192 if (substr($prototype, $ix, 1) eq ',') {
2194 if ($count % 2 == 1) {
2195 substr($prototype, $ix, 1) = ' ';
2201 sub process_state3_function($$) {
2205 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
2207 if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#\s*define/)) {
2210 elsif ($x =~ /([^\{]*)/) {
2214 if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) {
2215 $prototype =~ s@/\*.*?\*/@@gos; # strip comments.
2216 $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
2217 $prototype =~ s@^\s+@@gos; # strip leading spaces
2218 if ($prototype =~ /SYSCALL_DEFINE/) {
2221 if ($prototype =~ /TRACE_EVENT/ || $prototype =~ /DEFINE_EVENT/ ||
2222 $prototype =~ /DEFINE_SINGLE_EVENT/)
2224 tracepoint_munge($file);
2226 dump_function($prototype, $file);
2231 sub process_state3_type($$) {
2235 $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
2236 $x =~ s@^\s+@@gos; # strip leading spaces
2237 $x =~ s@\s+$@@gos; # strip trailing spaces
2238 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
2241 # To distinguish preprocessor directive from regular declaration later.
2246 if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
2247 $prototype .= $1 . $2;
2248 ($2 eq '{') && $brcount++;
2249 ($2 eq '}') && $brcount--;
2250 if (($2 eq ';') && ($brcount == 0)) {
2251 dump_declaration($prototype, $file);
2263 # xml_escape: replace <, >, and & in the text stream;
2265 # however, formatting controls that are generated internally/locally in the
2266 # kernel-doc script are not escaped here; instead, they begin life like
2267 # $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings
2268 # are converted to their mnemonic-expected output, without the 4 * '\' & ':',
2269 # just before actual output; (this is done by local_unescape())
2272 if (($output_mode eq "text") || ($output_mode eq "man")) {
2275 $text =~ s/\&/\\\\\\amp;/g;
2276 $text =~ s/\</\\\\\\lt;/g;
2277 $text =~ s/\>/\\\\\\gt;/g;
2281 # convert local escape strings to html
2282 # local escape strings look like: '\\\\menmonic:' (that's 4 backslashes)
2283 sub local_unescape($) {
2285 if (($output_mode eq "text") || ($output_mode eq "man")) {
2288 $text =~ s/\\\\\\\\lt:/</g;
2289 $text =~ s/\\\\\\\\gt:/>/g;
2293 sub process_file($) {
2299 my $initial_section_counter = $section_counter;
2301 if (defined($ENV{'SRCTREE'})) {
2302 $file = "$ENV{'SRCTREE'}" . "/" . "@_";
2307 if (defined($source_map{$file})) {
2308 $file = $source_map{$file};
2311 if (!open(IN,"<$file")) {
2312 print STDERR "Error: Cannot open file $file\n";
2319 $section_counter = 0;
2321 while (s/\\\s*$//) {
2325 if (/$doc_start/o) {
2326 $state = 1; # next line is always the function name
2329 } elsif ($state == 1) { # this line is the function name (always)
2330 if (/$doc_block/o) {
2334 $section = $section_intro;
2339 elsif (/$doc_decl/o) {
2341 if (/\s*([\w\s]+?)\s*-/) {
2347 # strip leading/trailing/multiple spaces
2351 $descr =~ s/\s+/ /g;
2352 $declaration_purpose = xml_escape($descr);
2355 $declaration_purpose = "";
2358 if (($declaration_purpose eq "") && $verbose) {
2359 print STDERR "Warning(${file}:$.): missing initial short description on line:\n";
2364 if ($identifier =~ m/^struct/) {
2365 $decl_type = 'struct';
2366 } elsif ($identifier =~ m/^union/) {
2367 $decl_type = 'union';
2368 } elsif ($identifier =~ m/^enum/) {
2369 $decl_type = 'enum';
2370 } elsif ($identifier =~ m/^typedef/) {
2371 $decl_type = 'typedef';
2373 $decl_type = 'function';
2377 print STDERR "Info(${file}:$.): Scanning doc for $identifier\n";
2380 print STDERR "Warning(${file}:$.): Cannot understand $_ on line $.",
2381 " - I thought it was a doc line\n";
2385 } elsif ($state == 2) { # look for head: lines, and include content
2390 if (($contents ne "") && ($contents ne "\n")) {
2391 if (!$in_doc_sect && $verbose) {
2392 print STDERR "Warning(${file}:$.): contents before sections\n";
2395 dump_section($file, $section, xml_escape($contents));
2396 $section = $section_default;
2401 $contents = $newcontents;
2402 if ($contents ne "") {
2403 while ((substr($contents, 0, 1) eq " ") ||
2404 substr($contents, 0, 1) eq "\t") {
2405 $contents = substr($contents, 1);
2409 $section = $newsection;
2410 } elsif (/$doc_end/) {
2412 if (($contents ne "") && ($contents ne "\n")) {
2413 dump_section($file, $section, xml_escape($contents));
2414 $section = $section_default;
2417 # look for doc_com + <text> + doc_end:
2418 if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') {
2419 print STDERR "Warning(${file}:$.): suspicious ending line: $_";
2426 # print STDERR "end of doc comment, looking for prototype\n";
2427 } elsif (/$doc_content/) {
2428 # miguel-style comment kludge, look for blank lines after
2429 # @parameter line to signify start of description
2431 if ($section =~ m/^@/ || $section eq $section_context) {
2432 dump_section($file, $section, xml_escape($contents));
2433 $section = $section_default;
2439 } elsif ($in_purpose == 1) {
2440 # Continued declaration purpose
2441 chomp($declaration_purpose);
2442 $declaration_purpose .= " " . xml_escape($1);
2443 $declaration_purpose =~ s/\s+/ /g;
2445 $contents .= $1 . "\n";
2448 # i dont know - bad line? ignore.
2449 print STDERR "Warning(${file}:$.): bad line: $_";
2452 } elsif ($state == 3) { # scanning for function '{' (end of prototype)
2453 if ($decl_type eq 'function') {
2454 process_state3_function($_, $file);
2456 process_state3_type($_, $file);
2458 } elsif ($state == 4) {
2459 # Documentation block
2461 dump_doc_section($file, $section, xml_escape($contents));
2465 %parameterdescs = ();
2466 %parametertypes = ();
2467 @parameterlist = ();
2472 $section = $section_intro;
2479 dump_doc_section($file, $section, xml_escape($contents));
2483 %parameterdescs = ();
2484 %parametertypes = ();
2485 @parameterlist = ();
2491 elsif (/$doc_content/)
2495 $contents .= $blankline;
2499 $contents .= $1 . "\n";
2504 if ($initial_section_counter == $section_counter) {
2505 print STDERR "Warning(${file}): no structured comments found\n";
2506 if ($output_mode eq "xml") {
2507 # The template wants at least one RefEntry here; make one.
2508 print "<refentry>\n";
2509 print " <refnamediv>\n";
2510 print " <refname>\n";
2512 print " </refname>\n";
2513 print " <refpurpose>\n";
2514 print " Document generation inconsistency\n";
2515 print " </refpurpose>\n";
2516 print " </refnamediv>\n";
2517 print " <refsect1>\n";
2520 print " </title>\n";
2521 print " <warning>\n";
2523 print " The template for this document tried to insert\n";
2524 print " the structured comment from the file\n";
2525 print " <filename>${file}</filename> at this point,\n";
2526 print " but none was found.\n";
2527 print " This dummy section is inserted to allow\n";
2528 print " generation to continue.\n";
2530 print " </warning>\n";
2531 print " </refsect1>\n";
2532 print "</refentry>\n";
2538 $kernelversion = get_kernel_version();
2540 # generate a sequence of code that will splice in highlighting information
2541 # using the s// operator.
2542 foreach my $pattern (keys %highlights) {
2543 # print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
2544 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
2547 # Read the file that maps relative names to absolute names for
2548 # separate source and object directories and for shadow trees.
2549 if (open(SOURCE_MAP, "<.tmp_filelist.txt")) {
2550 my ($relname, $absname);
2551 while(<SOURCE_MAP>) {
2553 ($relname, $absname) = (split())[0..1];
2554 $relname =~ s:^/+::;
2555 $source_map{$relname} = $absname;
2564 if ($verbose && $errors) {
2565 print STDERR "$errors errors\n";
2567 if ($verbose && $warnings) {
2568 print STDERR "$warnings warnings\n";