blob: 8bb83a100edb81316b4f99f419a0e826fe9739f2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 22:20:361#!/usr/bin/perl -w
2
3use strict;
4
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 ##
Randy Dunlap94dc7ad2008-04-28 09:16:348## Copyright (C) 2005-2008 Randy Dunlap ##
Linus Torvalds1da177e2005-04-16 22:20:369## ##
10## #define enhancements by Armin Kuster <akuster@mvista.com> ##
11## Copyright (c) 2000 MontaVista Software, Inc. ##
12## ##
13## This software falls under the GNU General Public License. ##
14## Please read the COPYING file for more information ##
15
16# w.o. 03-11-2000: added the '-filelist' option.
17
18# 18/01/2001 - Cleanups
19# Functions prototyped as foo(void) same as foo()
20# Stop eval'ing where we don't need to.
21# -- huggie@earth.li
22
23# 27/06/2001 - Allowed whitespace after initial "/**" and
24# allowed comments before function declarations.
25# -- Christian Kreibich <ck@whoop.org>
26
27# Still to do:
28# - add perldoc documentation
29# - Look more closely at some of the scarier bits :)
30
31# 26/05/2001 - Support for separate source and object trees.
32# Return error code.
33# Keith Owens <kaos@ocs.com.au>
34
35# 23/09/2001 - Added support for typedefs, structs, enums and unions
36# Support for Context section; can be terminated using empty line
37# Small fixes (like spaces vs. \s in regex)
38# -- Tim Jansen <tim@tjansen.de>
39
40
41#
42# This will read a 'c' file and scan for embedded comments in the
43# style of gnome comments (+minor extensions - see below).
44#
45
46# Note: This only supports 'c'.
47
48# usage:
Johannes Berg4b445952007-10-24 22:08:4849# kernel-doc [ -docbook | -html | -text | -man ] [ -no-doc-sections ]
Linus Torvalds1da177e2005-04-16 22:20:3650# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
51# or
52# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile
53#
54# Set output format using one of -docbook -html -text or -man. Default is man.
55#
Johannes Berg4b445952007-10-24 22:08:4856# -no-doc-sections
57# Do not output DOC: sections
58#
Linus Torvalds1da177e2005-04-16 22:20:3659# -function funcname
Johannes Bergb112e0f2007-10-24 22:08:4860# If set, then only generate documentation for the given function(s) or
61# DOC: section titles. All other functions and DOC: sections are ignored.
Linus Torvalds1da177e2005-04-16 22:20:3662#
63# -nofunction funcname
Johannes Bergb112e0f2007-10-24 22:08:4864# If set, then only generate documentation for the other function(s)/DOC:
65# sections. Cannot be used together with -function (yes, that's a bug --
66# perl hackers can fix it 8))
Linus Torvalds1da177e2005-04-16 22:20:3667#
68# c files - list of 'c' files to process
69#
70# All output goes to stdout, with errors to stderr.
71
72#
73# format of comments.
74# In the following table, (...)? signifies optional structure.
75# (...)* signifies 0 or more structure elements
76# /**
77# * function_name(:)? (- short description)?
78# (* @parameterx: (description of parameter x)?)*
79# (* a blank line)?
80# * (Description:)? (Description of function)?
81# * (section header: (section description)? )*
82# (*)?*/
83#
84# So .. the trivial example would be:
85#
86# /**
87# * my_function
88# **/
89#
Randy Dunlap891dcd22007-02-10 09:45:5390# If the Description: header tag is omitted, then there must be a blank line
Linus Torvalds1da177e2005-04-16 22:20:3691# after the last parameter specification.
92# e.g.
93# /**
94# * my_function - does my stuff
95# * @my_arg: its mine damnit
96# *
Randy Dunlap3c3b8092006-02-01 11:06:5897# * Does my stuff explained.
Linus Torvalds1da177e2005-04-16 22:20:3698# */
99#
100# or, could also use:
101# /**
102# * my_function - does my stuff
103# * @my_arg: its mine damnit
Randy Dunlap3c3b8092006-02-01 11:06:58104# * Description: Does my stuff explained.
Linus Torvalds1da177e2005-04-16 22:20:36105# */
106# etc.
107#
Randy Dunlap3c3b8092006-02-01 11:06:58108# Beside functions you can also write documentation for structs, unions,
109# enums and typedefs. Instead of the function name you must write the name
110# of the declaration; the struct/union/enum/typedef must always precede
111# the name. Nesting of declarations is not supported.
Linus Torvalds1da177e2005-04-16 22:20:36112# Use the argument mechanism to document members or constants.
113# e.g.
114# /**
115# * struct my_struct - short description
116# * @a: first member
117# * @b: second member
Randy Dunlap3c3b8092006-02-01 11:06:58118# *
Linus Torvalds1da177e2005-04-16 22:20:36119# * Longer description
120# */
121# struct my_struct {
122# int a;
123# int b;
Martin Waitzaeec46b2005-11-14 00:08:13124# /* private: */
125# int c;
Linus Torvalds1da177e2005-04-16 22:20:36126# };
127#
128# All descriptions can be multiline, except the short function description.
Randy Dunlap3c3b8092006-02-01 11:06:58129#
130# You can also add additional sections. When documenting kernel functions you
131# should document the "Context:" of the function, e.g. whether the functions
Linus Torvalds1da177e2005-04-16 22:20:36132# can be called form interrupts. Unlike other sections you can end it with an
Randy Dunlap3c3b8092006-02-01 11:06:58133# empty line.
134# Example-sections should contain the string EXAMPLE so that they are marked
Linus Torvalds1da177e2005-04-16 22:20:36135# appropriately in DocBook.
136#
137# Example:
138# /**
139# * user_function - function that can only be called in user context
140# * @a: some argument
141# * Context: !in_interrupt()
Randy Dunlap3c3b8092006-02-01 11:06:58142# *
Linus Torvalds1da177e2005-04-16 22:20:36143# * Some description
144# * Example:
145# * user_function(22);
146# */
147# ...
148#
149#
150# All descriptive text is further processed, scanning for the following special
151# patterns, which are highlighted appropriately.
152#
153# 'funcname()' - function
154# '$ENVVAR' - environmental variable
155# '&struct_name' - name of a structure (up to two words including 'struct')
156# '@parameter' - name of a parameter
157# '%CONST' - name of a constant.
158
159my $errors = 0;
160my $warnings = 0;
Randy Dunlap5f8c7c92007-07-19 08:48:24161my $anon_struct_union = 0;
Linus Torvalds1da177e2005-04-16 22:20:36162
163# match expressions used to find embedded type information
164my $type_constant = '\%([-_\w]+)';
165my $type_func = '(\w+)\(\)';
166my $type_param = '\@(\w+)';
Randy Dunlap3eb014a2007-05-08 07:29:51167my $type_struct = '\&((struct\s*)*[_\w]+)';
Randy Dunlap6b5b55f2007-10-17 06:31:20168my $type_struct_xml = '\\&amp;((struct\s*)*[_\w]+)';
Linus Torvalds1da177e2005-04-16 22:20:36169my $type_env = '(\$\w+)';
170
171# Output conversion substitutions.
172# One for each output format
173
174# these work fairly well
175my %highlights_html = ( $type_constant, "<i>\$1</i>",
176$type_func, "<b>\$1</b>",
Randy Dunlap3eb014a2007-05-08 07:29:51177$type_struct_xml, "<i>\$1</i>",
178$type_env, "<b><i>\$1</i></b>",
Linus Torvalds1da177e2005-04-16 22:20:36179$type_param, "<tt><b>\$1</b></tt>" );
Randy Dunlap6b5b55f2007-10-17 06:31:20180my $local_lt = "\\\\\\\\lt:";
181my $local_gt = "\\\\\\\\gt:";
182my $blankline_html = $local_lt . "p" . $local_gt;# was "<p>"
Linus Torvalds1da177e2005-04-16 22:20:36183
184# XML, docbook format
185my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>",
186$type_constant, "<constant>\$1</constant>",
187$type_func, "<function>\$1</function>",
Johannes Berg5c98fc02007-10-24 22:08:48188$type_struct_xml, "<structname>\$1</structname>",
Linus Torvalds1da177e2005-04-16 22:20:36189$type_env, "<envar>\$1</envar>",
190$type_param, "<parameter>\$1</parameter>" );
Johannes Berg5c98fc02007-10-24 22:08:48191my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n";
Linus Torvalds1da177e2005-04-16 22:20:36192
193# gnome, docbook format
194my %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>",
195 $type_func, "<function>\$1</function>",
196 $type_struct, "<structname>\$1</structname>",
197 $type_env, "<envar>\$1</envar>",
198 $type_param, "<parameter>\$1</parameter>" );
199my $blankline_gnome = "</para><para>\n";
200
201# these are pretty rough
202my %highlights_man = ( $type_constant, "\$1",
203 $type_func, "\\\\fB\$1\\\\fP",
204 $type_struct, "\\\\fI\$1\\\\fP",
205 $type_param, "\\\\fI\$1\\\\fP" );
206my $blankline_man = "";
207
208# text-mode
209my %highlights_text = ( $type_constant, "\$1",
210$type_func, "\$1",
211$type_struct, "\$1",
212$type_param, "\$1" );
213my $blankline_text = "";
214
215
216sub usage {
Johannes Berg4b445952007-10-24 22:08:48217 print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ] [ -no-doc-sections ]\n";
Linus Torvalds1da177e2005-04-16 22:20:36218 print " [ -function funcname [ -function funcname ...] ]\n";
219 print " [ -nofunction funcname [ -nofunction funcname ...] ]\n";
220 print " c source file(s) > outputfile\n";
Randy Dunlap77cc23b2008-02-07 08:13:42221 print " -v : verbose output, more warnings & other info listed\n";
Linus Torvalds1da177e2005-04-16 22:20:36222 exit 1;
223}
224
225# read arguments
226if ($#ARGV==-1) {
227 usage();
228}
229
230my $verbose = 0;
231my $output_mode = "man";
Johannes Berg4b445952007-10-24 22:08:48232my $no_doc_sections = 0;
Linus Torvalds1da177e2005-04-16 22:20:36233my %highlights = %highlights_man;
234my $blankline = $blankline_man;
235my $modulename = "Kernel API";
236my $function_only = 0;
Randy Dunlap3c3b8092006-02-01 11:06:58237my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
238'July', 'August', 'September', 'October',
239'November', 'December')[(localtime)[4]] .
Linus Torvalds1da177e2005-04-16 22:20:36240 " " . ((localtime)[5]+1900);
241
242# Essentially these are globals
243# They probably want to be tidied up made more localised or summat.
244# CAVEAT EMPTOR! Some of the others I localised may not want to be which
245# could cause "use of undefined value" or other bugs.
246my ($function, %function_table,%parametertypes,$declaration_purpose);
247my ($type,$declaration_name,$return_type);
248my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map);
249
Randy Dunlapbd0e88e2008-03-13 19:32:43250if (defined($ENV{'KBUILD_VERBOSE'})) {
251$verbose = "$ENV{'KBUILD_VERBOSE'}";
252}
253
Randy Dunlap3c3b8092006-02-01 11:06:58254# Generated docbook code is inserted in a template at a point where
Linus Torvalds1da177e2005-04-16 22:20:36255# docbook v3.1 requires a non-zero sequence of RefEntry's; see:
256# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
257# We keep track of number of generated entries and generate a dummy
258# if needs be to ensure the expanded template can be postprocessed
259# into html.
260my $section_counter = 0;
261
262my $lineprefix="";
263
264# states
265# 0 - normal code
266# 1 - looking for function name
267# 2 - scanning field start.
268# 3 - scanning prototype.
269# 4 - documentation block
270my $state;
Randy Dunlap850622d2006-06-25 12:48:55271my $in_doc_sect;
Linus Torvalds1da177e2005-04-16 22:20:36272
273#declaration types: can be
274# 'function', 'struct', 'union', 'enum', 'typedef'
275my $decl_type;
276
277my $doc_special = "\@\%\$\&";
278
279my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
280my $doc_end = '\*/';
281my $doc_com = '\s*\*\s*';
282my $doc_decl = $doc_com.'(\w+)';
Randy Dunlap891dcd22007-02-10 09:45:53283my $doc_sect = $doc_com.'(['.$doc_special.']?[\w\s]+):(.*)';
Linus Torvalds1da177e2005-04-16 22:20:36284my $doc_content = $doc_com.'(.*)';
285my $doc_block = $doc_com.'DOC:\s*(.*)?';
286
287my %constants;
288my %parameterdescs;
289my @parameterlist;
290my %sections;
291my @sectionlist;
Randy Dunlapa1d94aa2008-12-19 16:49:30292my $sectcheck;
293my $struct_actual;
Linus Torvalds1da177e2005-04-16 22:20:36294
295my $contents = "";
296my $section_default = "Description";# default section
297my $section_intro = "Introduction";
298my $section = $section_default;
299my $section_context = "Context";
300
301my $undescribed = "-- undescribed --";
302
303reset_state();
304
305while ($ARGV[0] =~ m/^-(.*)/) {
306 my $cmd = shift @ARGV;
307 if ($cmd eq "-html") {
308$output_mode = "html";
309%highlights = %highlights_html;
310$blankline = $blankline_html;
311 } elsif ($cmd eq "-man") {
312$output_mode = "man";
313%highlights = %highlights_man;
314$blankline = $blankline_man;
315 } elsif ($cmd eq "-text") {
316$output_mode = "text";
317%highlights = %highlights_text;
318$blankline = $blankline_text;
319 } elsif ($cmd eq "-docbook") {
320$output_mode = "xml";
321%highlights = %highlights_xml;
322$blankline = $blankline_xml;
323 } elsif ($cmd eq "-gnome") {
324$output_mode = "gnome";
325%highlights = %highlights_gnome;
326$blankline = $blankline_gnome;
327 } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document
328$modulename = shift @ARGV;
329 } elsif ($cmd eq "-function") { # to only output specific functions
330$function_only = 1;
331$function = shift @ARGV;
332$function_table{$function} = 1;
333 } elsif ($cmd eq "-nofunction") { # to only output specific functions
334$function_only = 2;
335$function = shift @ARGV;
336$function_table{$function} = 1;
337 } elsif ($cmd eq "-v") {
338$verbose = 1;
339 } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
340usage();
341 } elsif ($cmd eq '-filelist') {
342 $filelist = shift @ARGV;
Johannes Berg4b445952007-10-24 22:08:48343 } elsif ($cmd eq '-no-doc-sections') {
344 $no_doc_sections = 1;
Linus Torvalds1da177e2005-04-16 22:20:36345 }
346}
347
Borislav Petkov53f049f2007-05-08 07:30:54348# get kernel version from env
349sub get_kernel_version() {
Johannes Berg1b9bc222007-10-24 22:08:48350 my $version = 'unknown kernel version';
Borislav Petkov53f049f2007-05-08 07:30:54351
352 if (defined($ENV{'KERNELVERSION'})) {
353$version = $ENV{'KERNELVERSION'};
354 }
355 return $version;
356}
Borislav Petkov03662992007-05-09 09:33:43357my $kernelversion = get_kernel_version();
Linus Torvalds1da177e2005-04-16 22:20:36358
359# generate a sequence of code that will splice in highlighting information
360# using the s// operator.
361my $dohighlight = "";
362foreach my $pattern (keys %highlights) {
Randy Dunlap3eb014a2007-05-08 07:29:51363# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
Linus Torvalds1da177e2005-04-16 22:20:36364 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
365}
366
367##
368# dumps section contents to arrays/hashes intended for that purpose.
369#
370sub dump_section {
Randy Dunlap94dc7ad2008-04-28 09:16:34371 my $file = shift;
Linus Torvalds1da177e2005-04-16 22:20:36372 my $name = shift;
373 my $contents = join "\n", @_;
374
375 if ($name =~ m/$type_constant/) {
376$name = $1;
377# print STDERR "constant section '$1' = '$contents'\n";
378$constants{$name} = $contents;
379 } elsif ($name =~ m/$type_param/) {
380# print STDERR "parameter def '$1' = '$contents'\n";
381$name = $1;
382$parameterdescs{$name} = $contents;
Randy Dunlapa1d94aa2008-12-19 16:49:30383$sectcheck = $sectcheck . $name . " ";
Randy Dunlapced69092008-12-01 21:14:03384 } elsif ($name eq "@\.\.\.") {
385# print STDERR "parameter def '...' = '$contents'\n";
386$name = "...";
387$parameterdescs{$name} = $contents;
Randy Dunlapa1d94aa2008-12-19 16:49:30388$sectcheck = $sectcheck . $name . " ";
Linus Torvalds1da177e2005-04-16 22:20:36389 } else {
390# print STDERR "other section '$name' = '$contents'\n";
Randy Dunlap94dc7ad2008-04-28 09:16:34391if (defined($sections{$name}) && ($sections{$name} ne "")) {
392print STDERR "Error(${file}:$.): duplicate section name '$name'\n";
393++$errors;
394}
Linus Torvalds1da177e2005-04-16 22:20:36395$sections{$name} = $contents;
396push @sectionlist, $name;
397 }
398}
399
400##
Johannes Bergb112e0f2007-10-24 22:08:48401# dump DOC: section after checking that it should go out
402#
403sub dump_doc_section {
Randy Dunlap94dc7ad2008-04-28 09:16:34404 my $file = shift;
Johannes Bergb112e0f2007-10-24 22:08:48405 my $name = shift;
406 my $contents = join "\n", @_;
407
Johannes Berg4b445952007-10-24 22:08:48408 if ($no_doc_sections) {
409 return;
410 }
411
Johannes Bergb112e0f2007-10-24 22:08:48412 if (($function_only == 0) ||
413( $function_only == 1 && defined($function_table{$name})) ||
414( $function_only == 2 && !defined($function_table{$name})))
415 {
Randy Dunlap94dc7ad2008-04-28 09:16:34416dump_section($file, $name, $contents);
Johannes Bergb112e0f2007-10-24 22:08:48417output_blockhead({'sectionlist' => \@sectionlist,
418 'sections' => \%sections,
419 'module' => $modulename,
420 'content-only' => ($function_only != 0), });
421 }
422}
423
424##
Linus Torvalds1da177e2005-04-16 22:20:36425# output function
426#
427# parameterdescs, a hash.
428# function => "function name"
429# parameterlist => @list of parameters
430# parameterdescs => %parameter descriptions
431# sectionlist => @list of sections
Randy Dunlapa21217da2007-02-10 09:46:04432# sections => %section descriptions
Randy Dunlap3c3b8092006-02-01 11:06:58433#
Linus Torvalds1da177e2005-04-16 22:20:36434
435sub output_highlight {
436 my $contents = join "\n",@_;
437 my $line;
438
439# DEBUG
440# if (!defined $contents) {
441# use Carp;
442# confess "output_highlight got called with no args?\n";
443# }
444
Johannes Berg5c98fc02007-10-24 22:08:48445 if ($output_mode eq "html" || $output_mode eq "xml") {
Randy Dunlap6b5b55f2007-10-17 06:31:20446$contents = local_unescape($contents);
447# convert data read & converted thru xml_escape() into &xyz; format:
448$contents =~ s/\\\\\\/&/g;
449 }
Randy Dunlap3eb014a2007-05-08 07:29:51450# print STDERR "contents b4:$contents\n";
Linus Torvalds1da177e2005-04-16 22:20:36451 eval $dohighlight;
452 die $@ if $@;
Randy Dunlap3eb014a2007-05-08 07:29:51453# print STDERR "contents af:$contents\n";
454
Linus Torvalds1da177e2005-04-16 22:20:36455 foreach $line (split "\n", $contents) {
Randy Dunlap3c308792007-05-08 07:24:39456if ($line eq ""){
Randy Dunlap6b5b55f2007-10-17 06:31:20457 print $lineprefix, local_unescape($blankline);
Linus Torvalds1da177e2005-04-16 22:20:36458} else {
Randy Dunlap3c308792007-05-08 07:24:39459 $line =~ s/\\\\\\/\&/g;
Randy Dunlapcdccb312007-07-19 08:48:25460 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
461print "\\&$line";
462 } else {
463print $lineprefix, $line;
464 }
Linus Torvalds1da177e2005-04-16 22:20:36465}
466print "\n";
467 }
468}
469
470#output sections in html
471sub output_section_html(%) {
472 my %args = %{$_[0]};
473 my $section;
474
475 foreach $section (@{$args{'sectionlist'}}) {
476print "<h3>$section</h3>\n";
477print "<blockquote>\n";
478output_highlight($args{'sections'}{$section});
479print "</blockquote>\n";
Randy Dunlap3c3b8092006-02-01 11:06:58480 }
Linus Torvalds1da177e2005-04-16 22:20:36481}
482
483# output enum in html
484sub output_enum_html(%) {
485 my %args = %{$_[0]};
486 my ($parameter);
487 my $count;
488 print "<h2>enum ".$args{'enum'}."</h2>\n";
489
490 print "<b>enum ".$args{'enum'}."</b> {<br>\n";
491 $count = 0;
492 foreach $parameter (@{$args{'parameterlist'}}) {
Randy Dunlap3c308792007-05-08 07:24:39493print " <b>".$parameter."</b>";
Linus Torvalds1da177e2005-04-16 22:20:36494if ($count != $#{$args{'parameterlist'}}) {
495 $count++;
496 print ",\n";
497}
498print "<br>";
499 }
500 print "};<br>\n";
501
502 print "<h3>Constants</h3>\n";
503 print "<dl>\n";
504 foreach $parameter (@{$args{'parameterlist'}}) {
505print "<dt><b>".$parameter."</b>\n";
506print "<dd>";
507output_highlight($args{'parameterdescs'}{$parameter});
508 }
509 print "</dl>\n";
510 output_section_html(@_);
511 print "<hr>\n";
512}
513
Randy Dunlapd28bee02006-02-01 11:06:57514# output typedef in html
Linus Torvalds1da177e2005-04-16 22:20:36515sub output_typedef_html(%) {
516 my %args = %{$_[0]};
517 my ($parameter);
518 my $count;
519 print "<h2>typedef ".$args{'typedef'}."</h2>\n";
520
521 print "<b>typedef ".$args{'typedef'}."</b>\n";
522 output_section_html(@_);
523 print "<hr>\n";
524}
525
526# output struct in html
527sub output_struct_html(%) {
528 my %args = %{$_[0]};
529 my ($parameter);
530
Randy Dunlap262d9b012007-02-20 21:58:04531 print "<h2>".$args{'type'}." ".$args{'struct'}. " - " .$args{'purpose'}."</h2>\n";
Linus Torvalds1da177e2005-04-16 22:20:36532 print "<b>".$args{'type'}." ".$args{'struct'}."</b> {<br>\n";
533 foreach $parameter (@{$args{'parameterlist'}}) {
534if ($parameter =~ /^#/) {
535print "$parameter<br>\n";
536next;
537}
538my $parameter_name = $parameter;
539$parameter_name =~ s/\[.*//;
540
Randy Dunlap3c308792007-05-08 07:24:39541($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:36542$type = $args{'parametertypes'}{$parameter};
543if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
544 # pointer-to-function
Randy Dunlap3eb014a2007-05-08 07:29:51545 print "&nbsp; &nbsp; <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
Linus Torvalds1da177e2005-04-16 22:20:36546} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
Randy Dunlap3eb014a2007-05-08 07:29:51547 # bitfield
548 print "&nbsp; &nbsp; <i>$1</i> <b>$parameter</b>$2;<br>\n";
Linus Torvalds1da177e2005-04-16 22:20:36549} else {
Randy Dunlap3eb014a2007-05-08 07:29:51550 print "&nbsp; &nbsp; <i>$type</i> <b>$parameter</b>;<br>\n";
Linus Torvalds1da177e2005-04-16 22:20:36551}
552 }
553 print "};<br>\n";
554
555 print "<h3>Members</h3>\n";
556 print "<dl>\n";
557 foreach $parameter (@{$args{'parameterlist'}}) {
558($parameter =~ /^#/) && next;
559
560my $parameter_name = $parameter;
561$parameter_name =~ s/\[.*//;
562
Randy Dunlap3c308792007-05-08 07:24:39563($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:36564print "<dt><b>".$parameter."</b>\n";
565print "<dd>";
566output_highlight($args{'parameterdescs'}{$parameter_name});
567 }
568 print "</dl>\n";
569 output_section_html(@_);
570 print "<hr>\n";
571}
572
573# output function in html
574sub output_function_html(%) {
575 my %args = %{$_[0]};
576 my ($parameter, $section);
577 my $count;
Linus Torvalds1da177e2005-04-16 22:20:36578
Randy Dunlap262d9b012007-02-20 21:58:04579 print "<h2>" .$args{'function'}." - ".$args{'purpose'}."</h2>\n";
Linus Torvalds1da177e2005-04-16 22:20:36580 print "<i>".$args{'functiontype'}."</i>\n";
581 print "<b>".$args{'function'}."</b>\n";
582 print "(";
583 $count = 0;
584 foreach $parameter (@{$args{'parameterlist'}}) {
585$type = $args{'parametertypes'}{$parameter};
586if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
587 # pointer-to-function
588 print "<i>$1</i><b>$parameter</b>) <i>($2)</i>";
589} else {
590 print "<i>".$type."</i> <b>".$parameter."</b>";
591}
592if ($count != $#{$args{'parameterlist'}}) {
593 $count++;
594 print ",\n";
595}
596 }
597 print ")\n";
598
599 print "<h3>Arguments</h3>\n";
600 print "<dl>\n";
601 foreach $parameter (@{$args{'parameterlist'}}) {
602my $parameter_name = $parameter;
603$parameter_name =~ s/\[.*//;
604
Randy Dunlap3c308792007-05-08 07:24:39605($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:36606print "<dt><b>".$parameter."</b>\n";
607print "<dd>";
608output_highlight($args{'parameterdescs'}{$parameter_name});
609 }
610 print "</dl>\n";
611 output_section_html(@_);
612 print "<hr>\n";
613}
614
Johannes Bergb112e0f2007-10-24 22:08:48615# output DOC: block header in html
616sub output_blockhead_html(%) {
Linus Torvalds1da177e2005-04-16 22:20:36617 my %args = %{$_[0]};
618 my ($parameter, $section);
619 my $count;
620
621 foreach $section (@{$args{'sectionlist'}}) {
622print "<h3>$section</h3>\n";
623print "<ul>\n";
624output_highlight($args{'sections'}{$section});
625print "</ul>\n";
626 }
627 print "<hr>\n";
628}
629
630sub output_section_xml(%) {
631 my %args = %{$_[0]};
Randy Dunlap3c3b8092006-02-01 11:06:58632 my $section;
Linus Torvalds1da177e2005-04-16 22:20:36633 # print out each section
634 $lineprefix=" ";
635 foreach $section (@{$args{'sectionlist'}}) {
Rich Walkerc73894c2005-05-01 15:59:26636print "<refsect1>\n";
637print "<title>$section</title>\n";
Linus Torvalds1da177e2005-04-16 22:20:36638if ($section =~ m/EXAMPLE/i) {
Rich Walkerc73894c2005-05-01 15:59:26639 print "<informalexample><programlisting>\n";
640} else {
641 print "<para>\n";
Linus Torvalds1da177e2005-04-16 22:20:36642}
643output_highlight($args{'sections'}{$section});
644if ($section =~ m/EXAMPLE/i) {
Rich Walkerc73894c2005-05-01 15:59:26645 print "</programlisting></informalexample>\n";
646} else {
647 print "</para>\n";
Linus Torvalds1da177e2005-04-16 22:20:36648}
Rich Walkerc73894c2005-05-01 15:59:26649print "</refsect1>\n";
Linus Torvalds1da177e2005-04-16 22:20:36650 }
651}
652
653# output function in XML DocBook
654sub output_function_xml(%) {
655 my %args = %{$_[0]};
656 my ($parameter, $section);
657 my $count;
658 my $id;
659
660 $id = "API-".$args{'function'};
661 $id =~ s/[^A-Za-z0-9]/-/g;
662
Pavel Pisa5449bc942007-02-10 09:45:37663 print "<refentry id=\"$id\">\n";
Martin Waitz8b0c2d92005-05-01 15:59:27664 print "<refentryinfo>\n";
665 print " <title>LINUX</title>\n";
666 print " <productname>Kernel Hackers Manual</productname>\n";
667 print " <date>$man_date</date>\n";
668 print "</refentryinfo>\n";
Linus Torvalds1da177e2005-04-16 22:20:36669 print "<refmeta>\n";
Pavel Pisa5449bc942007-02-10 09:45:37670 print " <refentrytitle><phrase>".$args{'function'}."</phrase></refentrytitle>\n";
Martin Waitz8b0c2d92005-05-01 15:59:27671 print " <manvolnum>9</manvolnum>\n";
Borislav Petkov03662992007-05-09 09:33:43672 print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
Linus Torvalds1da177e2005-04-16 22:20:36673 print "</refmeta>\n";
674 print "<refnamediv>\n";
675 print " <refname>".$args{'function'}."</refname>\n";
676 print " <refpurpose>\n";
677 print " ";
678 output_highlight ($args{'purpose'});
679 print " </refpurpose>\n";
680 print "</refnamediv>\n";
681
682 print "<refsynopsisdiv>\n";
683 print " <title>Synopsis</title>\n";
684 print " <funcsynopsis><funcprototype>\n";
685 print " <funcdef>".$args{'functiontype'}." ";
686 print "<function>".$args{'function'}." </function></funcdef>\n";
687
688 $count = 0;
689 if ($#{$args{'parameterlist'}} >= 0) {
690foreach $parameter (@{$args{'parameterlist'}}) {
691 $type = $args{'parametertypes'}{$parameter};
692 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
693# pointer-to-function
694print " <paramdef>$1<parameter>$parameter</parameter>)\n";
695print " <funcparams>$2</funcparams></paramdef>\n";
696 } else {
697print " <paramdef>".$type;
698print " <parameter>$parameter</parameter></paramdef>\n";
699 }
700}
701 } else {
Martin Waitz6013d542005-05-01 15:59:25702print " <void/>\n";
Linus Torvalds1da177e2005-04-16 22:20:36703 }
704 print " </funcprototype></funcsynopsis>\n";
705 print "</refsynopsisdiv>\n";
706
707 # print parameters
708 print "<refsect1>\n <title>Arguments</title>\n";
709 if ($#{$args{'parameterlist'}} >= 0) {
710print " <variablelist>\n";
711foreach $parameter (@{$args{'parameterlist'}}) {
712 my $parameter_name = $parameter;
713 $parameter_name =~ s/\[.*//;
714
715 print " <varlistentry>\n <term><parameter>$parameter</parameter></term>\n";
716 print " <listitem>\n <para>\n";
717 $lineprefix=" ";
718 output_highlight($args{'parameterdescs'}{$parameter_name});
719 print " </para>\n </listitem>\n </varlistentry>\n";
720}
721print " </variablelist>\n";
722 } else {
723print " <para>\n None\n </para>\n";
724 }
725 print "</refsect1>\n";
726
727 output_section_xml(@_);
728 print "</refentry>\n\n";
729}
730
731# output struct in XML DocBook
732sub output_struct_xml(%) {
733 my %args = %{$_[0]};
734 my ($parameter, $section);
735 my $id;
736
737 $id = "API-struct-".$args{'struct'};
738 $id =~ s/[^A-Za-z0-9]/-/g;
739
Pavel Pisa5449bc942007-02-10 09:45:37740 print "<refentry id=\"$id\">\n";
Martin Waitz8b0c2d92005-05-01 15:59:27741 print "<refentryinfo>\n";
742 print " <title>LINUX</title>\n";
743 print " <productname>Kernel Hackers Manual</productname>\n";
744 print " <date>$man_date</date>\n";
745 print "</refentryinfo>\n";
Linus Torvalds1da177e2005-04-16 22:20:36746 print "<refmeta>\n";
Pavel Pisa5449bc942007-02-10 09:45:37747 print " <refentrytitle><phrase>".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
Martin Waitz8b0c2d92005-05-01 15:59:27748 print " <manvolnum>9</manvolnum>\n";
Borislav Petkov03662992007-05-09 09:33:43749 print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
Linus Torvalds1da177e2005-04-16 22:20:36750 print "</refmeta>\n";
751 print "<refnamediv>\n";
752 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n";
753 print " <refpurpose>\n";
754 print " ";
755 output_highlight ($args{'purpose'});
756 print " </refpurpose>\n";
757 print "</refnamediv>\n";
758
759 print "<refsynopsisdiv>\n";
760 print " <title>Synopsis</title>\n";
761 print " <programlisting>\n";
762 print $args{'type'}." ".$args{'struct'}." {\n";
763 foreach $parameter (@{$args{'parameterlist'}}) {
764if ($parameter =~ /^#/) {
765 print "$parameter\n";
766 next;
767}
768
769my $parameter_name = $parameter;
770$parameter_name =~ s/\[.*//;
771
772defined($args{'parameterdescs'}{$parameter_name}) || next;
Randy Dunlap3c308792007-05-08 07:24:39773($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:36774$type = $args{'parametertypes'}{$parameter};
775if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
776 # pointer-to-function
777 print " $1 $parameter) ($2);\n";
778} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
Randy Dunlap51f5a0c2007-07-19 08:48:24779 # bitfield
Linus Torvalds1da177e2005-04-16 22:20:36780 print " $1 $parameter$2;\n";
781} else {
782 print " ".$type." ".$parameter.";\n";
783}
784 }
785 print "};";
786 print " </programlisting>\n";
787 print "</refsynopsisdiv>\n";
788
789 print " <refsect1>\n";
790 print " <title>Members</title>\n";
791
Randy Dunlap39f00c02008-09-22 20:57:44792 if ($#{$args{'parameterlist'}} >= 0) {
Linus Torvalds1da177e2005-04-16 22:20:36793 print " <variablelist>\n";
794 foreach $parameter (@{$args{'parameterlist'}}) {
795 ($parameter =~ /^#/) && next;
796
797 my $parameter_name = $parameter;
798 $parameter_name =~ s/\[.*//;
799
800 defined($args{'parameterdescs'}{$parameter_name}) || next;
801 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
802 print " <varlistentry>";
803 print " <term>$parameter</term>\n";
804 print " <listitem><para>\n";
805 output_highlight($args{'parameterdescs'}{$parameter_name});
806 print " </para></listitem>\n";
807 print " </varlistentry>\n";
808 }
809 print " </variablelist>\n";
Randy Dunlap39f00c02008-09-22 20:57:44810 } else {
811print " <para>\n None\n </para>\n";
812 }
Linus Torvalds1da177e2005-04-16 22:20:36813 print " </refsect1>\n";
814
815 output_section_xml(@_);
816
817 print "</refentry>\n\n";
818}
819
820# output enum in XML DocBook
821sub output_enum_xml(%) {
822 my %args = %{$_[0]};
823 my ($parameter, $section);
824 my $count;
825 my $id;
826
827 $id = "API-enum-".$args{'enum'};
828 $id =~ s/[^A-Za-z0-9]/-/g;
829
Pavel Pisa5449bc942007-02-10 09:45:37830 print "<refentry id=\"$id\">\n";
Martin Waitz8b0c2d92005-05-01 15:59:27831 print "<refentryinfo>\n";
832 print " <title>LINUX</title>\n";
833 print " <productname>Kernel Hackers Manual</productname>\n";
834 print " <date>$man_date</date>\n";
835 print "</refentryinfo>\n";
Linus Torvalds1da177e2005-04-16 22:20:36836 print "<refmeta>\n";
Pavel Pisa5449bc942007-02-10 09:45:37837 print " <refentrytitle><phrase>enum ".$args{'enum'}."</phrase></refentrytitle>\n";
Martin Waitz8b0c2d92005-05-01 15:59:27838 print " <manvolnum>9</manvolnum>\n";
Borislav Petkov03662992007-05-09 09:33:43839 print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
Linus Torvalds1da177e2005-04-16 22:20:36840 print "</refmeta>\n";
841 print "<refnamediv>\n";
842 print " <refname>enum ".$args{'enum'}."</refname>\n";
843 print " <refpurpose>\n";
844 print " ";
845 output_highlight ($args{'purpose'});
846 print " </refpurpose>\n";
847 print "</refnamediv>\n";
848
849 print "<refsynopsisdiv>\n";
850 print " <title>Synopsis</title>\n";
851 print " <programlisting>\n";
852 print "enum ".$args{'enum'}." {\n";
853 $count = 0;
854 foreach $parameter (@{$args{'parameterlist'}}) {
Randy Dunlap3c308792007-05-08 07:24:39855print " $parameter";
856if ($count != $#{$args{'parameterlist'}}) {
Linus Torvalds1da177e2005-04-16 22:20:36857 $count++;
858 print ",";
Randy Dunlap3c308792007-05-08 07:24:39859}
Linus Torvalds1da177e2005-04-16 22:20:36860print "\n";
861 }
862 print "};";
863 print " </programlisting>\n";
864 print "</refsynopsisdiv>\n";
865
866 print "<refsect1>\n";
Randy Dunlap3c3b8092006-02-01 11:06:58867 print " <title>Constants</title>\n";
Linus Torvalds1da177e2005-04-16 22:20:36868 print " <variablelist>\n";
869 foreach $parameter (@{$args{'parameterlist'}}) {
870 my $parameter_name = $parameter;
871 $parameter_name =~ s/\[.*//;
872
873 print " <varlistentry>";
874 print " <term>$parameter</term>\n";
875 print " <listitem><para>\n";
876 output_highlight($args{'parameterdescs'}{$parameter_name});
877 print " </para></listitem>\n";
878 print " </varlistentry>\n";
879 }
880 print " </variablelist>\n";
881 print "</refsect1>\n";
882
883 output_section_xml(@_);
884
885 print "</refentry>\n\n";
886}
887
888# output typedef in XML DocBook
889sub output_typedef_xml(%) {
890 my %args = %{$_[0]};
891 my ($parameter, $section);
892 my $id;
893
894 $id = "API-typedef-".$args{'typedef'};
895 $id =~ s/[^A-Za-z0-9]/-/g;
896
Pavel Pisa5449bc942007-02-10 09:45:37897 print "<refentry id=\"$id\">\n";
Martin Waitz8b0c2d92005-05-01 15:59:27898 print "<refentryinfo>\n";
899 print " <title>LINUX</title>\n";
900 print " <productname>Kernel Hackers Manual</productname>\n";
901 print " <date>$man_date</date>\n";
902 print "</refentryinfo>\n";
Linus Torvalds1da177e2005-04-16 22:20:36903 print "<refmeta>\n";
Pavel Pisa5449bc942007-02-10 09:45:37904 print " <refentrytitle><phrase>typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
Martin Waitz8b0c2d92005-05-01 15:59:27905 print " <manvolnum>9</manvolnum>\n";
Linus Torvalds1da177e2005-04-16 22:20:36906 print "</refmeta>\n";
907 print "<refnamediv>\n";
908 print " <refname>typedef ".$args{'typedef'}."</refname>\n";
909 print " <refpurpose>\n";
910 print " ";
911 output_highlight ($args{'purpose'});
912 print " </refpurpose>\n";
913 print "</refnamediv>\n";
914
915 print "<refsynopsisdiv>\n";
916 print " <title>Synopsis</title>\n";
917 print " <synopsis>typedef ".$args{'typedef'}.";</synopsis>\n";
918 print "</refsynopsisdiv>\n";
919
920 output_section_xml(@_);
921
922 print "</refentry>\n\n";
923}
924
925# output in XML DocBook
Johannes Bergb112e0f2007-10-24 22:08:48926sub output_blockhead_xml(%) {
Linus Torvalds1da177e2005-04-16 22:20:36927 my %args = %{$_[0]};
928 my ($parameter, $section);
929 my $count;
930
931 my $id = $args{'module'};
932 $id =~ s/[^A-Za-z0-9]/-/g;
933
934 # print out each section
935 $lineprefix=" ";
936 foreach $section (@{$args{'sectionlist'}}) {
Johannes Bergb112e0f2007-10-24 22:08:48937if (!$args{'content-only'}) {
938print "<refsect1>\n <title>$section</title>\n";
939}
Linus Torvalds1da177e2005-04-16 22:20:36940if ($section =~ m/EXAMPLE/i) {
941 print "<example><para>\n";
Johannes Bergb112e0f2007-10-24 22:08:48942} else {
943 print "<para>\n";
Linus Torvalds1da177e2005-04-16 22:20:36944}
945output_highlight($args{'sections'}{$section});
946if ($section =~ m/EXAMPLE/i) {
947 print "</para></example>\n";
Johannes Bergb112e0f2007-10-24 22:08:48948} else {
949 print "</para>";
Linus Torvalds1da177e2005-04-16 22:20:36950}
Johannes Bergb112e0f2007-10-24 22:08:48951if (!$args{'content-only'}) {
952print "\n</refsect1>\n";
953}
Linus Torvalds1da177e2005-04-16 22:20:36954 }
955
956 print "\n\n";
957}
958
959# output in XML DocBook
960sub output_function_gnome {
961 my %args = %{$_[0]};
962 my ($parameter, $section);
963 my $count;
964 my $id;
965
966 $id = $args{'module'}."-".$args{'function'};
967 $id =~ s/[^A-Za-z0-9]/-/g;
968
969 print "<sect2>\n";
970 print " <title id=\"$id\">".$args{'function'}."</title>\n";
971
972 print " <funcsynopsis>\n";
973 print " <funcdef>".$args{'functiontype'}." ";
974 print "<function>".$args{'function'}." ";
975 print "</function></funcdef>\n";
976
977 $count = 0;
978 if ($#{$args{'parameterlist'}} >= 0) {
979foreach $parameter (@{$args{'parameterlist'}}) {
980 $type = $args{'parametertypes'}{$parameter};
981 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
982# pointer-to-function
983print " <paramdef>$1 <parameter>$parameter</parameter>)\n";
984print " <funcparams>$2</funcparams></paramdef>\n";
985 } else {
986print " <paramdef>".$type;
987print " <parameter>$parameter</parameter></paramdef>\n";
988 }
989}
990 } else {
991print " <void>\n";
992 }
993 print " </funcsynopsis>\n";
994 if ($#{$args{'parameterlist'}} >= 0) {
995print " <informaltable pgwide=\"1\" frame=\"none\" role=\"params\">\n";
996print "<tgroup cols=\"2\">\n";
997print "<colspec colwidth=\"2*\">\n";
998print "<colspec colwidth=\"8*\">\n";
999print "<tbody>\n";
1000foreach $parameter (@{$args{'parameterlist'}}) {
1001 my $parameter_name = $parameter;
1002 $parameter_name =~ s/\[.*//;
1003
1004 print " <row><entry align=\"right\"><parameter>$parameter</parameter></entry>\n";
1005 print " <entry>\n";
1006 $lineprefix=" ";
1007 output_highlight($args{'parameterdescs'}{$parameter_name});
1008 print " </entry></row>\n";
1009}
1010print " </tbody></tgroup></informaltable>\n";
1011 } else {
1012print " <para>\n None\n </para>\n";
1013 }
1014
1015 # print out each section
1016 $lineprefix=" ";
1017 foreach $section (@{$args{'sectionlist'}}) {
1018print "<simplesect>\n <title>$section</title>\n";
1019if ($section =~ m/EXAMPLE/i) {
1020 print "<example><programlisting>\n";
1021} else {
1022}
1023print "<para>\n";
1024output_highlight($args{'sections'}{$section});
1025print "</para>\n";
1026if ($section =~ m/EXAMPLE/i) {
1027 print "</programlisting></example>\n";
1028} else {
1029}
1030print " </simplesect>\n";
1031 }
1032
1033 print "</sect2>\n\n";
1034}
1035
1036##
1037# output function in man
1038sub output_function_man(%) {
1039 my %args = %{$_[0]};
1040 my ($parameter, $section);
1041 my $count;
1042
1043 print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n";
1044
1045 print ".SH NAME\n";
1046 print $args{'function'}." \\- ".$args{'purpose'}."\n";
1047
1048 print ".SH SYNOPSIS\n";
Randy Dunlapa21217da2007-02-10 09:46:041049 if ($args{'functiontype'} ne "") {
1050print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";
1051 } else {
1052print ".B \"".$args{'function'}."\n";
1053 }
Linus Torvalds1da177e2005-04-16 22:20:361054 $count = 0;
1055 my $parenth = "(";
1056 my $post = ",";
1057 foreach my $parameter (@{$args{'parameterlist'}}) {
1058if ($count == $#{$args{'parameterlist'}}) {
1059 $post = ");";
1060}
1061$type = $args{'parametertypes'}{$parameter};
1062if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1063 # pointer-to-function
1064 print ".BI \"".$parenth.$1."\" ".$parameter." \") (".$2.")".$post."\"\n";
1065} else {
1066 $type =~ s/([^\*])$/$1 /;
1067 print ".BI \"".$parenth.$type."\" ".$parameter." \"".$post."\"\n";
1068}
1069$count++;
1070$parenth = "";
1071 }
1072
1073 print ".SH ARGUMENTS\n";
1074 foreach $parameter (@{$args{'parameterlist'}}) {
1075my $parameter_name = $parameter;
1076$parameter_name =~ s/\[.*//;
1077
1078print ".IP \"".$parameter."\" 12\n";
1079output_highlight($args{'parameterdescs'}{$parameter_name});
1080 }
1081 foreach $section (@{$args{'sectionlist'}}) {
1082print ".SH \"", uc $section, "\"\n";
1083output_highlight($args{'sections'}{$section});
1084 }
1085}
1086
1087##
1088# output enum in man
1089sub output_enum_man(%) {
1090 my %args = %{$_[0]};
1091 my ($parameter, $section);
1092 my $count;
1093
1094 print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual\" LINUX\n";
1095
1096 print ".SH NAME\n";
1097 print "enum ".$args{'enum'}." \\- ".$args{'purpose'}."\n";
1098
1099 print ".SH SYNOPSIS\n";
1100 print "enum ".$args{'enum'}." {\n";
1101 $count = 0;
1102 foreach my $parameter (@{$args{'parameterlist'}}) {
Randy Dunlap3c308792007-05-08 07:24:391103print ".br\n.BI \" $parameter\"\n";
Linus Torvalds1da177e2005-04-16 22:20:361104if ($count == $#{$args{'parameterlist'}}) {
1105 print "\n};\n";
1106 last;
1107}
1108else {
1109 print ", \n.br\n";
1110}
1111$count++;
1112 }
1113
1114 print ".SH Constants\n";
1115 foreach $parameter (@{$args{'parameterlist'}}) {
1116my $parameter_name = $parameter;
1117$parameter_name =~ s/\[.*//;
1118
1119print ".IP \"".$parameter."\" 12\n";
1120output_highlight($args{'parameterdescs'}{$parameter_name});
1121 }
1122 foreach $section (@{$args{'sectionlist'}}) {
1123print ".SH \"$section\"\n";
1124output_highlight($args{'sections'}{$section});
1125 }
1126}
1127
1128##
1129# output struct in man
1130sub output_struct_man(%) {
1131 my %args = %{$_[0]};
1132 my ($parameter, $section);
1133
1134 print ".TH \"$args{'module'}\" 9 \"".$args{'type'}." ".$args{'struct'}."\" \"$man_date\" \"API Manual\" LINUX\n";
1135
1136 print ".SH NAME\n";
1137 print $args{'type'}." ".$args{'struct'}." \\- ".$args{'purpose'}."\n";
1138
1139 print ".SH SYNOPSIS\n";
1140 print $args{'type'}." ".$args{'struct'}." {\n.br\n";
1141
1142 foreach my $parameter (@{$args{'parameterlist'}}) {
1143if ($parameter =~ /^#/) {
1144 print ".BI \"$parameter\"\n.br\n";
1145 next;
1146}
1147my $parameter_name = $parameter;
1148$parameter_name =~ s/\[.*//;
1149
Randy Dunlap3c308792007-05-08 07:24:391150($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:361151$type = $args{'parametertypes'}{$parameter};
1152if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1153 # pointer-to-function
1154 print ".BI \" ".$1."\" ".$parameter." \") (".$2.")"."\"\n;\n";
1155} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
Randy.Dunlap1d7e1d42006-07-01 11:36:341156 # bitfield
1157 print ".BI \" ".$1."\ \" ".$parameter.$2." \""."\"\n;\n";
Linus Torvalds1da177e2005-04-16 22:20:361158} else {
1159 $type =~ s/([^\*])$/$1 /;
1160 print ".BI \" ".$type."\" ".$parameter." \""."\"\n;\n";
1161}
1162print "\n.br\n";
1163 }
1164 print "};\n.br\n";
1165
Randy Dunlapc51d3dac2006-06-25 12:49:141166 print ".SH Members\n";
Linus Torvalds1da177e2005-04-16 22:20:361167 foreach $parameter (@{$args{'parameterlist'}}) {
1168($parameter =~ /^#/) && next;
1169
1170my $parameter_name = $parameter;
1171$parameter_name =~ s/\[.*//;
1172
Randy Dunlap3c308792007-05-08 07:24:391173($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:361174print ".IP \"".$parameter."\" 12\n";
1175output_highlight($args{'parameterdescs'}{$parameter_name});
1176 }
1177 foreach $section (@{$args{'sectionlist'}}) {
1178print ".SH \"$section\"\n";
1179output_highlight($args{'sections'}{$section});
1180 }
1181}
1182
1183##
1184# output typedef in man
1185sub output_typedef_man(%) {
1186 my %args = %{$_[0]};
1187 my ($parameter, $section);
1188
1189 print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual\" LINUX\n";
1190
1191 print ".SH NAME\n";
1192 print "typedef ".$args{'typedef'}." \\- ".$args{'purpose'}."\n";
1193
1194 foreach $section (@{$args{'sectionlist'}}) {
1195print ".SH \"$section\"\n";
1196output_highlight($args{'sections'}{$section});
1197 }
1198}
1199
Johannes Bergb112e0f2007-10-24 22:08:481200sub output_blockhead_man(%) {
Linus Torvalds1da177e2005-04-16 22:20:361201 my %args = %{$_[0]};
1202 my ($parameter, $section);
1203 my $count;
1204
1205 print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual\" LINUX\n";
1206
1207 foreach $section (@{$args{'sectionlist'}}) {
1208print ".SH \"$section\"\n";
1209output_highlight($args{'sections'}{$section});
1210 }
1211}
1212
1213##
1214# output in text
1215sub output_function_text(%) {
1216 my %args = %{$_[0]};
1217 my ($parameter, $section);
Randy Dunlapa21217da2007-02-10 09:46:041218 my $start;
Linus Torvalds1da177e2005-04-16 22:20:361219
Randy Dunlapf47634b2006-07-01 11:36:361220 print "Name:\n\n";
1221 print $args{'function'}." - ".$args{'purpose'}."\n";
1222
1223 print "\nSynopsis:\n\n";
Randy Dunlapa21217da2007-02-10 09:46:041224 if ($args{'functiontype'} ne "") {
1225$start = $args{'functiontype'}." ".$args{'function'}." (";
1226 } else {
1227$start = $args{'function'}." (";
1228 }
Linus Torvalds1da177e2005-04-16 22:20:361229 print $start;
Randy Dunlapa21217da2007-02-10 09:46:041230
Linus Torvalds1da177e2005-04-16 22:20:361231 my $count = 0;
1232 foreach my $parameter (@{$args{'parameterlist'}}) {
1233$type = $args{'parametertypes'}{$parameter};
1234if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1235 # pointer-to-function
1236 print $1.$parameter.") (".$2;
1237} else {
1238 print $type." ".$parameter;
1239}
1240if ($count != $#{$args{'parameterlist'}}) {
1241 $count++;
1242 print ",\n";
1243 print " " x length($start);
1244} else {
1245 print ");\n\n";
1246}
1247 }
1248
1249 print "Arguments:\n\n";
1250 foreach $parameter (@{$args{'parameterlist'}}) {
1251my $parameter_name = $parameter;
1252$parameter_name =~ s/\[.*//;
1253
1254print $parameter."\n\t".$args{'parameterdescs'}{$parameter_name}."\n";
1255 }
1256 output_section_text(@_);
1257}
1258
1259#output sections in text
1260sub output_section_text(%) {
1261 my %args = %{$_[0]};
1262 my $section;
1263
1264 print "\n";
1265 foreach $section (@{$args{'sectionlist'}}) {
1266print "$section:\n\n";
1267output_highlight($args{'sections'}{$section});
Randy Dunlap3c3b8092006-02-01 11:06:581268 }
Linus Torvalds1da177e2005-04-16 22:20:361269 print "\n\n";
1270}
1271
1272# output enum in text
1273sub output_enum_text(%) {
1274 my %args = %{$_[0]};
1275 my ($parameter);
1276 my $count;
1277 print "Enum:\n\n";
1278
Randy.Dunlap1d7e1d42006-07-01 11:36:341279 print "enum ".$args{'enum'}." - ".$args{'purpose'}."\n\n";
Linus Torvalds1da177e2005-04-16 22:20:361280 print "enum ".$args{'enum'}." {\n";
1281 $count = 0;
1282 foreach $parameter (@{$args{'parameterlist'}}) {
Randy Dunlap3c308792007-05-08 07:24:391283print "\t$parameter";
Linus Torvalds1da177e2005-04-16 22:20:361284if ($count != $#{$args{'parameterlist'}}) {
1285 $count++;
1286 print ",";
1287}
1288print "\n";
1289 }
1290 print "};\n\n";
1291
1292 print "Constants:\n\n";
1293 foreach $parameter (@{$args{'parameterlist'}}) {
1294print "$parameter\n\t";
1295print $args{'parameterdescs'}{$parameter}."\n";
1296 }
1297
1298 output_section_text(@_);
1299}
1300
1301# output typedef in text
1302sub output_typedef_text(%) {
1303 my %args = %{$_[0]};
1304 my ($parameter);
1305 my $count;
1306 print "Typedef:\n\n";
1307
Randy.Dunlap1d7e1d42006-07-01 11:36:341308 print "typedef ".$args{'typedef'}." - ".$args{'purpose'}."\n";
Linus Torvalds1da177e2005-04-16 22:20:361309 output_section_text(@_);
1310}
1311
1312# output struct as text
1313sub output_struct_text(%) {
1314 my %args = %{$_[0]};
1315 my ($parameter);
1316
Randy.Dunlap1d7e1d42006-07-01 11:36:341317 print $args{'type'}." ".$args{'struct'}." - ".$args{'purpose'}."\n\n";
Linus Torvalds1da177e2005-04-16 22:20:361318 print $args{'type'}." ".$args{'struct'}." {\n";
1319 foreach $parameter (@{$args{'parameterlist'}}) {
1320if ($parameter =~ /^#/) {
1321 print "$parameter\n";
1322 next;
1323}
1324
1325my $parameter_name = $parameter;
1326$parameter_name =~ s/\[.*//;
1327
Randy Dunlap3c308792007-05-08 07:24:391328($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:361329$type = $args{'parametertypes'}{$parameter};
1330if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1331 # pointer-to-function
1332 print "\t$1 $parameter) ($2);\n";
1333} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
Randy Dunlap51f5a0c2007-07-19 08:48:241334 # bitfield
Linus Torvalds1da177e2005-04-16 22:20:361335 print "\t$1 $parameter$2;\n";
1336} else {
1337 print "\t".$type." ".$parameter.";\n";
1338}
1339 }
1340 print "};\n\n";
1341
1342 print "Members:\n\n";
1343 foreach $parameter (@{$args{'parameterlist'}}) {
1344($parameter =~ /^#/) && next;
1345
1346my $parameter_name = $parameter;
1347$parameter_name =~ s/\[.*//;
1348
Randy Dunlap3c308792007-05-08 07:24:391349($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
Linus Torvalds1da177e2005-04-16 22:20:361350print "$parameter\n\t";
1351print $args{'parameterdescs'}{$parameter_name}."\n";
1352 }
1353 print "\n";
1354 output_section_text(@_);
1355}
1356
Johannes Bergb112e0f2007-10-24 22:08:481357sub output_blockhead_text(%) {
Linus Torvalds1da177e2005-04-16 22:20:361358 my %args = %{$_[0]};
1359 my ($parameter, $section);
1360
1361 foreach $section (@{$args{'sectionlist'}}) {
1362print " $section:\n";
1363print " -> ";
1364output_highlight($args{'sections'}{$section});
1365 }
1366}
1367
1368##
Randy Dunlap27205742006-10-11 08:22:121369# generic output function for all types (function, struct/union, typedef, enum);
1370# calls the generated, variable output_ function name based on
1371# functype and output_mode
Linus Torvalds1da177e2005-04-16 22:20:361372sub output_declaration {
1373 no strict 'refs';
1374 my $name = shift;
1375 my $functype = shift;
1376 my $func = "output_${functype}_$output_mode";
Randy Dunlap3c3b8092006-02-01 11:06:581377 if (($function_only==0) ||
1378( $function_only == 1 && defined($function_table{$name})) ||
Linus Torvalds1da177e2005-04-16 22:20:361379( $function_only == 2 && !defined($function_table{$name})))
1380 {
Randy Dunlap3c308792007-05-08 07:24:391381&$func(@_);
Linus Torvalds1da177e2005-04-16 22:20:361382$section_counter++;
1383 }
1384}
1385
1386##
Randy Dunlap27205742006-10-11 08:22:121387# generic output function - calls the right one based on current output mode.
Johannes Bergb112e0f2007-10-24 22:08:481388sub output_blockhead {
Linus Torvalds1da177e2005-04-16 22:20:361389 no strict 'refs';
Johannes Bergb112e0f2007-10-24 22:08:481390 my $func = "output_blockhead_".$output_mode;
Linus Torvalds1da177e2005-04-16 22:20:361391 &$func(@_);
1392 $section_counter++;
1393}
1394
1395##
Randy Dunlap3c3b8092006-02-01 11:06:581396# takes a declaration (struct, union, enum, typedef) and
Linus Torvalds1da177e2005-04-16 22:20:361397# invokes the right handler. NOT called for functions.
1398sub dump_declaration($$) {
1399 no strict 'refs';
1400 my ($prototype, $file) = @_;
1401 my $func = "dump_".$decl_type;
1402 &$func(@_);
1403}
1404
1405sub dump_union($$) {
1406 dump_struct(@_);
1407}
1408
1409sub dump_struct($$) {
1410 my $x = shift;
1411 my $file = shift;
Randy Dunlapa1d94aa2008-12-19 16:49:301412 my $nested;
Linus Torvalds1da177e2005-04-16 22:20:361413
1414 if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) {
Randy Dunlap3c308792007-05-08 07:24:391415$declaration_name = $2;
1416my $members = $3;
Linus Torvalds1da177e2005-04-16 22:20:361417
1418# ignore embedded structs or unions
Randy Dunlapa1d94aa2008-12-19 16:49:301419$members =~ s/({.*})//g;
1420$nested = $1;
Linus Torvalds1da177e2005-04-16 22:20:361421
Martin Waitzaeec46b2005-11-14 00:08:131422# ignore members marked private:
1423$members =~ s/\/\*.*?private:.*?public:.*?\*\///gos;
1424$members =~ s/\/\*.*?private:.*//gos;
1425# strip comments:
1426$members =~ s/\/\*.*?\*\///gos;
Randy Dunlapa1d94aa2008-12-19 16:49:301427$nested =~ s/\/\*.*?\*\///gos;
Martin Waitzaeec46b2005-11-14 00:08:131428
Linus Torvalds1da177e2005-04-16 22:20:361429create_parameterlist($members, ';', $file);
Randy Dunlapa1d94aa2008-12-19 16:49:301430check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
Linus Torvalds1da177e2005-04-16 22:20:361431
1432output_declaration($declaration_name,
1433 'struct',
1434 {'struct' => $declaration_name,
1435 'module' => $modulename,
1436 'parameterlist' => \@parameterlist,
1437 'parameterdescs' => \%parameterdescs,
1438 'parametertypes' => \%parametertypes,
1439 'sectionlist' => \@sectionlist,
1440 'sections' => \%sections,
1441 'purpose' => $declaration_purpose,
1442 'type' => $decl_type
1443 });
1444 }
1445 else {
Randy Dunlap3c308792007-05-08 07:24:391446print STDERR "Error(${file}:$.): Cannot parse struct or union!\n";
Linus Torvalds1da177e2005-04-16 22:20:361447++$errors;
1448 }
1449}
1450
1451sub dump_enum($$) {
1452 my $x = shift;
1453 my $file = shift;
1454
Martin Waitzaeec46b2005-11-14 00:08:131455 $x =~ s@/\*.*?\*/@@gos;# strip comments.
Linus Torvalds1da177e2005-04-16 22:20:361456 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
Randy Dunlap3c308792007-05-08 07:24:391457$declaration_name = $1;
1458my $members = $2;
Linus Torvalds1da177e2005-04-16 22:20:361459
1460foreach my $arg (split ',', $members) {
1461 $arg =~ s/^\s*(\w+).*/$1/;
1462 push @parameterlist, $arg;
1463 if (!$parameterdescs{$arg}) {
Randy Dunlap3c308792007-05-08 07:24:391464$parameterdescs{$arg} = $undescribed;
1465print STDERR "Warning(${file}:$.): Enum value '$arg' ".
Linus Torvalds1da177e2005-04-16 22:20:361466 "not described in enum '$declaration_name'\n";
1467 }
1468
1469}
Randy Dunlap3c3b8092006-02-01 11:06:581470
Linus Torvalds1da177e2005-04-16 22:20:361471output_declaration($declaration_name,
1472 'enum',
1473 {'enum' => $declaration_name,
1474 'module' => $modulename,
1475 'parameterlist' => \@parameterlist,
1476 'parameterdescs' => \%parameterdescs,
1477 'sectionlist' => \@sectionlist,
1478 'sections' => \%sections,
1479 'purpose' => $declaration_purpose
1480 });
1481 }
1482 else {
Randy Dunlap3c308792007-05-08 07:24:391483print STDERR "Error(${file}:$.): Cannot parse enum!\n";
Linus Torvalds1da177e2005-04-16 22:20:361484++$errors;
1485 }
1486}
1487
1488sub dump_typedef($$) {
1489 my $x = shift;
1490 my $file = shift;
1491
Martin Waitzaeec46b2005-11-14 00:08:131492 $x =~ s@/\*.*?\*/@@gos;# strip comments.
Linus Torvalds1da177e2005-04-16 22:20:361493 while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
Randy Dunlap3c308792007-05-08 07:24:391494$x =~ s/\(*.\)\s*;$/;/;
Linus Torvalds1da177e2005-04-16 22:20:361495$x =~ s/\[*.\]\s*;$/;/;
1496 }
1497
1498 if ($x =~ /typedef.*\s+(\w+)\s*;/) {
Randy Dunlap3c308792007-05-08 07:24:391499$declaration_name = $1;
Linus Torvalds1da177e2005-04-16 22:20:361500
1501output_declaration($declaration_name,
1502 'typedef',
1503 {'typedef' => $declaration_name,
1504 'module' => $modulename,
1505 'sectionlist' => \@sectionlist,
1506 'sections' => \%sections,
1507 'purpose' => $declaration_purpose
1508 });
1509 }
1510 else {
Randy Dunlap3c308792007-05-08 07:24:391511print STDERR "Error(${file}:$.): Cannot parse typedef!\n";
Linus Torvalds1da177e2005-04-16 22:20:361512++$errors;
1513 }
1514}
1515
Randy Dunlapa1d94aa2008-12-19 16:49:301516sub save_struct_actual($) {
1517 my $actual = shift;
1518
1519 # strip all spaces from the actual param so that it looks like one string item
1520 $actual =~ s/\s*//g;
1521 $struct_actual = $struct_actual . $actual . " ";
1522}
1523
Linus Torvalds1da177e2005-04-16 22:20:361524sub create_parameterlist($$$) {
1525 my $args = shift;
1526 my $splitter = shift;
1527 my $file = shift;
1528 my $type;
1529 my $param;
1530
Martin Waitza6d3fe72006-01-10 04:53:551531 # temporarily replace commas inside function pointer definition
Linus Torvalds1da177e2005-04-16 22:20:361532 while ($args =~ /(\([^\),]+),/) {
Randy Dunlap3c308792007-05-08 07:24:391533$args =~ s/(\([^\),]+),/$1#/g;
Linus Torvalds1da177e2005-04-16 22:20:361534 }
Randy Dunlap3c3b8092006-02-01 11:06:581535
Linus Torvalds1da177e2005-04-16 22:20:361536 foreach my $arg (split($splitter, $args)) {
1537# strip comments
1538$arg =~ s/\/\*.*\*\///;
Randy Dunlap3c308792007-05-08 07:24:391539# strip leading/trailing spaces
1540$arg =~ s/^\s*//;
Linus Torvalds1da177e2005-04-16 22:20:361541$arg =~ s/\s*$//;
1542$arg =~ s/\s+/ /;
1543
1544if ($arg =~ /^#/) {
1545 # Treat preprocessor directive as a typeless variable just to fill
1546 # corresponding data structures "correctly". Catch it later in
1547 # output_* subs.
1548 push_parameter($arg, "", $file);
Richard Kennedy00d62962008-02-23 23:24:011549} elsif ($arg =~ m/\(.+\)\s*\(/) {
Linus Torvalds1da177e2005-04-16 22:20:361550 # pointer-to-function
1551 $arg =~ tr/#/,/;
Richard Kennedy00d62962008-02-23 23:24:011552 $arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/;
Linus Torvalds1da177e2005-04-16 22:20:361553 $param = $1;
1554 $type = $arg;
Richard Kennedy00d62962008-02-23 23:24:011555 $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
Randy Dunlapa1d94aa2008-12-19 16:49:301556 save_struct_actual($param);
Linus Torvalds1da177e2005-04-16 22:20:361557 push_parameter($param, $type, $file);
Martin Waitzaeec46b2005-11-14 00:08:131558} elsif ($arg) {
Linus Torvalds1da177e2005-04-16 22:20:361559 $arg =~ s/\s*:\s*/:/g;
1560 $arg =~ s/\s*\[/\[/g;
1561
1562 my @args = split('\s*,\s*', $arg);
1563 if ($args[0] =~ m/\*/) {
1564$args[0] =~ s/(\*+)\s*/ $1/;
1565 }
Borislav Petkov884f2812007-05-08 07:29:051566
1567 my @first_arg;
1568 if ($args[0] =~ /^(.*\s+)(.*?\[.*\].*)$/) {
1569 shift @args;
1570 push(@first_arg, split('\s+', $1));
1571 push(@first_arg, $2);
1572 } else {
1573 @first_arg = split('\s+', shift @args);
1574 }
1575
Linus Torvalds1da177e2005-04-16 22:20:361576 unshift(@args, pop @first_arg);
1577 $type = join " ", @first_arg;
1578
1579 foreach $param (@args) {
1580if ($param =~ m/^(\*+)\s*(.*)/) {
Randy Dunlapa1d94aa2008-12-19 16:49:301581 save_struct_actual($2);
Linus Torvalds1da177e2005-04-16 22:20:361582 push_parameter($2, "$type $1", $file);
1583}
1584elsif ($param =~ m/(.*?):(\d+)/) {
Randy Dunlap7b978872008-05-16 22:45:521585 if ($type ne "") { # skip unnamed bit-fields
Randy Dunlapa1d94aa2008-12-19 16:49:301586save_struct_actual($1);
Randy Dunlap7b978872008-05-16 22:45:521587push_parameter($1, "$type:$2", $file)
1588 }
Linus Torvalds1da177e2005-04-16 22:20:361589}
1590else {
Randy Dunlapa1d94aa2008-12-19 16:49:301591 save_struct_actual($param);
Linus Torvalds1da177e2005-04-16 22:20:361592 push_parameter($param, $type, $file);
1593}
1594 }
1595}
1596 }
1597}
1598
1599sub push_parameter($$$) {
1600my $param = shift;
1601my $type = shift;
1602my $file = shift;
1603
Randy Dunlap5f8c7c92007-07-19 08:48:241604if (($anon_struct_union == 1) && ($type eq "") &&
1605 ($param eq "}")) {
1606return;# ignore the ending }; from anon. struct/union
1607}
1608
1609$anon_struct_union = 0;
Linus Torvalds1da177e2005-04-16 22:20:361610my $param_name = $param;
1611$param_name =~ s/\[.*//;
1612
Martin Waitza6d3fe72006-01-10 04:53:551613if ($type eq "" && $param =~ /\.\.\.$/)
Linus Torvalds1da177e2005-04-16 22:20:361614{
Randy Dunlapced69092008-12-01 21:14:031615 if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") {
1616$parameterdescs{$param} = "variable arguments";
1617 }
Linus Torvalds1da177e2005-04-16 22:20:361618}
1619elsif ($type eq "" && ($param eq "" or $param eq "void"))
1620{
Linus Torvalds1da177e2005-04-16 22:20:361621 $param="void";
1622 $parameterdescs{void} = "no arguments";
1623}
Randy Dunlap134fe012006-12-22 09:10:501624elsif ($type eq "" && ($param eq "struct" or $param eq "union"))
1625# handle unnamed (anonymous) union or struct:
1626{
1627$type = $param;
Randy Dunlap5f8c7c92007-07-19 08:48:241628$param = "{unnamed_" . $param . "}";
Randy Dunlap134fe012006-12-22 09:10:501629$parameterdescs{$param} = "anonymous\n";
Randy Dunlap5f8c7c92007-07-19 08:48:241630$anon_struct_union = 1;
Randy Dunlap134fe012006-12-22 09:10:501631}
1632
Martin Waitza6d3fe72006-01-10 04:53:551633# warn if parameter has no description
Randy Dunlap134fe012006-12-22 09:10:501634# (but ignore ones starting with # as these are not parameters
1635# but inline preprocessor statements);
1636# also ignore unnamed structs/unions;
Randy Dunlap5f8c7c92007-07-19 08:48:241637if (!$anon_struct_union) {
Martin Waitza6d3fe72006-01-10 04:53:551638if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) {
1639
Linus Torvalds1da177e2005-04-16 22:20:361640 $parameterdescs{$param_name} = $undescribed;
1641
1642 if (($type eq 'function') || ($type eq 'enum')) {
Randy Dunlap3c308792007-05-08 07:24:391643print STDERR "Warning(${file}:$.): Function parameter ".
Linus Torvalds1da177e2005-04-16 22:20:361644 "or member '$param' not " .
1645 "described in '$declaration_name'\n";
1646 }
1647 print STDERR "Warning(${file}:$.):".
Randy Dunlap3c308792007-05-08 07:24:391648 " No description found for parameter '$param'\n";
Linus Torvalds1da177e2005-04-16 22:20:361649 ++$warnings;
Randy Dunlap3c308792007-05-08 07:24:391650}
1651}
Linus Torvalds1da177e2005-04-16 22:20:361652
1653push @parameterlist, $param;
1654$parametertypes{$param} = $type;
1655}
1656
Randy Dunlapa1d94aa2008-12-19 16:49:301657sub check_sections($$$$$$) {
1658my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck, $nested) = @_;
1659my @sects = split ' ', $sectcheck;
1660my @prms = split ' ', $prmscheck;
1661my $err;
1662my ($px, $sx);
1663my $prm_clean;# strip trailing "[array size]" and/or beginning "*"
1664
1665foreach $sx (0 .. $#sects) {
1666$err = 1;
1667foreach $px (0 .. $#prms) {
1668$prm_clean = $prms[$px];
1669$prm_clean =~ s/\[.*\]//;
1670$prm_clean =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//;
1671##$prm_clean =~ s/^\**//;
1672if ($prm_clean eq $sects[$sx]) {
1673$err = 0;
1674last;
1675}
1676}
1677if ($err) {
1678if ($decl_type eq "function") {
1679print STDERR "Warning(${file}:$.): " .
1680"Excess function parameter " .
1681"'$sects[$sx]' " .
1682"description in '$decl_name'\n";
1683++$warnings;
1684} else {
1685if ($nested !~ m/\Q$sects[$sx]\E/) {
1686 print STDERR "Warning(${file}:$.): " .
1687"Excess struct/union/enum/typedef member " .
1688"'$sects[$sx]' " .
1689"description in '$decl_name'\n";
1690 ++$warnings;
1691}
1692}
1693}
1694}
1695}
1696
Linus Torvalds1da177e2005-04-16 22:20:361697##
1698# takes a function prototype and the name of the current file being
1699# processed and spits out all the details stored in the global
1700# arrays/hashes.
1701sub dump_function($$) {
1702 my $prototype = shift;
1703 my $file = shift;
1704
1705 $prototype =~ s/^static +//;
1706 $prototype =~ s/^extern +//;
Pavel Pisa4dc3b162005-05-01 15:59:251707 $prototype =~ s/^asmlinkage +//;
Linus Torvalds1da177e2005-04-16 22:20:361708 $prototype =~ s/^inline +//;
1709 $prototype =~ s/^__inline__ +//;
Randy Dunlap32e79402006-10-11 08:22:101710 $prototype =~ s/^__inline +//;
1711 $prototype =~ s/^__always_inline +//;
1712 $prototype =~ s/^noinline +//;
Randy Dunlap0129a052006-07-30 10:03:411713 $prototype =~ s/__devinit +//;
Randy Dunlap74fc5c62008-06-19 23:03:291714 $prototype =~ s/__init +//;
Randy Dunlap890c78c2008-10-26 00:06:431715 $prototype =~ s/^#\s*define\s+//; #ak added
Randy Dunlap328d2442007-03-01 04:12:101716 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
Linus Torvalds1da177e2005-04-16 22:20:361717
1718 # Yes, this truly is vile. We are looking for:
1719 # 1. Return type (may be nothing if we're looking at a macro)
1720 # 2. Function name
1721 # 3. Function parameters.
1722 #
1723 # All the while we have to watch out for function pointer parameters
1724 # (which IIRC is what the two sections are for), C types (these
1725 # regexps don't even start to express all the possibilities), and
1726 # so on.
1727 #
1728 # If you mess with these regexps, it's a good idea to check that
1729 # the following functions' documentation still comes out right:
1730 # - parport_register_device (function pointer parameters)
1731 # - atomic_set (macro)
Martin Waitz9598f912006-02-01 11:06:551732 # - pci_match_device, __copy_to_user (long return type)
Linus Torvalds1da177e2005-04-16 22:20:361733
1734 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1735$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1736$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1737$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
Randy Dunlap94b3e032008-02-07 08:13:261738$prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
Linus Torvalds1da177e2005-04-16 22:20:361739$prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1740$prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1741$prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1742$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1743$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1744$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1745$prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1746$prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
Martin Waitz9598f912006-02-01 11:06:551747$prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1748$prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
Randy Dunlap412ecd772007-02-11 06:47:331749$prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1750$prototype =~ m/^(\w+\s+\w+\s*\*\s*\w+\s*\*\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
Linus Torvalds1da177e2005-04-16 22:20:361751$return_type = $1;
1752$declaration_name = $2;
1753my $args = $3;
1754
1755create_parameterlist($args, ',', $file);
1756 } else {
1757print STDERR "Error(${file}:$.): cannot understand prototype: '$prototype'\n";
1758++$errors;
1759return;
1760 }
1761
Randy Dunlapa1d94aa2008-12-19 16:49:301762my $prms = join " ", @parameterlist;
1763check_sections($file, $declaration_name, "function", $sectcheck, $prms, "");
1764
Randy Dunlap3c3b8092006-02-01 11:06:581765 output_declaration($declaration_name,
Linus Torvalds1da177e2005-04-16 22:20:361766 'function',
1767 {'function' => $declaration_name,
1768'module' => $modulename,
1769'functiontype' => $return_type,
1770'parameterlist' => \@parameterlist,
1771'parameterdescs' => \%parameterdescs,
1772'parametertypes' => \%parametertypes,
1773'sectionlist' => \@sectionlist,
1774'sections' => \%sections,
1775'purpose' => $declaration_purpose
1776 });
1777}
1778
1779sub process_file($);
1780
1781# Read the file that maps relative names to absolute names for
1782# separate source and object directories and for shadow trees.
1783if (open(SOURCE_MAP, "<.tmp_filelist.txt")) {
1784my ($relname, $absname);
1785while(<SOURCE_MAP>) {
1786chop();
1787($relname, $absname) = (split())[0..1];
1788$relname =~ s:^/+::;
1789$source_map{$relname} = $absname;
1790}
1791close(SOURCE_MAP);
1792}
1793
1794if ($filelist) {
1795open(FLIST,"<$filelist") or die "Can't open file list $filelist";
1796while(<FLIST>) {
1797chop;
1798process_file($_);
1799}
1800}
1801
1802foreach (@ARGV) {
1803 chomp;
1804 process_file($_);
1805}
1806if ($verbose && $errors) {
1807 print STDERR "$errors errors\n";
1808}
1809if ($verbose && $warnings) {
1810 print STDERR "$warnings warnings\n";
1811}
1812
1813exit($errors);
1814
1815sub reset_state {
1816 $function = "";
1817 %constants = ();
1818 %parameterdescs = ();
1819 %parametertypes = ();
1820 @parameterlist = ();
1821 %sections = ();
1822 @sectionlist = ();
Randy Dunlapa1d94aa2008-12-19 16:49:301823 $sectcheck = "";
1824 $struct_actual = "";
Linus Torvalds1da177e2005-04-16 22:20:361825 $prototype = "";
Randy Dunlap3c3b8092006-02-01 11:06:581826
Linus Torvalds1da177e2005-04-16 22:20:361827 $state = 0;
1828}
1829
Randy Dunlap3c3b8092006-02-01 11:06:581830sub process_state3_function($$) {
Linus Torvalds1da177e2005-04-16 22:20:361831 my $x = shift;
1832 my $file = shift;
1833
Randy Dunlap51f5a0c2007-07-19 08:48:241834 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1835
Randy Dunlap890c78c2008-10-26 00:06:431836 if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#\s*define/)) {
Linus Torvalds1da177e2005-04-16 22:20:361837# do nothing
1838 }
1839 elsif ($x =~ /([^\{]*)/) {
Randy Dunlap3c308792007-05-08 07:24:391840$prototype .= $1;
Linus Torvalds1da177e2005-04-16 22:20:361841 }
Randy Dunlap890c78c2008-10-26 00:06:431842 if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) {
Randy Dunlap3c308792007-05-08 07:24:391843$prototype =~ s@/\*.*?\*/@@gos;# strip comments.
Linus Torvalds1da177e2005-04-16 22:20:361844$prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1845$prototype =~ s@^\s+@@gos; # strip leading spaces
1846dump_function($prototype,$file);
1847reset_state();
1848 }
1849}
1850
Randy Dunlap3c3b8092006-02-01 11:06:581851sub process_state3_type($$) {
Linus Torvalds1da177e2005-04-16 22:20:361852 my $x = shift;
1853 my $file = shift;
1854
Linus Torvalds1da177e2005-04-16 22:20:361855 $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1856 $x =~ s@^\s+@@gos; # strip leading spaces
1857 $x =~ s@\s+$@@gos; # strip trailing spaces
Randy Dunlap51f5a0c2007-07-19 08:48:241858 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1859
Linus Torvalds1da177e2005-04-16 22:20:361860 if ($x =~ /^#/) {
1861# To distinguish preprocessor directive from regular declaration later.
1862$x .= ";";
1863 }
1864
1865 while (1) {
Randy Dunlap3c308792007-05-08 07:24:391866if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
Linus Torvalds1da177e2005-04-16 22:20:361867 $prototype .= $1 . $2;
1868 ($2 eq '{') && $brcount++;
1869 ($2 eq '}') && $brcount--;
1870 if (($2 eq ';') && ($brcount == 0)) {
Randy Dunlap3c308792007-05-08 07:24:391871dump_declaration($prototype,$file);
Linus Torvalds1da177e2005-04-16 22:20:361872reset_state();
Randy Dunlap3c308792007-05-08 07:24:391873last;
Linus Torvalds1da177e2005-04-16 22:20:361874 }
1875 $x = $3;
Randy Dunlap3c308792007-05-08 07:24:391876} else {
Linus Torvalds1da177e2005-04-16 22:20:361877 $prototype .= $x;
1878 last;
1879}
1880 }
1881}
1882
Randy Dunlap6b5b55f2007-10-17 06:31:201883# xml_escape: replace <, >, and & in the text stream;
1884#
1885# however, formatting controls that are generated internally/locally in the
1886# kernel-doc script are not escaped here; instead, they begin life like
1887# $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings
1888# are converted to their mnemonic-expected output, without the 4 * '\' & ':',
1889# just before actual output; (this is done by local_unescape())
Linus Torvalds1da177e2005-04-16 22:20:361890sub xml_escape($) {
1891my $text = shift;
Randy Dunlapecfb2512006-06-25 12:49:131892if (($output_mode eq "text") || ($output_mode eq "man")) {
1893return $text;
1894}
Linus Torvalds1da177e2005-04-16 22:20:361895$text =~ s/\&/\\\\\\amp;/g;
1896$text =~ s/\</\\\\\\lt;/g;
1897$text =~ s/\>/\\\\\\gt;/g;
1898return $text;
1899}
1900
Randy Dunlap6b5b55f2007-10-17 06:31:201901# convert local escape strings to html
1902# local escape strings look like: '\\\\menmonic:' (that's 4 backslashes)
1903sub local_unescape($) {
1904my $text = shift;
1905if (($output_mode eq "text") || ($output_mode eq "man")) {
1906return $text;
1907}
1908$text =~ s/\\\\\\\\lt:/</g;
1909$text =~ s/\\\\\\\\gt:/>/g;
1910return $text;
1911}
1912
Linus Torvalds1da177e2005-04-16 22:20:361913sub process_file($) {
Randy Dunlap2283a112005-07-07 22:39:261914 my $file;
Linus Torvalds1da177e2005-04-16 22:20:361915 my $identifier;
1916 my $func;
Randy Dunlapa21217da2007-02-10 09:46:041917 my $descr;
Linus Torvalds1da177e2005-04-16 22:20:361918 my $initial_section_counter = $section_counter;
1919
Randy Dunlap2283a112005-07-07 22:39:261920 if (defined($ENV{'SRCTREE'})) {
1921$file = "$ENV{'SRCTREE'}" . "/" . "@_";
1922 }
1923 else {
1924$file = "@_";
1925 }
Linus Torvalds1da177e2005-04-16 22:20:361926 if (defined($source_map{$file})) {
1927$file = $source_map{$file};
1928 }
1929
1930 if (!open(IN,"<$file")) {
1931print STDERR "Error: Cannot open file $file\n";
1932++$errors;
1933return;
1934 }
1935
1936 $section_counter = 0;
1937 while (<IN>) {
1938if ($state == 0) {
1939 if (/$doc_start/o) {
1940$state = 1;# next line is always the function name
Randy Dunlap850622d2006-06-25 12:48:551941$in_doc_sect = 0;
Linus Torvalds1da177e2005-04-16 22:20:361942 }
1943} elsif ($state == 1) {# this line is the function name (always)
1944 if (/$doc_block/o) {
1945$state = 4;
1946$contents = "";
1947if ( $1 eq "" ) {
1948$section = $section_intro;
1949} else {
1950$section = $1;
1951}
Randy Dunlap3c308792007-05-08 07:24:391952 }
Linus Torvalds1da177e2005-04-16 22:20:361953 elsif (/$doc_decl/o) {
1954$identifier = $1;
1955if (/\s*([\w\s]+?)\s*-/) {
1956 $identifier = $1;
1957}
1958
1959$state = 2;
1960if (/-(.*)/) {
Randy Dunlap51f5a0c2007-07-19 08:48:241961 # strip leading/trailing/multiple spaces
Randy Dunlapa21217da2007-02-10 09:46:041962 $descr= $1;
1963 $descr =~ s/^\s*//;
1964 $descr =~ s/\s*$//;
1965 $descr =~ s/\s+/ /;
1966 $declaration_purpose = xml_escape($descr);
Linus Torvalds1da177e2005-04-16 22:20:361967} else {
1968 $declaration_purpose = "";
1969}
Randy Dunlap77cc23b2008-02-07 08:13:421970
1971if (($declaration_purpose eq "") && $verbose) {
1972print STDERR "Warning(${file}:$.): missing initial short description on line:\n";
1973print STDERR $_;
1974++$warnings;
1975}
1976
Linus Torvalds1da177e2005-04-16 22:20:361977if ($identifier =~ m/^struct/) {
1978 $decl_type = 'struct';
1979} elsif ($identifier =~ m/^union/) {
1980 $decl_type = 'union';
1981} elsif ($identifier =~ m/^enum/) {
1982 $decl_type = 'enum';
1983} elsif ($identifier =~ m/^typedef/) {
1984 $decl_type = 'typedef';
1985} else {
1986 $decl_type = 'function';
1987}
1988
1989if ($verbose) {
1990 print STDERR "Info(${file}:$.): Scanning doc for $identifier\n";
1991}
1992 } else {
1993print STDERR "Warning(${file}:$.): Cannot understand $_ on line $.",
1994" - I thought it was a doc line\n";
1995++$warnings;
1996$state = 0;
1997 }
1998} elsif ($state == 2) {# look for head: lines, and include content
1999 if (/$doc_sect/o) {
2000$newsection = $1;
2001$newcontents = $2;
2002
Randy Dunlap792aa2f2008-02-07 08:13:412003if (($contents ne "") && ($contents ne "\n")) {
Randy Dunlap850622d2006-06-25 12:48:552004 if (!$in_doc_sect && $verbose) {
2005print STDERR "Warning(${file}:$.): contents before sections\n";
2006++$warnings;
2007 }
Randy Dunlap94dc7ad2008-04-28 09:16:342008 dump_section($file, $section, xml_escape($contents));
Linus Torvalds1da177e2005-04-16 22:20:362009 $section = $section_default;
2010}
2011
Randy Dunlap850622d2006-06-25 12:48:552012$in_doc_sect = 1;
Linus Torvalds1da177e2005-04-16 22:20:362013$contents = $newcontents;
2014if ($contents ne "") {
Randy Dunlap27205742006-10-11 08:22:122015 while ((substr($contents, 0, 1) eq " ") ||
2016substr($contents, 0, 1) eq "\t") {
2017 $contents = substr($contents, 1);
Randy Dunlap05189492006-06-25 12:47:472018 }
Linus Torvalds1da177e2005-04-16 22:20:362019 $contents .= "\n";
2020}
2021$section = $newsection;
2022 } elsif (/$doc_end/) {
2023
2024if ($contents ne "") {
Randy Dunlap94dc7ad2008-04-28 09:16:342025 dump_section($file, $section, xml_escape($contents));
Linus Torvalds1da177e2005-04-16 22:20:362026 $section = $section_default;
2027 $contents = "";
2028}
Randy Dunlap46b958e2008-04-28 09:16:352029# look for doc_com + <text> + doc_end:
2030if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') {
2031 print STDERR "Warning(${file}:$.): suspicious ending line: $_";
2032 ++$warnings;
2033}
Linus Torvalds1da177e2005-04-16 22:20:362034
2035$prototype = "";
2036$state = 3;
2037$brcount = 0;
Randy Dunlap232acbc2006-06-25 12:47:482038# print STDERR "end of doc comment, looking for prototype\n";
Linus Torvalds1da177e2005-04-16 22:20:362039 } elsif (/$doc_content/) {
2040# miguel-style comment kludge, look for blank lines after
2041# @parameter line to signify start of description
Randy Dunlap3c3b8092006-02-01 11:06:582042if ($1 eq "" &&
Linus Torvalds1da177e2005-04-16 22:20:362043($section =~ m/^@/ || $section eq $section_context)) {
Randy Dunlap94dc7ad2008-04-28 09:16:342044 dump_section($file, $section, xml_escape($contents));
Linus Torvalds1da177e2005-04-16 22:20:362045 $section = $section_default;
2046 $contents = "";
2047} else {
2048 $contents .= $1."\n";
2049}
2050 } else {
2051# i dont know - bad line? ignore.
Randy Dunlap3c3b8092006-02-01 11:06:582052print STDERR "Warning(${file}:$.): bad line: $_";
Linus Torvalds1da177e2005-04-16 22:20:362053++$warnings;
2054 }
Randy Dunlap232acbc2006-06-25 12:47:482055} elsif ($state == 3) { # scanning for function '{' (end of prototype)
Linus Torvalds1da177e2005-04-16 22:20:362056 if ($decl_type eq 'function') {
Randy Dunlap3c308792007-05-08 07:24:392057process_state3_function($_, $file);
Linus Torvalds1da177e2005-04-16 22:20:362058 } else {
Randy Dunlap3c308792007-05-08 07:24:392059process_state3_type($_, $file);
Linus Torvalds1da177e2005-04-16 22:20:362060 }
2061} elsif ($state == 4) {
2062# Documentation block
Randy Dunlap3c308792007-05-08 07:24:392063if (/$doc_block/) {
Randy Dunlap94dc7ad2008-04-28 09:16:342064dump_doc_section($file, $section, xml_escape($contents));
Linus Torvalds1da177e2005-04-16 22:20:362065$contents = "";
2066$function = "";
2067%constants = ();
2068%parameterdescs = ();
2069%parametertypes = ();
2070@parameterlist = ();
2071%sections = ();
2072@sectionlist = ();
2073$prototype = "";
2074if ( $1 eq "" ) {
2075$section = $section_intro;
2076} else {
2077$section = $1;
2078}
Randy Dunlap3c308792007-05-08 07:24:392079}
Linus Torvalds1da177e2005-04-16 22:20:362080elsif (/$doc_end/)
2081{
Randy Dunlap94dc7ad2008-04-28 09:16:342082dump_doc_section($file, $section, xml_escape($contents));
Linus Torvalds1da177e2005-04-16 22:20:362083$contents = "";
2084$function = "";
2085%constants = ();
2086%parameterdescs = ();
2087%parametertypes = ();
2088@parameterlist = ();
2089%sections = ();
2090@sectionlist = ();
2091$prototype = "";
2092$state = 0;
2093}
2094elsif (/$doc_content/)
2095{
2096if ( $1 eq "" )
2097{
2098$contents .= $blankline;
2099}
2100else
2101{
2102$contents .= $1 . "\n";
Randy Dunlap3c3b8092006-02-01 11:06:582103}
Randy Dunlap3c308792007-05-08 07:24:392104}
2105}
Linus Torvalds1da177e2005-04-16 22:20:362106 }
2107 if ($initial_section_counter == $section_counter) {
2108print STDERR "Warning(${file}): no structured comments found\n";
2109if ($output_mode eq "xml") {
2110 # The template wants at least one RefEntry here; make one.
2111 print "<refentry>\n";
2112 print " <refnamediv>\n";
2113 print " <refname>\n";
2114 print " ${file}\n";
2115 print " </refname>\n";
2116 print " <refpurpose>\n";
2117 print " Document generation inconsistency\n";
2118 print " </refpurpose>\n";
2119 print " </refnamediv>\n";
2120 print " <refsect1>\n";
2121 print " <title>\n";
2122 print " Oops\n";
2123 print " </title>\n";
2124 print " <warning>\n";
2125 print " <para>\n";
2126 print " The template for this document tried to insert\n";
2127 print " the structured comment from the file\n";
2128 print " <filename>${file}</filename> at this point,\n";
2129 print " but none was found.\n";
2130 print " This dummy section is inserted to allow\n";
2131 print " generation to continue.\n";
2132 print " </para>\n";
2133 print " </warning>\n";
2134 print " </refsect1>\n";
2135 print "</refentry>\n";
2136}
2137 }
2138}