Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | |
| 3 | use 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 ## |
| 8 | ## ## |
| 9 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## |
| 10 | ## Copyright (c) 2000 MontaVista Software, Inc. ## |
| 11 | ## ## |
| 12 | ## This software falls under the GNU General Public License. ## |
| 13 | ## Please read the COPYING file for more information ## |
| 14 | |
| 15 | # w.o. 03-11-2000: added the '-filelist' option. |
| 16 | |
| 17 | # 18/01/2001 - Cleanups |
| 18 | # Functions prototyped as foo(void) same as foo() |
| 19 | # Stop eval'ing where we don't need to. |
| 20 | # -- huggie@earth.li |
| 21 | |
| 22 | # 27/06/2001 - Allowed whitespace after initial "/**" and |
| 23 | # allowed comments before function declarations. |
| 24 | # -- Christian Kreibich <ck@whoop.org> |
| 25 | |
| 26 | # Still to do: |
| 27 | # - add perldoc documentation |
| 28 | # - Look more closely at some of the scarier bits :) |
| 29 | |
| 30 | # 26/05/2001 - Support for separate source and object trees. |
| 31 | # Return error code. |
| 32 | # Keith Owens <kaos@ocs.com.au> |
| 33 | |
| 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> |
| 38 | |
| 39 | |
| 40 | # |
| 41 | # This will read a 'c' file and scan for embedded comments in the |
| 42 | # style of gnome comments (+minor extensions - see below). |
| 43 | # |
| 44 | |
| 45 | # Note: This only supports 'c'. |
| 46 | |
| 47 | # usage: |
Randy Dunlap | d28bee0 | 2006-02-01 03:06:57 -0800 | [diff] [blame] | 48 | # kernel-doc [ -docbook | -html | -text | -man ] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | # [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile |
| 50 | # or |
| 51 | # [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile |
| 52 | # |
| 53 | # Set output format using one of -docbook -html -text or -man. Default is man. |
| 54 | # |
| 55 | # -function funcname |
| 56 | # If set, then only generate documentation for the given function(s). All |
| 57 | # other functions are ignored. |
| 58 | # |
| 59 | # -nofunction funcname |
Rolf Eike Beer | a073a8b | 2006-10-03 23:13:02 +0200 | [diff] [blame] | 60 | # If set, then only generate documentation for the other function(s). |
| 61 | # Cannot be used together with -function |
Randy Dunlap | d28bee0 | 2006-02-01 03:06:57 -0800 | [diff] [blame] | 62 | # (yes, that's a bug -- perl hackers can fix it 8)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | # |
| 64 | # c files - list of 'c' files to process |
| 65 | # |
| 66 | # All output goes to stdout, with errors to stderr. |
| 67 | |
| 68 | # |
| 69 | # format of comments. |
| 70 | # In the following table, (...)? signifies optional structure. |
| 71 | # (...)* signifies 0 or more structure elements |
| 72 | # /** |
| 73 | # * function_name(:)? (- short description)? |
| 74 | # (* @parameterx: (description of parameter x)?)* |
| 75 | # (* a blank line)? |
| 76 | # * (Description:)? (Description of function)? |
| 77 | # * (section header: (section description)? )* |
| 78 | # (*)?*/ |
| 79 | # |
| 80 | # So .. the trivial example would be: |
| 81 | # |
| 82 | # /** |
| 83 | # * my_function |
| 84 | # **/ |
| 85 | # |
Randy Dunlap | 891dcd2 | 2007-02-10 01:45:53 -0800 | [diff] [blame] | 86 | # If the Description: header tag is omitted, then there must be a blank line |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | # after the last parameter specification. |
| 88 | # e.g. |
| 89 | # /** |
| 90 | # * my_function - does my stuff |
| 91 | # * @my_arg: its mine damnit |
| 92 | # * |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 93 | # * Does my stuff explained. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | # */ |
| 95 | # |
| 96 | # or, could also use: |
| 97 | # /** |
| 98 | # * my_function - does my stuff |
| 99 | # * @my_arg: its mine damnit |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 100 | # * Description: Does my stuff explained. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | # */ |
| 102 | # etc. |
| 103 | # |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 104 | # Beside functions you can also write documentation for structs, unions, |
| 105 | # enums and typedefs. Instead of the function name you must write the name |
| 106 | # of the declaration; the struct/union/enum/typedef must always precede |
| 107 | # the name. Nesting of declarations is not supported. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | # Use the argument mechanism to document members or constants. |
| 109 | # e.g. |
| 110 | # /** |
| 111 | # * struct my_struct - short description |
| 112 | # * @a: first member |
| 113 | # * @b: second member |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 114 | # * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | # * Longer description |
| 116 | # */ |
| 117 | # struct my_struct { |
| 118 | # int a; |
| 119 | # int b; |
Martin Waitz | aeec46b | 2005-11-13 16:08:13 -0800 | [diff] [blame] | 120 | # /* private: */ |
| 121 | # int c; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | # }; |
| 123 | # |
| 124 | # All descriptions can be multiline, except the short function description. |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 125 | # |
| 126 | # You can also add additional sections. When documenting kernel functions you |
| 127 | # should document the "Context:" of the function, e.g. whether the functions |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | # can be called form interrupts. Unlike other sections you can end it with an |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 129 | # empty line. |
| 130 | # Example-sections should contain the string EXAMPLE so that they are marked |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | # appropriately in DocBook. |
| 132 | # |
| 133 | # Example: |
| 134 | # /** |
| 135 | # * user_function - function that can only be called in user context |
| 136 | # * @a: some argument |
| 137 | # * Context: !in_interrupt() |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 138 | # * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | # * Some description |
| 140 | # * Example: |
| 141 | # * user_function(22); |
| 142 | # */ |
| 143 | # ... |
| 144 | # |
| 145 | # |
| 146 | # All descriptive text is further processed, scanning for the following special |
| 147 | # patterns, which are highlighted appropriately. |
| 148 | # |
| 149 | # 'funcname()' - function |
| 150 | # '$ENVVAR' - environmental variable |
| 151 | # '&struct_name' - name of a structure (up to two words including 'struct') |
| 152 | # '@parameter' - name of a parameter |
| 153 | # '%CONST' - name of a constant. |
| 154 | |
| 155 | my $errors = 0; |
| 156 | my $warnings = 0; |
Randy Dunlap | 5f8c7c9 | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 157 | my $anon_struct_union = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | # match expressions used to find embedded type information |
| 160 | my $type_constant = '\%([-_\w]+)'; |
| 161 | my $type_func = '(\w+)\(\)'; |
| 162 | my $type_param = '\@(\w+)'; |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 163 | my $type_struct = '\&((struct\s*)*[_\w]+)'; |
| 164 | my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)'; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | my $type_env = '(\$\w+)'; |
| 166 | |
| 167 | # Output conversion substitutions. |
| 168 | # One for each output format |
| 169 | |
| 170 | # these work fairly well |
| 171 | my %highlights_html = ( $type_constant, "<i>\$1</i>", |
| 172 | $type_func, "<b>\$1</b>", |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 173 | $type_struct_xml, "<i>\$1</i>", |
| 174 | $type_env, "<b><i>\$1</i></b>", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | $type_param, "<tt><b>\$1</b></tt>" ); |
| 176 | my $blankline_html = "<p>"; |
| 177 | |
| 178 | # XML, docbook format |
| 179 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", |
| 180 | $type_constant, "<constant>\$1</constant>", |
| 181 | $type_func, "<function>\$1</function>", |
| 182 | $type_struct, "<structname>\$1</structname>", |
| 183 | $type_env, "<envar>\$1</envar>", |
| 184 | $type_param, "<parameter>\$1</parameter>" ); |
| 185 | my $blankline_xml = "</para><para>\n"; |
| 186 | |
| 187 | # gnome, docbook format |
| 188 | my %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>", |
| 189 | $type_func, "<function>\$1</function>", |
| 190 | $type_struct, "<structname>\$1</structname>", |
| 191 | $type_env, "<envar>\$1</envar>", |
| 192 | $type_param, "<parameter>\$1</parameter>" ); |
| 193 | my $blankline_gnome = "</para><para>\n"; |
| 194 | |
| 195 | # these are pretty rough |
| 196 | my %highlights_man = ( $type_constant, "\$1", |
| 197 | $type_func, "\\\\fB\$1\\\\fP", |
| 198 | $type_struct, "\\\\fI\$1\\\\fP", |
| 199 | $type_param, "\\\\fI\$1\\\\fP" ); |
| 200 | my $blankline_man = ""; |
| 201 | |
| 202 | # text-mode |
| 203 | my %highlights_text = ( $type_constant, "\$1", |
| 204 | $type_func, "\$1", |
| 205 | $type_struct, "\$1", |
| 206 | $type_param, "\$1" ); |
| 207 | my $blankline_text = ""; |
| 208 | |
| 209 | |
| 210 | sub usage { |
| 211 | print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ]\n"; |
| 212 | print " [ -function funcname [ -function funcname ...] ]\n"; |
| 213 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; |
| 214 | print " c source file(s) > outputfile\n"; |
| 215 | exit 1; |
| 216 | } |
| 217 | |
| 218 | # read arguments |
| 219 | if ($#ARGV==-1) { |
| 220 | usage(); |
| 221 | } |
| 222 | |
| 223 | my $verbose = 0; |
| 224 | my $output_mode = "man"; |
| 225 | my %highlights = %highlights_man; |
| 226 | my $blankline = $blankline_man; |
| 227 | my $modulename = "Kernel API"; |
| 228 | my $function_only = 0; |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 229 | my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', |
| 230 | 'July', 'August', 'September', 'October', |
| 231 | 'November', 'December')[(localtime)[4]] . |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | " " . ((localtime)[5]+1900); |
| 233 | |
| 234 | # Essentially these are globals |
| 235 | # They probably want to be tidied up made more localised or summat. |
| 236 | # CAVEAT EMPTOR! Some of the others I localised may not want to be which |
| 237 | # could cause "use of undefined value" or other bugs. |
| 238 | my ($function, %function_table,%parametertypes,$declaration_purpose); |
| 239 | my ($type,$declaration_name,$return_type); |
| 240 | my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map); |
| 241 | |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 242 | # Generated docbook code is inserted in a template at a point where |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | # docbook v3.1 requires a non-zero sequence of RefEntry's; see: |
| 244 | # http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html |
| 245 | # We keep track of number of generated entries and generate a dummy |
| 246 | # if needs be to ensure the expanded template can be postprocessed |
| 247 | # into html. |
| 248 | my $section_counter = 0; |
| 249 | |
| 250 | my $lineprefix=""; |
| 251 | |
| 252 | # states |
| 253 | # 0 - normal code |
| 254 | # 1 - looking for function name |
| 255 | # 2 - scanning field start. |
| 256 | # 3 - scanning prototype. |
| 257 | # 4 - documentation block |
| 258 | my $state; |
Randy Dunlap | 850622d | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 259 | my $in_doc_sect; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
| 261 | #declaration types: can be |
| 262 | # 'function', 'struct', 'union', 'enum', 'typedef' |
| 263 | my $decl_type; |
| 264 | |
| 265 | my $doc_special = "\@\%\$\&"; |
| 266 | |
| 267 | my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start. |
| 268 | my $doc_end = '\*/'; |
| 269 | my $doc_com = '\s*\*\s*'; |
| 270 | my $doc_decl = $doc_com.'(\w+)'; |
Randy Dunlap | 891dcd2 | 2007-02-10 01:45:53 -0800 | [diff] [blame] | 271 | my $doc_sect = $doc_com.'(['.$doc_special.']?[\w\s]+):(.*)'; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | my $doc_content = $doc_com.'(.*)'; |
| 273 | my $doc_block = $doc_com.'DOC:\s*(.*)?'; |
| 274 | |
| 275 | my %constants; |
| 276 | my %parameterdescs; |
| 277 | my @parameterlist; |
| 278 | my %sections; |
| 279 | my @sectionlist; |
| 280 | |
| 281 | my $contents = ""; |
| 282 | my $section_default = "Description"; # default section |
| 283 | my $section_intro = "Introduction"; |
| 284 | my $section = $section_default; |
| 285 | my $section_context = "Context"; |
| 286 | |
| 287 | my $undescribed = "-- undescribed --"; |
| 288 | |
| 289 | reset_state(); |
| 290 | |
| 291 | while ($ARGV[0] =~ m/^-(.*)/) { |
| 292 | my $cmd = shift @ARGV; |
| 293 | if ($cmd eq "-html") { |
| 294 | $output_mode = "html"; |
| 295 | %highlights = %highlights_html; |
| 296 | $blankline = $blankline_html; |
| 297 | } elsif ($cmd eq "-man") { |
| 298 | $output_mode = "man"; |
| 299 | %highlights = %highlights_man; |
| 300 | $blankline = $blankline_man; |
| 301 | } elsif ($cmd eq "-text") { |
| 302 | $output_mode = "text"; |
| 303 | %highlights = %highlights_text; |
| 304 | $blankline = $blankline_text; |
| 305 | } elsif ($cmd eq "-docbook") { |
| 306 | $output_mode = "xml"; |
| 307 | %highlights = %highlights_xml; |
| 308 | $blankline = $blankline_xml; |
| 309 | } elsif ($cmd eq "-gnome") { |
| 310 | $output_mode = "gnome"; |
| 311 | %highlights = %highlights_gnome; |
| 312 | $blankline = $blankline_gnome; |
| 313 | } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document |
| 314 | $modulename = shift @ARGV; |
| 315 | } elsif ($cmd eq "-function") { # to only output specific functions |
| 316 | $function_only = 1; |
| 317 | $function = shift @ARGV; |
| 318 | $function_table{$function} = 1; |
| 319 | } elsif ($cmd eq "-nofunction") { # to only output specific functions |
| 320 | $function_only = 2; |
| 321 | $function = shift @ARGV; |
| 322 | $function_table{$function} = 1; |
| 323 | } elsif ($cmd eq "-v") { |
| 324 | $verbose = 1; |
| 325 | } elsif (($cmd eq "-h") || ($cmd eq "--help")) { |
| 326 | usage(); |
| 327 | } elsif ($cmd eq '-filelist') { |
| 328 | $filelist = shift @ARGV; |
| 329 | } |
| 330 | } |
| 331 | |
Borislav Petkov | 53f049f | 2007-05-08 00:30:54 -0700 | [diff] [blame] | 332 | # get kernel version from env |
| 333 | sub get_kernel_version() { |
| 334 | my $version; |
| 335 | |
| 336 | if (defined($ENV{'KERNELVERSION'})) { |
| 337 | $version = $ENV{'KERNELVERSION'}; |
| 338 | } |
| 339 | return $version; |
| 340 | } |
Borislav Petkov | 0366299 | 2007-05-09 02:33:43 -0700 | [diff] [blame] | 341 | my $kernelversion = get_kernel_version(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
| 343 | # generate a sequence of code that will splice in highlighting information |
| 344 | # using the s// operator. |
| 345 | my $dohighlight = ""; |
| 346 | foreach my $pattern (keys %highlights) { |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 347 | # print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n"; |
| 349 | } |
| 350 | |
| 351 | ## |
| 352 | # dumps section contents to arrays/hashes intended for that purpose. |
| 353 | # |
| 354 | sub dump_section { |
| 355 | my $name = shift; |
| 356 | my $contents = join "\n", @_; |
| 357 | |
| 358 | if ($name =~ m/$type_constant/) { |
| 359 | $name = $1; |
| 360 | # print STDERR "constant section '$1' = '$contents'\n"; |
| 361 | $constants{$name} = $contents; |
| 362 | } elsif ($name =~ m/$type_param/) { |
| 363 | # print STDERR "parameter def '$1' = '$contents'\n"; |
| 364 | $name = $1; |
| 365 | $parameterdescs{$name} = $contents; |
| 366 | } else { |
| 367 | # print STDERR "other section '$name' = '$contents'\n"; |
| 368 | $sections{$name} = $contents; |
| 369 | push @sectionlist, $name; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | ## |
| 374 | # output function |
| 375 | # |
| 376 | # parameterdescs, a hash. |
| 377 | # function => "function name" |
| 378 | # parameterlist => @list of parameters |
| 379 | # parameterdescs => %parameter descriptions |
| 380 | # sectionlist => @list of sections |
Randy Dunlap | a21217d | 2007-02-10 01:46:04 -0800 | [diff] [blame] | 381 | # sections => %section descriptions |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 382 | # |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
| 384 | sub output_highlight { |
| 385 | my $contents = join "\n",@_; |
| 386 | my $line; |
| 387 | |
| 388 | # DEBUG |
| 389 | # if (!defined $contents) { |
| 390 | # use Carp; |
| 391 | # confess "output_highlight got called with no args?\n"; |
| 392 | # } |
| 393 | |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 394 | # print STDERR "contents b4:$contents\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | eval $dohighlight; |
| 396 | die $@ if $@; |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 397 | if ($output_mode eq "html") { |
| 398 | $contents =~ s/\\\\//; |
| 399 | } |
| 400 | # print STDERR "contents af:$contents\n"; |
| 401 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | foreach $line (split "\n", $contents) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 403 | if ($line eq ""){ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | print $lineprefix, $blankline; |
| 405 | } else { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 406 | $line =~ s/\\\\\\/\&/g; |
Randy Dunlap | cdccb31 | 2007-07-19 01:48:25 -0700 | [diff] [blame] | 407 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { |
| 408 | print "\\&$line"; |
| 409 | } else { |
| 410 | print $lineprefix, $line; |
| 411 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | } |
| 413 | print "\n"; |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | #output sections in html |
| 418 | sub output_section_html(%) { |
| 419 | my %args = %{$_[0]}; |
| 420 | my $section; |
| 421 | |
| 422 | foreach $section (@{$args{'sectionlist'}}) { |
| 423 | print "<h3>$section</h3>\n"; |
| 424 | print "<blockquote>\n"; |
| 425 | output_highlight($args{'sections'}{$section}); |
| 426 | print "</blockquote>\n"; |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | # output enum in html |
| 431 | sub output_enum_html(%) { |
| 432 | my %args = %{$_[0]}; |
| 433 | my ($parameter); |
| 434 | my $count; |
| 435 | print "<h2>enum ".$args{'enum'}."</h2>\n"; |
| 436 | |
| 437 | print "<b>enum ".$args{'enum'}."</b> {<br>\n"; |
| 438 | $count = 0; |
| 439 | foreach $parameter (@{$args{'parameterlist'}}) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 440 | print " <b>".$parameter."</b>"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | if ($count != $#{$args{'parameterlist'}}) { |
| 442 | $count++; |
| 443 | print ",\n"; |
| 444 | } |
| 445 | print "<br>"; |
| 446 | } |
| 447 | print "};<br>\n"; |
| 448 | |
| 449 | print "<h3>Constants</h3>\n"; |
| 450 | print "<dl>\n"; |
| 451 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 452 | print "<dt><b>".$parameter."</b>\n"; |
| 453 | print "<dd>"; |
| 454 | output_highlight($args{'parameterdescs'}{$parameter}); |
| 455 | } |
| 456 | print "</dl>\n"; |
| 457 | output_section_html(@_); |
| 458 | print "<hr>\n"; |
| 459 | } |
| 460 | |
Randy Dunlap | d28bee0 | 2006-02-01 03:06:57 -0800 | [diff] [blame] | 461 | # output typedef in html |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | sub output_typedef_html(%) { |
| 463 | my %args = %{$_[0]}; |
| 464 | my ($parameter); |
| 465 | my $count; |
| 466 | print "<h2>typedef ".$args{'typedef'}."</h2>\n"; |
| 467 | |
| 468 | print "<b>typedef ".$args{'typedef'}."</b>\n"; |
| 469 | output_section_html(@_); |
| 470 | print "<hr>\n"; |
| 471 | } |
| 472 | |
| 473 | # output struct in html |
| 474 | sub output_struct_html(%) { |
| 475 | my %args = %{$_[0]}; |
| 476 | my ($parameter); |
| 477 | |
Randy Dunlap | 262d9b0 | 2007-02-20 13:58:04 -0800 | [diff] [blame] | 478 | print "<h2>".$args{'type'}." ".$args{'struct'}. " - " .$args{'purpose'}."</h2>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | print "<b>".$args{'type'}." ".$args{'struct'}."</b> {<br>\n"; |
| 480 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 481 | if ($parameter =~ /^#/) { |
| 482 | print "$parameter<br>\n"; |
| 483 | next; |
| 484 | } |
| 485 | my $parameter_name = $parameter; |
| 486 | $parameter_name =~ s/\[.*//; |
| 487 | |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 488 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | $type = $args{'parametertypes'}{$parameter}; |
| 490 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 491 | # pointer-to-function |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 492 | print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 494 | # bitfield |
| 495 | print " <i>$1</i> <b>$parameter</b>$2;<br>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | } else { |
Randy Dunlap | 3eb014a | 2007-05-08 00:29:51 -0700 | [diff] [blame] | 497 | print " <i>$type</i> <b>$parameter</b>;<br>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | print "};<br>\n"; |
| 501 | |
| 502 | print "<h3>Members</h3>\n"; |
| 503 | print "<dl>\n"; |
| 504 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 505 | ($parameter =~ /^#/) && next; |
| 506 | |
| 507 | my $parameter_name = $parameter; |
| 508 | $parameter_name =~ s/\[.*//; |
| 509 | |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 510 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | print "<dt><b>".$parameter."</b>\n"; |
| 512 | print "<dd>"; |
| 513 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 514 | } |
| 515 | print "</dl>\n"; |
| 516 | output_section_html(@_); |
| 517 | print "<hr>\n"; |
| 518 | } |
| 519 | |
| 520 | # output function in html |
| 521 | sub output_function_html(%) { |
| 522 | my %args = %{$_[0]}; |
| 523 | my ($parameter, $section); |
| 524 | my $count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | |
Randy Dunlap | 262d9b0 | 2007-02-20 13:58:04 -0800 | [diff] [blame] | 526 | print "<h2>" .$args{'function'}." - ".$args{'purpose'}."</h2>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | print "<i>".$args{'functiontype'}."</i>\n"; |
| 528 | print "<b>".$args{'function'}."</b>\n"; |
| 529 | print "("; |
| 530 | $count = 0; |
| 531 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 532 | $type = $args{'parametertypes'}{$parameter}; |
| 533 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 534 | # pointer-to-function |
| 535 | print "<i>$1</i><b>$parameter</b>) <i>($2)</i>"; |
| 536 | } else { |
| 537 | print "<i>".$type."</i> <b>".$parameter."</b>"; |
| 538 | } |
| 539 | if ($count != $#{$args{'parameterlist'}}) { |
| 540 | $count++; |
| 541 | print ",\n"; |
| 542 | } |
| 543 | } |
| 544 | print ")\n"; |
| 545 | |
| 546 | print "<h3>Arguments</h3>\n"; |
| 547 | print "<dl>\n"; |
| 548 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 549 | my $parameter_name = $parameter; |
| 550 | $parameter_name =~ s/\[.*//; |
| 551 | |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 552 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | print "<dt><b>".$parameter."</b>\n"; |
| 554 | print "<dd>"; |
| 555 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 556 | } |
| 557 | print "</dl>\n"; |
| 558 | output_section_html(@_); |
| 559 | print "<hr>\n"; |
| 560 | } |
| 561 | |
| 562 | # output intro in html |
| 563 | sub output_intro_html(%) { |
| 564 | my %args = %{$_[0]}; |
| 565 | my ($parameter, $section); |
| 566 | my $count; |
| 567 | |
| 568 | foreach $section (@{$args{'sectionlist'}}) { |
| 569 | print "<h3>$section</h3>\n"; |
| 570 | print "<ul>\n"; |
| 571 | output_highlight($args{'sections'}{$section}); |
| 572 | print "</ul>\n"; |
| 573 | } |
| 574 | print "<hr>\n"; |
| 575 | } |
| 576 | |
| 577 | sub output_section_xml(%) { |
| 578 | my %args = %{$_[0]}; |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 579 | my $section; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | # print out each section |
| 581 | $lineprefix=" "; |
| 582 | foreach $section (@{$args{'sectionlist'}}) { |
Rich Walker | c73894c | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 583 | print "<refsect1>\n"; |
| 584 | print "<title>$section</title>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | if ($section =~ m/EXAMPLE/i) { |
Rich Walker | c73894c | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 586 | print "<informalexample><programlisting>\n"; |
| 587 | } else { |
| 588 | print "<para>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | } |
| 590 | output_highlight($args{'sections'}{$section}); |
| 591 | if ($section =~ m/EXAMPLE/i) { |
Rich Walker | c73894c | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 592 | print "</programlisting></informalexample>\n"; |
| 593 | } else { |
| 594 | print "</para>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | } |
Rich Walker | c73894c | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 596 | print "</refsect1>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | } |
| 598 | } |
| 599 | |
| 600 | # output function in XML DocBook |
| 601 | sub output_function_xml(%) { |
| 602 | my %args = %{$_[0]}; |
| 603 | my ($parameter, $section); |
| 604 | my $count; |
| 605 | my $id; |
| 606 | |
| 607 | $id = "API-".$args{'function'}; |
| 608 | $id =~ s/[^A-Za-z0-9]/-/g; |
| 609 | |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 610 | print "<refentry id=\"$id\">\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 611 | print "<refentryinfo>\n"; |
| 612 | print " <title>LINUX</title>\n"; |
| 613 | print " <productname>Kernel Hackers Manual</productname>\n"; |
| 614 | print " <date>$man_date</date>\n"; |
| 615 | print "</refentryinfo>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | print "<refmeta>\n"; |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 617 | print " <refentrytitle><phrase>".$args{'function'}."</phrase></refentrytitle>\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 618 | print " <manvolnum>9</manvolnum>\n"; |
Borislav Petkov | 0366299 | 2007-05-09 02:33:43 -0700 | [diff] [blame] | 619 | print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | print "</refmeta>\n"; |
| 621 | print "<refnamediv>\n"; |
| 622 | print " <refname>".$args{'function'}."</refname>\n"; |
| 623 | print " <refpurpose>\n"; |
| 624 | print " "; |
| 625 | output_highlight ($args{'purpose'}); |
| 626 | print " </refpurpose>\n"; |
| 627 | print "</refnamediv>\n"; |
| 628 | |
| 629 | print "<refsynopsisdiv>\n"; |
| 630 | print " <title>Synopsis</title>\n"; |
| 631 | print " <funcsynopsis><funcprototype>\n"; |
| 632 | print " <funcdef>".$args{'functiontype'}." "; |
| 633 | print "<function>".$args{'function'}." </function></funcdef>\n"; |
| 634 | |
| 635 | $count = 0; |
| 636 | if ($#{$args{'parameterlist'}} >= 0) { |
| 637 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 638 | $type = $args{'parametertypes'}{$parameter}; |
| 639 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 640 | # pointer-to-function |
| 641 | print " <paramdef>$1<parameter>$parameter</parameter>)\n"; |
| 642 | print " <funcparams>$2</funcparams></paramdef>\n"; |
| 643 | } else { |
| 644 | print " <paramdef>".$type; |
| 645 | print " <parameter>$parameter</parameter></paramdef>\n"; |
| 646 | } |
| 647 | } |
| 648 | } else { |
Martin Waitz | 6013d54 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 649 | print " <void/>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | } |
| 651 | print " </funcprototype></funcsynopsis>\n"; |
| 652 | print "</refsynopsisdiv>\n"; |
| 653 | |
| 654 | # print parameters |
| 655 | print "<refsect1>\n <title>Arguments</title>\n"; |
| 656 | if ($#{$args{'parameterlist'}} >= 0) { |
| 657 | print " <variablelist>\n"; |
| 658 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 659 | my $parameter_name = $parameter; |
| 660 | $parameter_name =~ s/\[.*//; |
| 661 | |
| 662 | print " <varlistentry>\n <term><parameter>$parameter</parameter></term>\n"; |
| 663 | print " <listitem>\n <para>\n"; |
| 664 | $lineprefix=" "; |
| 665 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 666 | print " </para>\n </listitem>\n </varlistentry>\n"; |
| 667 | } |
| 668 | print " </variablelist>\n"; |
| 669 | } else { |
| 670 | print " <para>\n None\n </para>\n"; |
| 671 | } |
| 672 | print "</refsect1>\n"; |
| 673 | |
| 674 | output_section_xml(@_); |
| 675 | print "</refentry>\n\n"; |
| 676 | } |
| 677 | |
| 678 | # output struct in XML DocBook |
| 679 | sub output_struct_xml(%) { |
| 680 | my %args = %{$_[0]}; |
| 681 | my ($parameter, $section); |
| 682 | my $id; |
| 683 | |
| 684 | $id = "API-struct-".$args{'struct'}; |
| 685 | $id =~ s/[^A-Za-z0-9]/-/g; |
| 686 | |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 687 | print "<refentry id=\"$id\">\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 688 | print "<refentryinfo>\n"; |
| 689 | print " <title>LINUX</title>\n"; |
| 690 | print " <productname>Kernel Hackers Manual</productname>\n"; |
| 691 | print " <date>$man_date</date>\n"; |
| 692 | print "</refentryinfo>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | print "<refmeta>\n"; |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 694 | print " <refentrytitle><phrase>".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 695 | print " <manvolnum>9</manvolnum>\n"; |
Borislav Petkov | 0366299 | 2007-05-09 02:33:43 -0700 | [diff] [blame] | 696 | print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | print "</refmeta>\n"; |
| 698 | print "<refnamediv>\n"; |
| 699 | print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n"; |
| 700 | print " <refpurpose>\n"; |
| 701 | print " "; |
| 702 | output_highlight ($args{'purpose'}); |
| 703 | print " </refpurpose>\n"; |
| 704 | print "</refnamediv>\n"; |
| 705 | |
| 706 | print "<refsynopsisdiv>\n"; |
| 707 | print " <title>Synopsis</title>\n"; |
| 708 | print " <programlisting>\n"; |
| 709 | print $args{'type'}." ".$args{'struct'}." {\n"; |
| 710 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 711 | if ($parameter =~ /^#/) { |
| 712 | print "$parameter\n"; |
| 713 | next; |
| 714 | } |
| 715 | |
| 716 | my $parameter_name = $parameter; |
| 717 | $parameter_name =~ s/\[.*//; |
| 718 | |
| 719 | defined($args{'parameterdescs'}{$parameter_name}) || next; |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 720 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | $type = $args{'parametertypes'}{$parameter}; |
| 722 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 723 | # pointer-to-function |
| 724 | print " $1 $parameter) ($2);\n"; |
| 725 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
Randy Dunlap | 51f5a0c | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 726 | # bitfield |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | print " $1 $parameter$2;\n"; |
| 728 | } else { |
| 729 | print " ".$type." ".$parameter.";\n"; |
| 730 | } |
| 731 | } |
| 732 | print "};"; |
| 733 | print " </programlisting>\n"; |
| 734 | print "</refsynopsisdiv>\n"; |
| 735 | |
| 736 | print " <refsect1>\n"; |
| 737 | print " <title>Members</title>\n"; |
| 738 | |
| 739 | print " <variablelist>\n"; |
| 740 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 741 | ($parameter =~ /^#/) && next; |
| 742 | |
| 743 | my $parameter_name = $parameter; |
| 744 | $parameter_name =~ s/\[.*//; |
| 745 | |
| 746 | defined($args{'parameterdescs'}{$parameter_name}) || next; |
| 747 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
| 748 | print " <varlistentry>"; |
| 749 | print " <term>$parameter</term>\n"; |
| 750 | print " <listitem><para>\n"; |
| 751 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 752 | print " </para></listitem>\n"; |
| 753 | print " </varlistentry>\n"; |
| 754 | } |
| 755 | print " </variablelist>\n"; |
| 756 | print " </refsect1>\n"; |
| 757 | |
| 758 | output_section_xml(@_); |
| 759 | |
| 760 | print "</refentry>\n\n"; |
| 761 | } |
| 762 | |
| 763 | # output enum in XML DocBook |
| 764 | sub output_enum_xml(%) { |
| 765 | my %args = %{$_[0]}; |
| 766 | my ($parameter, $section); |
| 767 | my $count; |
| 768 | my $id; |
| 769 | |
| 770 | $id = "API-enum-".$args{'enum'}; |
| 771 | $id =~ s/[^A-Za-z0-9]/-/g; |
| 772 | |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 773 | print "<refentry id=\"$id\">\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 774 | print "<refentryinfo>\n"; |
| 775 | print " <title>LINUX</title>\n"; |
| 776 | print " <productname>Kernel Hackers Manual</productname>\n"; |
| 777 | print " <date>$man_date</date>\n"; |
| 778 | print "</refentryinfo>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | print "<refmeta>\n"; |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 780 | print " <refentrytitle><phrase>enum ".$args{'enum'}."</phrase></refentrytitle>\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 781 | print " <manvolnum>9</manvolnum>\n"; |
Borislav Petkov | 0366299 | 2007-05-09 02:33:43 -0700 | [diff] [blame] | 782 | print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | print "</refmeta>\n"; |
| 784 | print "<refnamediv>\n"; |
| 785 | print " <refname>enum ".$args{'enum'}."</refname>\n"; |
| 786 | print " <refpurpose>\n"; |
| 787 | print " "; |
| 788 | output_highlight ($args{'purpose'}); |
| 789 | print " </refpurpose>\n"; |
| 790 | print "</refnamediv>\n"; |
| 791 | |
| 792 | print "<refsynopsisdiv>\n"; |
| 793 | print " <title>Synopsis</title>\n"; |
| 794 | print " <programlisting>\n"; |
| 795 | print "enum ".$args{'enum'}." {\n"; |
| 796 | $count = 0; |
| 797 | foreach $parameter (@{$args{'parameterlist'}}) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 798 | print " $parameter"; |
| 799 | if ($count != $#{$args{'parameterlist'}}) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | $count++; |
| 801 | print ","; |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 802 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | print "\n"; |
| 804 | } |
| 805 | print "};"; |
| 806 | print " </programlisting>\n"; |
| 807 | print "</refsynopsisdiv>\n"; |
| 808 | |
| 809 | print "<refsect1>\n"; |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 810 | print " <title>Constants</title>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | print " <variablelist>\n"; |
| 812 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 813 | my $parameter_name = $parameter; |
| 814 | $parameter_name =~ s/\[.*//; |
| 815 | |
| 816 | print " <varlistentry>"; |
| 817 | print " <term>$parameter</term>\n"; |
| 818 | print " <listitem><para>\n"; |
| 819 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 820 | print " </para></listitem>\n"; |
| 821 | print " </varlistentry>\n"; |
| 822 | } |
| 823 | print " </variablelist>\n"; |
| 824 | print "</refsect1>\n"; |
| 825 | |
| 826 | output_section_xml(@_); |
| 827 | |
| 828 | print "</refentry>\n\n"; |
| 829 | } |
| 830 | |
| 831 | # output typedef in XML DocBook |
| 832 | sub output_typedef_xml(%) { |
| 833 | my %args = %{$_[0]}; |
| 834 | my ($parameter, $section); |
| 835 | my $id; |
| 836 | |
| 837 | $id = "API-typedef-".$args{'typedef'}; |
| 838 | $id =~ s/[^A-Za-z0-9]/-/g; |
| 839 | |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 840 | print "<refentry id=\"$id\">\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 841 | print "<refentryinfo>\n"; |
| 842 | print " <title>LINUX</title>\n"; |
| 843 | print " <productname>Kernel Hackers Manual</productname>\n"; |
| 844 | print " <date>$man_date</date>\n"; |
| 845 | print "</refentryinfo>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | print "<refmeta>\n"; |
Pavel Pisa | 5449bc9 | 2007-02-10 01:45:37 -0800 | [diff] [blame] | 847 | print " <refentrytitle><phrase>typedef ".$args{'typedef'}."</phrase></refentrytitle>\n"; |
Martin Waitz | 8b0c2d9 | 2005-05-01 08:59:27 -0700 | [diff] [blame] | 848 | print " <manvolnum>9</manvolnum>\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | print "</refmeta>\n"; |
| 850 | print "<refnamediv>\n"; |
| 851 | print " <refname>typedef ".$args{'typedef'}."</refname>\n"; |
| 852 | print " <refpurpose>\n"; |
| 853 | print " "; |
| 854 | output_highlight ($args{'purpose'}); |
| 855 | print " </refpurpose>\n"; |
| 856 | print "</refnamediv>\n"; |
| 857 | |
| 858 | print "<refsynopsisdiv>\n"; |
| 859 | print " <title>Synopsis</title>\n"; |
| 860 | print " <synopsis>typedef ".$args{'typedef'}.";</synopsis>\n"; |
| 861 | print "</refsynopsisdiv>\n"; |
| 862 | |
| 863 | output_section_xml(@_); |
| 864 | |
| 865 | print "</refentry>\n\n"; |
| 866 | } |
| 867 | |
| 868 | # output in XML DocBook |
| 869 | sub output_intro_xml(%) { |
| 870 | my %args = %{$_[0]}; |
| 871 | my ($parameter, $section); |
| 872 | my $count; |
| 873 | |
| 874 | my $id = $args{'module'}; |
| 875 | $id =~ s/[^A-Za-z0-9]/-/g; |
| 876 | |
| 877 | # print out each section |
| 878 | $lineprefix=" "; |
| 879 | foreach $section (@{$args{'sectionlist'}}) { |
| 880 | print "<refsect1>\n <title>$section</title>\n <para>\n"; |
| 881 | if ($section =~ m/EXAMPLE/i) { |
| 882 | print "<example><para>\n"; |
| 883 | } |
| 884 | output_highlight($args{'sections'}{$section}); |
| 885 | if ($section =~ m/EXAMPLE/i) { |
| 886 | print "</para></example>\n"; |
| 887 | } |
| 888 | print " </para>\n</refsect1>\n"; |
| 889 | } |
| 890 | |
| 891 | print "\n\n"; |
| 892 | } |
| 893 | |
| 894 | # output in XML DocBook |
| 895 | sub output_function_gnome { |
| 896 | my %args = %{$_[0]}; |
| 897 | my ($parameter, $section); |
| 898 | my $count; |
| 899 | my $id; |
| 900 | |
| 901 | $id = $args{'module'}."-".$args{'function'}; |
| 902 | $id =~ s/[^A-Za-z0-9]/-/g; |
| 903 | |
| 904 | print "<sect2>\n"; |
| 905 | print " <title id=\"$id\">".$args{'function'}."</title>\n"; |
| 906 | |
| 907 | print " <funcsynopsis>\n"; |
| 908 | print " <funcdef>".$args{'functiontype'}." "; |
| 909 | print "<function>".$args{'function'}." "; |
| 910 | print "</function></funcdef>\n"; |
| 911 | |
| 912 | $count = 0; |
| 913 | if ($#{$args{'parameterlist'}} >= 0) { |
| 914 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 915 | $type = $args{'parametertypes'}{$parameter}; |
| 916 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 917 | # pointer-to-function |
| 918 | print " <paramdef>$1 <parameter>$parameter</parameter>)\n"; |
| 919 | print " <funcparams>$2</funcparams></paramdef>\n"; |
| 920 | } else { |
| 921 | print " <paramdef>".$type; |
| 922 | print " <parameter>$parameter</parameter></paramdef>\n"; |
| 923 | } |
| 924 | } |
| 925 | } else { |
| 926 | print " <void>\n"; |
| 927 | } |
| 928 | print " </funcsynopsis>\n"; |
| 929 | if ($#{$args{'parameterlist'}} >= 0) { |
| 930 | print " <informaltable pgwide=\"1\" frame=\"none\" role=\"params\">\n"; |
| 931 | print "<tgroup cols=\"2\">\n"; |
| 932 | print "<colspec colwidth=\"2*\">\n"; |
| 933 | print "<colspec colwidth=\"8*\">\n"; |
| 934 | print "<tbody>\n"; |
| 935 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 936 | my $parameter_name = $parameter; |
| 937 | $parameter_name =~ s/\[.*//; |
| 938 | |
| 939 | print " <row><entry align=\"right\"><parameter>$parameter</parameter></entry>\n"; |
| 940 | print " <entry>\n"; |
| 941 | $lineprefix=" "; |
| 942 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 943 | print " </entry></row>\n"; |
| 944 | } |
| 945 | print " </tbody></tgroup></informaltable>\n"; |
| 946 | } else { |
| 947 | print " <para>\n None\n </para>\n"; |
| 948 | } |
| 949 | |
| 950 | # print out each section |
| 951 | $lineprefix=" "; |
| 952 | foreach $section (@{$args{'sectionlist'}}) { |
| 953 | print "<simplesect>\n <title>$section</title>\n"; |
| 954 | if ($section =~ m/EXAMPLE/i) { |
| 955 | print "<example><programlisting>\n"; |
| 956 | } else { |
| 957 | } |
| 958 | print "<para>\n"; |
| 959 | output_highlight($args{'sections'}{$section}); |
| 960 | print "</para>\n"; |
| 961 | if ($section =~ m/EXAMPLE/i) { |
| 962 | print "</programlisting></example>\n"; |
| 963 | } else { |
| 964 | } |
| 965 | print " </simplesect>\n"; |
| 966 | } |
| 967 | |
| 968 | print "</sect2>\n\n"; |
| 969 | } |
| 970 | |
| 971 | ## |
| 972 | # output function in man |
| 973 | sub output_function_man(%) { |
| 974 | my %args = %{$_[0]}; |
| 975 | my ($parameter, $section); |
| 976 | my $count; |
| 977 | |
| 978 | print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n"; |
| 979 | |
| 980 | print ".SH NAME\n"; |
| 981 | print $args{'function'}." \\- ".$args{'purpose'}."\n"; |
| 982 | |
| 983 | print ".SH SYNOPSIS\n"; |
Randy Dunlap | a21217d | 2007-02-10 01:46:04 -0800 | [diff] [blame] | 984 | if ($args{'functiontype'} ne "") { |
| 985 | print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n"; |
| 986 | } else { |
| 987 | print ".B \"".$args{'function'}."\n"; |
| 988 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | $count = 0; |
| 990 | my $parenth = "("; |
| 991 | my $post = ","; |
| 992 | foreach my $parameter (@{$args{'parameterlist'}}) { |
| 993 | if ($count == $#{$args{'parameterlist'}}) { |
| 994 | $post = ");"; |
| 995 | } |
| 996 | $type = $args{'parametertypes'}{$parameter}; |
| 997 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 998 | # pointer-to-function |
| 999 | print ".BI \"".$parenth.$1."\" ".$parameter." \") (".$2.")".$post."\"\n"; |
| 1000 | } else { |
| 1001 | $type =~ s/([^\*])$/$1 /; |
| 1002 | print ".BI \"".$parenth.$type."\" ".$parameter." \"".$post."\"\n"; |
| 1003 | } |
| 1004 | $count++; |
| 1005 | $parenth = ""; |
| 1006 | } |
| 1007 | |
| 1008 | print ".SH ARGUMENTS\n"; |
| 1009 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 1010 | my $parameter_name = $parameter; |
| 1011 | $parameter_name =~ s/\[.*//; |
| 1012 | |
| 1013 | print ".IP \"".$parameter."\" 12\n"; |
| 1014 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 1015 | } |
| 1016 | foreach $section (@{$args{'sectionlist'}}) { |
| 1017 | print ".SH \"", uc $section, "\"\n"; |
| 1018 | output_highlight($args{'sections'}{$section}); |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | ## |
| 1023 | # output enum in man |
| 1024 | sub output_enum_man(%) { |
| 1025 | my %args = %{$_[0]}; |
| 1026 | my ($parameter, $section); |
| 1027 | my $count; |
| 1028 | |
| 1029 | print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual\" LINUX\n"; |
| 1030 | |
| 1031 | print ".SH NAME\n"; |
| 1032 | print "enum ".$args{'enum'}." \\- ".$args{'purpose'}."\n"; |
| 1033 | |
| 1034 | print ".SH SYNOPSIS\n"; |
| 1035 | print "enum ".$args{'enum'}." {\n"; |
| 1036 | $count = 0; |
| 1037 | foreach my $parameter (@{$args{'parameterlist'}}) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1038 | print ".br\n.BI \" $parameter\"\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | if ($count == $#{$args{'parameterlist'}}) { |
| 1040 | print "\n};\n"; |
| 1041 | last; |
| 1042 | } |
| 1043 | else { |
| 1044 | print ", \n.br\n"; |
| 1045 | } |
| 1046 | $count++; |
| 1047 | } |
| 1048 | |
| 1049 | print ".SH Constants\n"; |
| 1050 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 1051 | my $parameter_name = $parameter; |
| 1052 | $parameter_name =~ s/\[.*//; |
| 1053 | |
| 1054 | print ".IP \"".$parameter."\" 12\n"; |
| 1055 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 1056 | } |
| 1057 | foreach $section (@{$args{'sectionlist'}}) { |
| 1058 | print ".SH \"$section\"\n"; |
| 1059 | output_highlight($args{'sections'}{$section}); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | ## |
| 1064 | # output struct in man |
| 1065 | sub output_struct_man(%) { |
| 1066 | my %args = %{$_[0]}; |
| 1067 | my ($parameter, $section); |
| 1068 | |
| 1069 | print ".TH \"$args{'module'}\" 9 \"".$args{'type'}." ".$args{'struct'}."\" \"$man_date\" \"API Manual\" LINUX\n"; |
| 1070 | |
| 1071 | print ".SH NAME\n"; |
| 1072 | print $args{'type'}." ".$args{'struct'}." \\- ".$args{'purpose'}."\n"; |
| 1073 | |
| 1074 | print ".SH SYNOPSIS\n"; |
| 1075 | print $args{'type'}." ".$args{'struct'}." {\n.br\n"; |
| 1076 | |
| 1077 | foreach my $parameter (@{$args{'parameterlist'}}) { |
| 1078 | if ($parameter =~ /^#/) { |
| 1079 | print ".BI \"$parameter\"\n.br\n"; |
| 1080 | next; |
| 1081 | } |
| 1082 | my $parameter_name = $parameter; |
| 1083 | $parameter_name =~ s/\[.*//; |
| 1084 | |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1085 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | $type = $args{'parametertypes'}{$parameter}; |
| 1087 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 1088 | # pointer-to-function |
| 1089 | print ".BI \" ".$1."\" ".$parameter." \") (".$2.")"."\"\n;\n"; |
| 1090 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
Randy.Dunlap | 1d7e1d4 | 2006-07-01 04:36:34 -0700 | [diff] [blame] | 1091 | # bitfield |
| 1092 | print ".BI \" ".$1."\ \" ".$parameter.$2." \""."\"\n;\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | } else { |
| 1094 | $type =~ s/([^\*])$/$1 /; |
| 1095 | print ".BI \" ".$type."\" ".$parameter." \""."\"\n;\n"; |
| 1096 | } |
| 1097 | print "\n.br\n"; |
| 1098 | } |
| 1099 | print "};\n.br\n"; |
| 1100 | |
Randy Dunlap | c51d3da | 2006-06-25 05:49:14 -0700 | [diff] [blame] | 1101 | print ".SH Members\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 1103 | ($parameter =~ /^#/) && next; |
| 1104 | |
| 1105 | my $parameter_name = $parameter; |
| 1106 | $parameter_name =~ s/\[.*//; |
| 1107 | |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1108 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | print ".IP \"".$parameter."\" 12\n"; |
| 1110 | output_highlight($args{'parameterdescs'}{$parameter_name}); |
| 1111 | } |
| 1112 | foreach $section (@{$args{'sectionlist'}}) { |
| 1113 | print ".SH \"$section\"\n"; |
| 1114 | output_highlight($args{'sections'}{$section}); |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | ## |
| 1119 | # output typedef in man |
| 1120 | sub output_typedef_man(%) { |
| 1121 | my %args = %{$_[0]}; |
| 1122 | my ($parameter, $section); |
| 1123 | |
| 1124 | print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual\" LINUX\n"; |
| 1125 | |
| 1126 | print ".SH NAME\n"; |
| 1127 | print "typedef ".$args{'typedef'}." \\- ".$args{'purpose'}."\n"; |
| 1128 | |
| 1129 | foreach $section (@{$args{'sectionlist'}}) { |
| 1130 | print ".SH \"$section\"\n"; |
| 1131 | output_highlight($args{'sections'}{$section}); |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | sub output_intro_man(%) { |
| 1136 | my %args = %{$_[0]}; |
| 1137 | my ($parameter, $section); |
| 1138 | my $count; |
| 1139 | |
| 1140 | print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual\" LINUX\n"; |
| 1141 | |
| 1142 | foreach $section (@{$args{'sectionlist'}}) { |
| 1143 | print ".SH \"$section\"\n"; |
| 1144 | output_highlight($args{'sections'}{$section}); |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | ## |
| 1149 | # output in text |
| 1150 | sub output_function_text(%) { |
| 1151 | my %args = %{$_[0]}; |
| 1152 | my ($parameter, $section); |
Randy Dunlap | a21217d | 2007-02-10 01:46:04 -0800 | [diff] [blame] | 1153 | my $start; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | |
Randy Dunlap | f47634b | 2006-07-01 04:36:36 -0700 | [diff] [blame] | 1155 | print "Name:\n\n"; |
| 1156 | print $args{'function'}." - ".$args{'purpose'}."\n"; |
| 1157 | |
| 1158 | print "\nSynopsis:\n\n"; |
Randy Dunlap | a21217d | 2007-02-10 01:46:04 -0800 | [diff] [blame] | 1159 | if ($args{'functiontype'} ne "") { |
| 1160 | $start = $args{'functiontype'}." ".$args{'function'}." ("; |
| 1161 | } else { |
| 1162 | $start = $args{'function'}." ("; |
| 1163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | print $start; |
Randy Dunlap | a21217d | 2007-02-10 01:46:04 -0800 | [diff] [blame] | 1165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | my $count = 0; |
| 1167 | foreach my $parameter (@{$args{'parameterlist'}}) { |
| 1168 | $type = $args{'parametertypes'}{$parameter}; |
| 1169 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 1170 | # pointer-to-function |
| 1171 | print $1.$parameter.") (".$2; |
| 1172 | } else { |
| 1173 | print $type." ".$parameter; |
| 1174 | } |
| 1175 | if ($count != $#{$args{'parameterlist'}}) { |
| 1176 | $count++; |
| 1177 | print ",\n"; |
| 1178 | print " " x length($start); |
| 1179 | } else { |
| 1180 | print ");\n\n"; |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | print "Arguments:\n\n"; |
| 1185 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 1186 | my $parameter_name = $parameter; |
| 1187 | $parameter_name =~ s/\[.*//; |
| 1188 | |
| 1189 | print $parameter."\n\t".$args{'parameterdescs'}{$parameter_name}."\n"; |
| 1190 | } |
| 1191 | output_section_text(@_); |
| 1192 | } |
| 1193 | |
| 1194 | #output sections in text |
| 1195 | sub output_section_text(%) { |
| 1196 | my %args = %{$_[0]}; |
| 1197 | my $section; |
| 1198 | |
| 1199 | print "\n"; |
| 1200 | foreach $section (@{$args{'sectionlist'}}) { |
| 1201 | print "$section:\n\n"; |
| 1202 | output_highlight($args{'sections'}{$section}); |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1203 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | print "\n\n"; |
| 1205 | } |
| 1206 | |
| 1207 | # output enum in text |
| 1208 | sub output_enum_text(%) { |
| 1209 | my %args = %{$_[0]}; |
| 1210 | my ($parameter); |
| 1211 | my $count; |
| 1212 | print "Enum:\n\n"; |
| 1213 | |
Randy.Dunlap | 1d7e1d4 | 2006-07-01 04:36:34 -0700 | [diff] [blame] | 1214 | print "enum ".$args{'enum'}." - ".$args{'purpose'}."\n\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | print "enum ".$args{'enum'}." {\n"; |
| 1216 | $count = 0; |
| 1217 | foreach $parameter (@{$args{'parameterlist'}}) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1218 | print "\t$parameter"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | if ($count != $#{$args{'parameterlist'}}) { |
| 1220 | $count++; |
| 1221 | print ","; |
| 1222 | } |
| 1223 | print "\n"; |
| 1224 | } |
| 1225 | print "};\n\n"; |
| 1226 | |
| 1227 | print "Constants:\n\n"; |
| 1228 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 1229 | print "$parameter\n\t"; |
| 1230 | print $args{'parameterdescs'}{$parameter}."\n"; |
| 1231 | } |
| 1232 | |
| 1233 | output_section_text(@_); |
| 1234 | } |
| 1235 | |
| 1236 | # output typedef in text |
| 1237 | sub output_typedef_text(%) { |
| 1238 | my %args = %{$_[0]}; |
| 1239 | my ($parameter); |
| 1240 | my $count; |
| 1241 | print "Typedef:\n\n"; |
| 1242 | |
Randy.Dunlap | 1d7e1d4 | 2006-07-01 04:36:34 -0700 | [diff] [blame] | 1243 | print "typedef ".$args{'typedef'}." - ".$args{'purpose'}."\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | output_section_text(@_); |
| 1245 | } |
| 1246 | |
| 1247 | # output struct as text |
| 1248 | sub output_struct_text(%) { |
| 1249 | my %args = %{$_[0]}; |
| 1250 | my ($parameter); |
| 1251 | |
Randy.Dunlap | 1d7e1d4 | 2006-07-01 04:36:34 -0700 | [diff] [blame] | 1252 | print $args{'type'}." ".$args{'struct'}." - ".$args{'purpose'}."\n\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1253 | print $args{'type'}." ".$args{'struct'}." {\n"; |
| 1254 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 1255 | if ($parameter =~ /^#/) { |
| 1256 | print "$parameter\n"; |
| 1257 | next; |
| 1258 | } |
| 1259 | |
| 1260 | my $parameter_name = $parameter; |
| 1261 | $parameter_name =~ s/\[.*//; |
| 1262 | |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1263 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | $type = $args{'parametertypes'}{$parameter}; |
| 1265 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 1266 | # pointer-to-function |
| 1267 | print "\t$1 $parameter) ($2);\n"; |
| 1268 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
Randy Dunlap | 51f5a0c | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1269 | # bitfield |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | print "\t$1 $parameter$2;\n"; |
| 1271 | } else { |
| 1272 | print "\t".$type." ".$parameter.";\n"; |
| 1273 | } |
| 1274 | } |
| 1275 | print "};\n\n"; |
| 1276 | |
| 1277 | print "Members:\n\n"; |
| 1278 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 1279 | ($parameter =~ /^#/) && next; |
| 1280 | |
| 1281 | my $parameter_name = $parameter; |
| 1282 | $parameter_name =~ s/\[.*//; |
| 1283 | |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1284 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1285 | print "$parameter\n\t"; |
| 1286 | print $args{'parameterdescs'}{$parameter_name}."\n"; |
| 1287 | } |
| 1288 | print "\n"; |
| 1289 | output_section_text(@_); |
| 1290 | } |
| 1291 | |
| 1292 | sub output_intro_text(%) { |
| 1293 | my %args = %{$_[0]}; |
| 1294 | my ($parameter, $section); |
| 1295 | |
| 1296 | foreach $section (@{$args{'sectionlist'}}) { |
| 1297 | print " $section:\n"; |
| 1298 | print " -> "; |
| 1299 | output_highlight($args{'sections'}{$section}); |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | ## |
Randy Dunlap | 2720574 | 2006-10-11 01:22:12 -0700 | [diff] [blame] | 1304 | # generic output function for all types (function, struct/union, typedef, enum); |
| 1305 | # calls the generated, variable output_ function name based on |
| 1306 | # functype and output_mode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1307 | sub output_declaration { |
| 1308 | no strict 'refs'; |
| 1309 | my $name = shift; |
| 1310 | my $functype = shift; |
| 1311 | my $func = "output_${functype}_$output_mode"; |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1312 | if (($function_only==0) || |
| 1313 | ( $function_only == 1 && defined($function_table{$name})) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | ( $function_only == 2 && !defined($function_table{$name}))) |
| 1315 | { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1316 | &$func(@_); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1317 | $section_counter++; |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | ## |
Randy Dunlap | 2720574 | 2006-10-11 01:22:12 -0700 | [diff] [blame] | 1322 | # generic output function - calls the right one based on current output mode. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1323 | sub output_intro { |
| 1324 | no strict 'refs'; |
| 1325 | my $func = "output_intro_".$output_mode; |
| 1326 | &$func(@_); |
| 1327 | $section_counter++; |
| 1328 | } |
| 1329 | |
| 1330 | ## |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1331 | # takes a declaration (struct, union, enum, typedef) and |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | # invokes the right handler. NOT called for functions. |
| 1333 | sub dump_declaration($$) { |
| 1334 | no strict 'refs'; |
| 1335 | my ($prototype, $file) = @_; |
| 1336 | my $func = "dump_".$decl_type; |
| 1337 | &$func(@_); |
| 1338 | } |
| 1339 | |
| 1340 | sub dump_union($$) { |
| 1341 | dump_struct(@_); |
| 1342 | } |
| 1343 | |
| 1344 | sub dump_struct($$) { |
| 1345 | my $x = shift; |
| 1346 | my $file = shift; |
| 1347 | |
| 1348 | if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1349 | $declaration_name = $2; |
| 1350 | my $members = $3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | |
| 1352 | # ignore embedded structs or unions |
| 1353 | $members =~ s/{.*?}//g; |
| 1354 | |
Martin Waitz | aeec46b | 2005-11-13 16:08:13 -0800 | [diff] [blame] | 1355 | # ignore members marked private: |
| 1356 | $members =~ s/\/\*.*?private:.*?public:.*?\*\///gos; |
| 1357 | $members =~ s/\/\*.*?private:.*//gos; |
| 1358 | # strip comments: |
| 1359 | $members =~ s/\/\*.*?\*\///gos; |
| 1360 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | create_parameterlist($members, ';', $file); |
| 1362 | |
| 1363 | output_declaration($declaration_name, |
| 1364 | 'struct', |
| 1365 | {'struct' => $declaration_name, |
| 1366 | 'module' => $modulename, |
| 1367 | 'parameterlist' => \@parameterlist, |
| 1368 | 'parameterdescs' => \%parameterdescs, |
| 1369 | 'parametertypes' => \%parametertypes, |
| 1370 | 'sectionlist' => \@sectionlist, |
| 1371 | 'sections' => \%sections, |
| 1372 | 'purpose' => $declaration_purpose, |
| 1373 | 'type' => $decl_type |
| 1374 | }); |
| 1375 | } |
| 1376 | else { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1377 | print STDERR "Error(${file}:$.): Cannot parse struct or union!\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1378 | ++$errors; |
| 1379 | } |
| 1380 | } |
| 1381 | |
| 1382 | sub dump_enum($$) { |
| 1383 | my $x = shift; |
| 1384 | my $file = shift; |
| 1385 | |
Martin Waitz | aeec46b | 2005-11-13 16:08:13 -0800 | [diff] [blame] | 1386 | $x =~ s@/\*.*?\*/@@gos; # strip comments. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1388 | $declaration_name = $1; |
| 1389 | my $members = $2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | |
| 1391 | foreach my $arg (split ',', $members) { |
| 1392 | $arg =~ s/^\s*(\w+).*/$1/; |
| 1393 | push @parameterlist, $arg; |
| 1394 | if (!$parameterdescs{$arg}) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1395 | $parameterdescs{$arg} = $undescribed; |
| 1396 | print STDERR "Warning(${file}:$.): Enum value '$arg' ". |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | "not described in enum '$declaration_name'\n"; |
| 1398 | } |
| 1399 | |
| 1400 | } |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1401 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | output_declaration($declaration_name, |
| 1403 | 'enum', |
| 1404 | {'enum' => $declaration_name, |
| 1405 | 'module' => $modulename, |
| 1406 | 'parameterlist' => \@parameterlist, |
| 1407 | 'parameterdescs' => \%parameterdescs, |
| 1408 | 'sectionlist' => \@sectionlist, |
| 1409 | 'sections' => \%sections, |
| 1410 | 'purpose' => $declaration_purpose |
| 1411 | }); |
| 1412 | } |
| 1413 | else { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1414 | print STDERR "Error(${file}:$.): Cannot parse enum!\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1415 | ++$errors; |
| 1416 | } |
| 1417 | } |
| 1418 | |
| 1419 | sub dump_typedef($$) { |
| 1420 | my $x = shift; |
| 1421 | my $file = shift; |
| 1422 | |
Martin Waitz | aeec46b | 2005-11-13 16:08:13 -0800 | [diff] [blame] | 1423 | $x =~ s@/\*.*?\*/@@gos; # strip comments. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 | while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1425 | $x =~ s/\(*.\)\s*;$/;/; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | $x =~ s/\[*.\]\s*;$/;/; |
| 1427 | } |
| 1428 | |
| 1429 | if ($x =~ /typedef.*\s+(\w+)\s*;/) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1430 | $declaration_name = $1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | |
| 1432 | output_declaration($declaration_name, |
| 1433 | 'typedef', |
| 1434 | {'typedef' => $declaration_name, |
| 1435 | 'module' => $modulename, |
| 1436 | 'sectionlist' => \@sectionlist, |
| 1437 | 'sections' => \%sections, |
| 1438 | 'purpose' => $declaration_purpose |
| 1439 | }); |
| 1440 | } |
| 1441 | else { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1442 | print STDERR "Error(${file}:$.): Cannot parse typedef!\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1443 | ++$errors; |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | sub create_parameterlist($$$) { |
| 1448 | my $args = shift; |
| 1449 | my $splitter = shift; |
| 1450 | my $file = shift; |
| 1451 | my $type; |
| 1452 | my $param; |
| 1453 | |
Martin Waitz | a6d3fe7 | 2006-01-09 20:53:55 -0800 | [diff] [blame] | 1454 | # temporarily replace commas inside function pointer definition |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | while ($args =~ /(\([^\),]+),/) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1456 | $args =~ s/(\([^\),]+),/$1#/g; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1457 | } |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1458 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | foreach my $arg (split($splitter, $args)) { |
| 1460 | # strip comments |
| 1461 | $arg =~ s/\/\*.*\*\///; |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1462 | # strip leading/trailing spaces |
| 1463 | $arg =~ s/^\s*//; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | $arg =~ s/\s*$//; |
| 1465 | $arg =~ s/\s+/ /; |
| 1466 | |
| 1467 | if ($arg =~ /^#/) { |
| 1468 | # Treat preprocessor directive as a typeless variable just to fill |
| 1469 | # corresponding data structures "correctly". Catch it later in |
| 1470 | # output_* subs. |
| 1471 | push_parameter($arg, "", $file); |
Randy Dunlap | ea82c74 | 2006-12-06 20:38:52 -0800 | [diff] [blame] | 1472 | } elsif ($arg =~ m/\(.*\*/) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | # pointer-to-function |
| 1474 | $arg =~ tr/#/,/; |
Randy Dunlap | 996a07b | 2007-02-10 01:45:56 -0800 | [diff] [blame] | 1475 | $arg =~ m/[^\(]+\(\*\s*([^\)]+)\)/; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | $param = $1; |
| 1477 | $type = $arg; |
| 1478 | $type =~ s/([^\(]+\(\*)$param/$1/; |
| 1479 | push_parameter($param, $type, $file); |
Martin Waitz | aeec46b | 2005-11-13 16:08:13 -0800 | [diff] [blame] | 1480 | } elsif ($arg) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1481 | $arg =~ s/\s*:\s*/:/g; |
| 1482 | $arg =~ s/\s*\[/\[/g; |
| 1483 | |
| 1484 | my @args = split('\s*,\s*', $arg); |
| 1485 | if ($args[0] =~ m/\*/) { |
| 1486 | $args[0] =~ s/(\*+)\s*/ $1/; |
| 1487 | } |
Borislav Petkov | 884f281 | 2007-05-08 00:29:05 -0700 | [diff] [blame] | 1488 | |
| 1489 | my @first_arg; |
| 1490 | if ($args[0] =~ /^(.*\s+)(.*?\[.*\].*)$/) { |
| 1491 | shift @args; |
| 1492 | push(@first_arg, split('\s+', $1)); |
| 1493 | push(@first_arg, $2); |
| 1494 | } else { |
| 1495 | @first_arg = split('\s+', shift @args); |
| 1496 | } |
| 1497 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | unshift(@args, pop @first_arg); |
| 1499 | $type = join " ", @first_arg; |
| 1500 | |
| 1501 | foreach $param (@args) { |
| 1502 | if ($param =~ m/^(\*+)\s*(.*)/) { |
| 1503 | push_parameter($2, "$type $1", $file); |
| 1504 | } |
| 1505 | elsif ($param =~ m/(.*?):(\d+)/) { |
| 1506 | push_parameter($1, "$type:$2", $file) |
| 1507 | } |
| 1508 | else { |
| 1509 | push_parameter($param, $type, $file); |
| 1510 | } |
| 1511 | } |
| 1512 | } |
| 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | sub push_parameter($$$) { |
| 1517 | my $param = shift; |
| 1518 | my $type = shift; |
| 1519 | my $file = shift; |
| 1520 | |
Randy Dunlap | 5f8c7c9 | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1521 | if (($anon_struct_union == 1) && ($type eq "") && |
| 1522 | ($param eq "}")) { |
| 1523 | return; # ignore the ending }; from anon. struct/union |
| 1524 | } |
| 1525 | |
| 1526 | $anon_struct_union = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1527 | my $param_name = $param; |
| 1528 | $param_name =~ s/\[.*//; |
| 1529 | |
Martin Waitz | a6d3fe7 | 2006-01-09 20:53:55 -0800 | [diff] [blame] | 1530 | if ($type eq "" && $param =~ /\.\.\.$/) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | { |
| 1532 | $type=""; |
Martin Waitz | a6d3fe7 | 2006-01-09 20:53:55 -0800 | [diff] [blame] | 1533 | $parameterdescs{$param} = "variable arguments"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | } |
| 1535 | elsif ($type eq "" && ($param eq "" or $param eq "void")) |
| 1536 | { |
| 1537 | $type=""; |
| 1538 | $param="void"; |
| 1539 | $parameterdescs{void} = "no arguments"; |
| 1540 | } |
Randy Dunlap | 134fe01 | 2006-12-22 01:10:50 -0800 | [diff] [blame] | 1541 | elsif ($type eq "" && ($param eq "struct" or $param eq "union")) |
| 1542 | # handle unnamed (anonymous) union or struct: |
| 1543 | { |
| 1544 | $type = $param; |
Randy Dunlap | 5f8c7c9 | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1545 | $param = "{unnamed_" . $param . "}"; |
Randy Dunlap | 134fe01 | 2006-12-22 01:10:50 -0800 | [diff] [blame] | 1546 | $parameterdescs{$param} = "anonymous\n"; |
Randy Dunlap | 5f8c7c9 | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1547 | $anon_struct_union = 1; |
Randy Dunlap | 134fe01 | 2006-12-22 01:10:50 -0800 | [diff] [blame] | 1548 | } |
| 1549 | |
Martin Waitz | a6d3fe7 | 2006-01-09 20:53:55 -0800 | [diff] [blame] | 1550 | # warn if parameter has no description |
Randy Dunlap | 134fe01 | 2006-12-22 01:10:50 -0800 | [diff] [blame] | 1551 | # (but ignore ones starting with # as these are not parameters |
| 1552 | # but inline preprocessor statements); |
| 1553 | # also ignore unnamed structs/unions; |
Randy Dunlap | 5f8c7c9 | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1554 | if (!$anon_struct_union) { |
Martin Waitz | a6d3fe7 | 2006-01-09 20:53:55 -0800 | [diff] [blame] | 1555 | if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) { |
| 1556 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1557 | $parameterdescs{$param_name} = $undescribed; |
| 1558 | |
| 1559 | if (($type eq 'function') || ($type eq 'enum')) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1560 | print STDERR "Warning(${file}:$.): Function parameter ". |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | "or member '$param' not " . |
| 1562 | "described in '$declaration_name'\n"; |
| 1563 | } |
| 1564 | print STDERR "Warning(${file}:$.):". |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1565 | " No description found for parameter '$param'\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1566 | ++$warnings; |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1567 | } |
| 1568 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | |
| 1570 | push @parameterlist, $param; |
| 1571 | $parametertypes{$param} = $type; |
| 1572 | } |
| 1573 | |
| 1574 | ## |
| 1575 | # takes a function prototype and the name of the current file being |
| 1576 | # processed and spits out all the details stored in the global |
| 1577 | # arrays/hashes. |
| 1578 | sub dump_function($$) { |
| 1579 | my $prototype = shift; |
| 1580 | my $file = shift; |
| 1581 | |
| 1582 | $prototype =~ s/^static +//; |
| 1583 | $prototype =~ s/^extern +//; |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 1584 | $prototype =~ s/^fastcall +//; |
| 1585 | $prototype =~ s/^asmlinkage +//; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1586 | $prototype =~ s/^inline +//; |
| 1587 | $prototype =~ s/^__inline__ +//; |
Randy Dunlap | 32e7940 | 2006-10-11 01:22:10 -0700 | [diff] [blame] | 1588 | $prototype =~ s/^__inline +//; |
| 1589 | $prototype =~ s/^__always_inline +//; |
| 1590 | $prototype =~ s/^noinline +//; |
Randy Dunlap | 0129a05 | 2006-07-30 03:03:41 -0700 | [diff] [blame] | 1591 | $prototype =~ s/__devinit +//; |
Randy Dunlap | 996a07b | 2007-02-10 01:45:56 -0800 | [diff] [blame] | 1592 | $prototype =~ s/^#define\s+//; #ak added |
Randy Dunlap | 328d244 | 2007-02-28 20:12:10 -0800 | [diff] [blame] | 1593 | $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1594 | |
| 1595 | # Yes, this truly is vile. We are looking for: |
| 1596 | # 1. Return type (may be nothing if we're looking at a macro) |
| 1597 | # 2. Function name |
| 1598 | # 3. Function parameters. |
| 1599 | # |
| 1600 | # All the while we have to watch out for function pointer parameters |
| 1601 | # (which IIRC is what the two sections are for), C types (these |
| 1602 | # regexps don't even start to express all the possibilities), and |
| 1603 | # so on. |
| 1604 | # |
| 1605 | # If you mess with these regexps, it's a good idea to check that |
| 1606 | # the following functions' documentation still comes out right: |
| 1607 | # - parport_register_device (function pointer parameters) |
| 1608 | # - atomic_set (macro) |
Martin Waitz | 9598f91 | 2006-02-01 03:06:55 -0800 | [diff] [blame] | 1609 | # - pci_match_device, __copy_to_user (long return type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1610 | |
| 1611 | if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 1612 | $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 1613 | $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 1614 | $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 1615 | $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 1616 | $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 1617 | $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 1618 | $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
| 1619 | $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
| 1620 | $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
| 1621 | $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
| 1622 | $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
| 1623 | $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
Martin Waitz | 9598f91 | 2006-02-01 03:06:55 -0800 | [diff] [blame] | 1624 | $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
| 1625 | $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
Randy Dunlap | 412ecd7 | 2007-02-10 22:47:33 -0800 | [diff] [blame] | 1626 | $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || |
| 1627 | $prototype =~ m/^(\w+\s+\w+\s*\*\s*\w+\s*\*\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1628 | $return_type = $1; |
| 1629 | $declaration_name = $2; |
| 1630 | my $args = $3; |
| 1631 | |
| 1632 | create_parameterlist($args, ',', $file); |
| 1633 | } else { |
| 1634 | print STDERR "Error(${file}:$.): cannot understand prototype: '$prototype'\n"; |
| 1635 | ++$errors; |
| 1636 | return; |
| 1637 | } |
| 1638 | |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1639 | output_declaration($declaration_name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | 'function', |
| 1641 | {'function' => $declaration_name, |
| 1642 | 'module' => $modulename, |
| 1643 | 'functiontype' => $return_type, |
| 1644 | 'parameterlist' => \@parameterlist, |
| 1645 | 'parameterdescs' => \%parameterdescs, |
| 1646 | 'parametertypes' => \%parametertypes, |
| 1647 | 'sectionlist' => \@sectionlist, |
| 1648 | 'sections' => \%sections, |
| 1649 | 'purpose' => $declaration_purpose |
| 1650 | }); |
| 1651 | } |
| 1652 | |
| 1653 | sub process_file($); |
| 1654 | |
| 1655 | # Read the file that maps relative names to absolute names for |
| 1656 | # separate source and object directories and for shadow trees. |
| 1657 | if (open(SOURCE_MAP, "<.tmp_filelist.txt")) { |
| 1658 | my ($relname, $absname); |
| 1659 | while(<SOURCE_MAP>) { |
| 1660 | chop(); |
| 1661 | ($relname, $absname) = (split())[0..1]; |
| 1662 | $relname =~ s:^/+::; |
| 1663 | $source_map{$relname} = $absname; |
| 1664 | } |
| 1665 | close(SOURCE_MAP); |
| 1666 | } |
| 1667 | |
| 1668 | if ($filelist) { |
| 1669 | open(FLIST,"<$filelist") or die "Can't open file list $filelist"; |
| 1670 | while(<FLIST>) { |
| 1671 | chop; |
| 1672 | process_file($_); |
| 1673 | } |
| 1674 | } |
| 1675 | |
| 1676 | foreach (@ARGV) { |
| 1677 | chomp; |
| 1678 | process_file($_); |
| 1679 | } |
| 1680 | if ($verbose && $errors) { |
| 1681 | print STDERR "$errors errors\n"; |
| 1682 | } |
| 1683 | if ($verbose && $warnings) { |
| 1684 | print STDERR "$warnings warnings\n"; |
| 1685 | } |
| 1686 | |
| 1687 | exit($errors); |
| 1688 | |
| 1689 | sub reset_state { |
| 1690 | $function = ""; |
| 1691 | %constants = (); |
| 1692 | %parameterdescs = (); |
| 1693 | %parametertypes = (); |
| 1694 | @parameterlist = (); |
| 1695 | %sections = (); |
| 1696 | @sectionlist = (); |
| 1697 | $prototype = ""; |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1698 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | $state = 0; |
| 1700 | } |
| 1701 | |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1702 | sub process_state3_function($$) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | my $x = shift; |
| 1704 | my $file = shift; |
| 1705 | |
Randy Dunlap | 51f5a0c | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1706 | $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line |
| 1707 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) { |
| 1709 | # do nothing |
| 1710 | } |
| 1711 | elsif ($x =~ /([^\{]*)/) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1712 | $prototype .= $1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | } |
| 1714 | if (($x =~ /\{/) || ($x =~ /\#define/) || ($x =~ /;/)) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1715 | $prototype =~ s@/\*.*?\*/@@gos; # strip comments. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. |
| 1717 | $prototype =~ s@^\s+@@gos; # strip leading spaces |
| 1718 | dump_function($prototype,$file); |
| 1719 | reset_state(); |
| 1720 | } |
| 1721 | } |
| 1722 | |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1723 | sub process_state3_type($$) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1724 | my $x = shift; |
| 1725 | my $file = shift; |
| 1726 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1727 | $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's. |
| 1728 | $x =~ s@^\s+@@gos; # strip leading spaces |
| 1729 | $x =~ s@\s+$@@gos; # strip trailing spaces |
Randy Dunlap | 51f5a0c | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1730 | $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line |
| 1731 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1732 | if ($x =~ /^#/) { |
| 1733 | # To distinguish preprocessor directive from regular declaration later. |
| 1734 | $x .= ";"; |
| 1735 | } |
| 1736 | |
| 1737 | while (1) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1738 | if ( $x =~ /([^{};]*)([{};])(.*)/ ) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | $prototype .= $1 . $2; |
| 1740 | ($2 eq '{') && $brcount++; |
| 1741 | ($2 eq '}') && $brcount--; |
| 1742 | if (($2 eq ';') && ($brcount == 0)) { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1743 | dump_declaration($prototype,$file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | reset_state(); |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1745 | last; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | } |
| 1747 | $x = $3; |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1748 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1749 | $prototype .= $x; |
| 1750 | last; |
| 1751 | } |
| 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | # replace <, >, and & |
| 1756 | sub xml_escape($) { |
| 1757 | my $text = shift; |
Randy Dunlap | ecfb251 | 2006-06-25 05:49:13 -0700 | [diff] [blame] | 1758 | if (($output_mode eq "text") || ($output_mode eq "man")) { |
| 1759 | return $text; |
| 1760 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | $text =~ s/\&/\\\\\\amp;/g; |
| 1762 | $text =~ s/\</\\\\\\lt;/g; |
| 1763 | $text =~ s/\>/\\\\\\gt;/g; |
| 1764 | return $text; |
| 1765 | } |
| 1766 | |
| 1767 | sub process_file($) { |
Randy Dunlap | 2283a11 | 2005-07-07 15:39:26 -0700 | [diff] [blame] | 1768 | my $file; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | my $identifier; |
| 1770 | my $func; |
Randy Dunlap | a21217d | 2007-02-10 01:46:04 -0800 | [diff] [blame] | 1771 | my $descr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1772 | my $initial_section_counter = $section_counter; |
| 1773 | |
Randy Dunlap | 2283a11 | 2005-07-07 15:39:26 -0700 | [diff] [blame] | 1774 | if (defined($ENV{'SRCTREE'})) { |
| 1775 | $file = "$ENV{'SRCTREE'}" . "/" . "@_"; |
| 1776 | } |
| 1777 | else { |
| 1778 | $file = "@_"; |
| 1779 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | if (defined($source_map{$file})) { |
| 1781 | $file = $source_map{$file}; |
| 1782 | } |
| 1783 | |
| 1784 | if (!open(IN,"<$file")) { |
| 1785 | print STDERR "Error: Cannot open file $file\n"; |
| 1786 | ++$errors; |
| 1787 | return; |
| 1788 | } |
| 1789 | |
| 1790 | $section_counter = 0; |
| 1791 | while (<IN>) { |
| 1792 | if ($state == 0) { |
| 1793 | if (/$doc_start/o) { |
| 1794 | $state = 1; # next line is always the function name |
Randy Dunlap | 850622d | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 1795 | $in_doc_sect = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1796 | } |
| 1797 | } elsif ($state == 1) { # this line is the function name (always) |
| 1798 | if (/$doc_block/o) { |
| 1799 | $state = 4; |
| 1800 | $contents = ""; |
| 1801 | if ( $1 eq "" ) { |
| 1802 | $section = $section_intro; |
| 1803 | } else { |
| 1804 | $section = $1; |
| 1805 | } |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1806 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1807 | elsif (/$doc_decl/o) { |
| 1808 | $identifier = $1; |
| 1809 | if (/\s*([\w\s]+?)\s*-/) { |
| 1810 | $identifier = $1; |
| 1811 | } |
| 1812 | |
| 1813 | $state = 2; |
| 1814 | if (/-(.*)/) { |
Randy Dunlap | 51f5a0c | 2007-07-19 01:48:24 -0700 | [diff] [blame] | 1815 | # strip leading/trailing/multiple spaces |
Randy Dunlap | a21217d | 2007-02-10 01:46:04 -0800 | [diff] [blame] | 1816 | $descr= $1; |
| 1817 | $descr =~ s/^\s*//; |
| 1818 | $descr =~ s/\s*$//; |
| 1819 | $descr =~ s/\s+/ /; |
| 1820 | $declaration_purpose = xml_escape($descr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1821 | } else { |
| 1822 | $declaration_purpose = ""; |
| 1823 | } |
| 1824 | if ($identifier =~ m/^struct/) { |
| 1825 | $decl_type = 'struct'; |
| 1826 | } elsif ($identifier =~ m/^union/) { |
| 1827 | $decl_type = 'union'; |
| 1828 | } elsif ($identifier =~ m/^enum/) { |
| 1829 | $decl_type = 'enum'; |
| 1830 | } elsif ($identifier =~ m/^typedef/) { |
| 1831 | $decl_type = 'typedef'; |
| 1832 | } else { |
| 1833 | $decl_type = 'function'; |
| 1834 | } |
| 1835 | |
| 1836 | if ($verbose) { |
| 1837 | print STDERR "Info(${file}:$.): Scanning doc for $identifier\n"; |
| 1838 | } |
| 1839 | } else { |
| 1840 | print STDERR "Warning(${file}:$.): Cannot understand $_ on line $.", |
| 1841 | " - I thought it was a doc line\n"; |
| 1842 | ++$warnings; |
| 1843 | $state = 0; |
| 1844 | } |
| 1845 | } elsif ($state == 2) { # look for head: lines, and include content |
| 1846 | if (/$doc_sect/o) { |
| 1847 | $newsection = $1; |
| 1848 | $newcontents = $2; |
| 1849 | |
| 1850 | if ($contents ne "") { |
Randy Dunlap | 850622d | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 1851 | if (!$in_doc_sect && $verbose) { |
| 1852 | print STDERR "Warning(${file}:$.): contents before sections\n"; |
| 1853 | ++$warnings; |
| 1854 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1855 | dump_section($section, xml_escape($contents)); |
| 1856 | $section = $section_default; |
| 1857 | } |
| 1858 | |
Randy Dunlap | 850622d | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 1859 | $in_doc_sect = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1860 | $contents = $newcontents; |
| 1861 | if ($contents ne "") { |
Randy Dunlap | 2720574 | 2006-10-11 01:22:12 -0700 | [diff] [blame] | 1862 | while ((substr($contents, 0, 1) eq " ") || |
| 1863 | substr($contents, 0, 1) eq "\t") { |
| 1864 | $contents = substr($contents, 1); |
Randy Dunlap | 0518949 | 2006-06-25 05:47:47 -0700 | [diff] [blame] | 1865 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | $contents .= "\n"; |
| 1867 | } |
| 1868 | $section = $newsection; |
| 1869 | } elsif (/$doc_end/) { |
| 1870 | |
| 1871 | if ($contents ne "") { |
| 1872 | dump_section($section, xml_escape($contents)); |
| 1873 | $section = $section_default; |
| 1874 | $contents = ""; |
| 1875 | } |
| 1876 | |
| 1877 | $prototype = ""; |
| 1878 | $state = 3; |
| 1879 | $brcount = 0; |
Randy Dunlap | 232acbc | 2006-06-25 05:47:48 -0700 | [diff] [blame] | 1880 | # print STDERR "end of doc comment, looking for prototype\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | } elsif (/$doc_content/) { |
| 1882 | # miguel-style comment kludge, look for blank lines after |
| 1883 | # @parameter line to signify start of description |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1884 | if ($1 eq "" && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1885 | ($section =~ m/^@/ || $section eq $section_context)) { |
| 1886 | dump_section($section, xml_escape($contents)); |
| 1887 | $section = $section_default; |
| 1888 | $contents = ""; |
| 1889 | } else { |
| 1890 | $contents .= $1."\n"; |
| 1891 | } |
| 1892 | } else { |
| 1893 | # i dont know - bad line? ignore. |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1894 | print STDERR "Warning(${file}:$.): bad line: $_"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1895 | ++$warnings; |
| 1896 | } |
Randy Dunlap | 232acbc | 2006-06-25 05:47:48 -0700 | [diff] [blame] | 1897 | } elsif ($state == 3) { # scanning for function '{' (end of prototype) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1898 | if ($decl_type eq 'function') { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1899 | process_state3_function($_, $file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1900 | } else { |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1901 | process_state3_type($_, $file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1902 | } |
| 1903 | } elsif ($state == 4) { |
| 1904 | # Documentation block |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1905 | if (/$doc_block/) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | dump_section($section, $contents); |
| 1907 | output_intro({'sectionlist' => \@sectionlist, |
| 1908 | 'sections' => \%sections }); |
| 1909 | $contents = ""; |
| 1910 | $function = ""; |
| 1911 | %constants = (); |
| 1912 | %parameterdescs = (); |
| 1913 | %parametertypes = (); |
| 1914 | @parameterlist = (); |
| 1915 | %sections = (); |
| 1916 | @sectionlist = (); |
| 1917 | $prototype = ""; |
| 1918 | if ( $1 eq "" ) { |
| 1919 | $section = $section_intro; |
| 1920 | } else { |
| 1921 | $section = $1; |
| 1922 | } |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1923 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1924 | elsif (/$doc_end/) |
| 1925 | { |
| 1926 | dump_section($section, $contents); |
| 1927 | output_intro({'sectionlist' => \@sectionlist, |
| 1928 | 'sections' => \%sections }); |
| 1929 | $contents = ""; |
| 1930 | $function = ""; |
| 1931 | %constants = (); |
| 1932 | %parameterdescs = (); |
| 1933 | %parametertypes = (); |
| 1934 | @parameterlist = (); |
| 1935 | %sections = (); |
| 1936 | @sectionlist = (); |
| 1937 | $prototype = ""; |
| 1938 | $state = 0; |
| 1939 | } |
| 1940 | elsif (/$doc_content/) |
| 1941 | { |
| 1942 | if ( $1 eq "" ) |
| 1943 | { |
| 1944 | $contents .= $blankline; |
| 1945 | } |
| 1946 | else |
| 1947 | { |
| 1948 | $contents .= $1 . "\n"; |
Randy Dunlap | 3c3b809 | 2006-02-01 03:06:58 -0800 | [diff] [blame] | 1949 | } |
Randy Dunlap | 3c30879 | 2007-05-08 00:24:39 -0700 | [diff] [blame] | 1950 | } |
| 1951 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1952 | } |
| 1953 | if ($initial_section_counter == $section_counter) { |
| 1954 | print STDERR "Warning(${file}): no structured comments found\n"; |
| 1955 | if ($output_mode eq "xml") { |
| 1956 | # The template wants at least one RefEntry here; make one. |
| 1957 | print "<refentry>\n"; |
| 1958 | print " <refnamediv>\n"; |
| 1959 | print " <refname>\n"; |
| 1960 | print " ${file}\n"; |
| 1961 | print " </refname>\n"; |
| 1962 | print " <refpurpose>\n"; |
| 1963 | print " Document generation inconsistency\n"; |
| 1964 | print " </refpurpose>\n"; |
| 1965 | print " </refnamediv>\n"; |
| 1966 | print " <refsect1>\n"; |
| 1967 | print " <title>\n"; |
| 1968 | print " Oops\n"; |
| 1969 | print " </title>\n"; |
| 1970 | print " <warning>\n"; |
| 1971 | print " <para>\n"; |
| 1972 | print " The template for this document tried to insert\n"; |
| 1973 | print " the structured comment from the file\n"; |
| 1974 | print " <filename>${file}</filename> at this point,\n"; |
| 1975 | print " but none was found.\n"; |
| 1976 | print " This dummy section is inserted to allow\n"; |
| 1977 | print " generation to continue.\n"; |
| 1978 | print " </para>\n"; |
| 1979 | print " </warning>\n"; |
| 1980 | print " </refsect1>\n"; |
| 1981 | print "</refentry>\n"; |
| 1982 | } |
| 1983 | } |
| 1984 | } |