.. | .. |
---|
56 | 56 | -rst Output reStructuredText format. |
---|
57 | 57 | -none Do not output documentation, only warnings. |
---|
58 | 58 | |
---|
| 59 | +Output format selection modifier (affects only ReST output): |
---|
| 60 | + |
---|
| 61 | + -sphinx-version Use the ReST C domain dialect compatible with an |
---|
| 62 | + specific Sphinx Version. |
---|
| 63 | + If not specified, kernel-doc will auto-detect using |
---|
| 64 | + the sphinx-build version found on PATH. |
---|
| 65 | + |
---|
59 | 66 | Output selection (mutually exclusive): |
---|
60 | 67 | -export Only output documentation for symbols that have been |
---|
61 | 68 | exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL() |
---|
.. | .. |
---|
66 | 73 | -function NAME Only output documentation for the given function(s) |
---|
67 | 74 | or DOC: section title(s). All other functions and DOC: |
---|
68 | 75 | sections are ignored. May be specified multiple times. |
---|
69 | | - -nofunction NAME Do NOT output documentation for the given function(s); |
---|
70 | | - only output documentation for the other functions and |
---|
71 | | - DOC: sections. May be specified multiple times. |
---|
| 76 | + -nosymbol NAME Exclude the specified symbols from the output |
---|
| 77 | + documentation. May be specified multiple times. |
---|
72 | 78 | |
---|
73 | 79 | Output selection modifiers: |
---|
74 | 80 | -no-doc-sections Do not output DOC: sections. |
---|
.. | .. |
---|
81 | 87 | Other parameters: |
---|
82 | 88 | -v Verbose output, more warnings and other information. |
---|
83 | 89 | -h Print this help. |
---|
| 90 | + -Werror Treat warnings as errors. |
---|
84 | 91 | |
---|
85 | 92 | EOF |
---|
86 | 93 | print $message; |
---|
.. | .. |
---|
212 | 219 | my $type_constant = '\b``([^\`]+)``\b'; |
---|
213 | 220 | my $type_constant2 = '\%([-_\w]+)'; |
---|
214 | 221 | my $type_func = '(\w+)\(\)'; |
---|
215 | | -my $type_param = '\@(\w*(\.\w+)*(\.\.\.)?)'; |
---|
| 222 | +my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)'; |
---|
| 223 | +my $type_param_ref = '([\!]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)'; |
---|
216 | 224 | my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params |
---|
| 225 | +my $type_fp_param2 = '\@(\w+->\S+)\(\)'; # Special RST handling for structs with func ptr params |
---|
217 | 226 | my $type_env = '(\$\w+)'; |
---|
218 | 227 | my $type_enum = '\&(enum\s*([_\w]+))'; |
---|
219 | 228 | my $type_struct = '\&(struct\s*([_\w]+))'; |
---|
.. | .. |
---|
236 | 245 | [$type_typedef, "\\\\fI\$1\\\\fP"], |
---|
237 | 246 | [$type_union, "\\\\fI\$1\\\\fP"], |
---|
238 | 247 | [$type_param, "\\\\fI\$1\\\\fP"], |
---|
| 248 | + [$type_param_ref, "\\\\fI\$1\$2\\\\fP"], |
---|
239 | 249 | [$type_member, "\\\\fI\$1\$2\$3\\\\fP"], |
---|
240 | 250 | [$type_fallback, "\\\\fI\$1\\\\fP"] |
---|
241 | 251 | ); |
---|
.. | .. |
---|
249 | 259 | [$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\\\\) <\$1>`"], |
---|
250 | 260 | [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], |
---|
251 | 261 | [$type_fp_param, "**\$1\\\\(\\\\)**"], |
---|
252 | | - [$type_func, "\\:c\\:func\\:`\$1()`"], |
---|
| 262 | + [$type_fp_param2, "**\$1\\\\(\\\\)**"], |
---|
| 263 | + [$type_func, "\$1()"], |
---|
253 | 264 | [$type_enum, "\\:c\\:type\\:`\$1 <\$2>`"], |
---|
254 | 265 | [$type_struct, "\\:c\\:type\\:`\$1 <\$2>`"], |
---|
255 | 266 | [$type_typedef, "\\:c\\:type\\:`\$1 <\$2>`"], |
---|
256 | 267 | [$type_union, "\\:c\\:type\\:`\$1 <\$2>`"], |
---|
257 | 268 | # in rst this can refer to any type |
---|
258 | 269 | [$type_fallback, "\\:c\\:type\\:`\$1`"], |
---|
259 | | - [$type_param, "**\$1**"] |
---|
| 270 | + [$type_param_ref, "**\$1\$2**"] |
---|
260 | 271 | ); |
---|
261 | 272 | my $blankline_rst = "\n"; |
---|
262 | 273 | |
---|
.. | .. |
---|
266 | 277 | } |
---|
267 | 278 | |
---|
268 | 279 | my $kernelversion; |
---|
| 280 | +my ($sphinx_major, $sphinx_minor, $sphinx_patch); |
---|
| 281 | + |
---|
269 | 282 | my $dohighlight = ""; |
---|
270 | 283 | |
---|
271 | 284 | my $verbose = 0; |
---|
| 285 | +my $Werror = 0; |
---|
272 | 286 | my $output_mode = "rst"; |
---|
273 | 287 | my $output_preformatted = 0; |
---|
274 | 288 | my $no_doc_sections = 0; |
---|
.. | .. |
---|
280 | 294 | use constant { |
---|
281 | 295 | OUTPUT_ALL => 0, # output all symbols and doc sections |
---|
282 | 296 | OUTPUT_INCLUDE => 1, # output only specified symbols |
---|
283 | | - OUTPUT_EXCLUDE => 2, # output everything except specified symbols |
---|
284 | | - OUTPUT_EXPORTED => 3, # output exported symbols |
---|
285 | | - OUTPUT_INTERNAL => 4, # output non-exported symbols |
---|
| 297 | + OUTPUT_EXPORTED => 2, # output exported symbols |
---|
| 298 | + OUTPUT_INTERNAL => 3, # output non-exported symbols |
---|
286 | 299 | }; |
---|
287 | 300 | my $output_selection = OUTPUT_ALL; |
---|
288 | | -my $show_not_found = 0; |
---|
| 301 | +my $show_not_found = 0; # No longer used |
---|
289 | 302 | |
---|
290 | 303 | my @export_file_list; |
---|
291 | 304 | |
---|
.. | .. |
---|
307 | 320 | # CAVEAT EMPTOR! Some of the others I localised may not want to be, which |
---|
308 | 321 | # could cause "use of undefined value" or other bugs. |
---|
309 | 322 | my ($function, %function_table, %parametertypes, $declaration_purpose); |
---|
| 323 | +my %nosymbol_table = (); |
---|
310 | 324 | my $declaration_start_line; |
---|
311 | 325 | my ($type, $declaration_name, $return_type); |
---|
312 | 326 | my ($newsection, $newcontents, $prototype, $brcount, %source_map); |
---|
.. | .. |
---|
315 | 329 | $verbose = "$ENV{'KBUILD_VERBOSE'}"; |
---|
316 | 330 | } |
---|
317 | 331 | |
---|
| 332 | +if (defined($ENV{'KDOC_WERROR'})) { |
---|
| 333 | + $Werror = "$ENV{'KDOC_WERROR'}"; |
---|
| 334 | +} |
---|
| 335 | + |
---|
| 336 | +if (defined($ENV{'KCFLAGS'})) { |
---|
| 337 | + my $kcflags = "$ENV{'KCFLAGS'}"; |
---|
| 338 | + |
---|
| 339 | + if ($kcflags =~ /Werror/) { |
---|
| 340 | + $Werror = 1; |
---|
| 341 | + } |
---|
| 342 | +} |
---|
| 343 | + |
---|
318 | 344 | # Generated docbook code is inserted in a template at a point where |
---|
319 | 345 | # docbook v3.1 requires a non-zero sequence of RefEntry's; see: |
---|
320 | | -# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html |
---|
| 346 | +# https://www.oasis-open.org/docbook/documentation/reference/html/refentry.html |
---|
321 | 347 | # We keep track of number of generated entries and generate a dummy |
---|
322 | 348 | # if needs be to ensure the expanded template can be postprocessed |
---|
323 | 349 | # into html. |
---|
.. | .. |
---|
327 | 353 | |
---|
328 | 354 | # Parser states |
---|
329 | 355 | use constant { |
---|
330 | | - STATE_NORMAL => 0, # normal code |
---|
331 | | - STATE_NAME => 1, # looking for function name |
---|
332 | | - STATE_BODY_MAYBE => 2, # body - or maybe more description |
---|
333 | | - STATE_BODY => 3, # the body of the comment |
---|
334 | | - STATE_PROTO => 4, # scanning prototype |
---|
335 | | - STATE_DOCBLOCK => 5, # documentation block |
---|
336 | | - STATE_INLINE => 6, # gathering documentation outside main block |
---|
| 356 | + STATE_NORMAL => 0, # normal code |
---|
| 357 | + STATE_NAME => 1, # looking for function name |
---|
| 358 | + STATE_BODY_MAYBE => 2, # body - or maybe more description |
---|
| 359 | + STATE_BODY => 3, # the body of the comment |
---|
| 360 | + STATE_BODY_WITH_BLANK_LINE => 4, # the body, which has a blank line |
---|
| 361 | + STATE_PROTO => 5, # scanning prototype |
---|
| 362 | + STATE_DOCBLOCK => 6, # documentation block |
---|
| 363 | + STATE_INLINE => 7, # gathering doc outside main block |
---|
337 | 364 | }; |
---|
338 | 365 | my $state; |
---|
339 | 366 | my $in_doc_sect; |
---|
.. | .. |
---|
361 | 388 | my $doc_com_body = '\s*\* ?'; |
---|
362 | 389 | my $doc_decl = $doc_com . '(\w+)'; |
---|
363 | 390 | # @params and a strictly limited set of supported section names |
---|
364 | | -my $doc_sect = $doc_com . |
---|
| 391 | +my $doc_sect = $doc_com . |
---|
365 | 392 | '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)'; |
---|
366 | 393 | my $doc_content = $doc_com_body . '(.*)'; |
---|
367 | 394 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; |
---|
.. | .. |
---|
413 | 440 | $output_selection = OUTPUT_INCLUDE; |
---|
414 | 441 | $function = shift @ARGV; |
---|
415 | 442 | $function_table{$function} = 1; |
---|
416 | | - } elsif ($cmd eq "nofunction") { # output all except specific functions |
---|
417 | | - $output_selection = OUTPUT_EXCLUDE; |
---|
418 | | - $function = shift @ARGV; |
---|
419 | | - $function_table{$function} = 1; |
---|
| 443 | + } elsif ($cmd eq "nosymbol") { # Exclude specific symbols |
---|
| 444 | + my $symbol = shift @ARGV; |
---|
| 445 | + $nosymbol_table{$symbol} = 1; |
---|
420 | 446 | } elsif ($cmd eq "export") { # only exported symbols |
---|
421 | 447 | $output_selection = OUTPUT_EXPORTED; |
---|
422 | 448 | %function_table = (); |
---|
.. | .. |
---|
428 | 454 | push(@export_file_list, $file); |
---|
429 | 455 | } elsif ($cmd eq "v") { |
---|
430 | 456 | $verbose = 1; |
---|
| 457 | + } elsif ($cmd eq "Werror") { |
---|
| 458 | + $Werror = 1; |
---|
431 | 459 | } elsif (($cmd eq "h") || ($cmd eq "help")) { |
---|
432 | 460 | usage(); |
---|
433 | 461 | } elsif ($cmd eq 'no-doc-sections') { |
---|
.. | .. |
---|
435 | 463 | } elsif ($cmd eq 'enable-lineno') { |
---|
436 | 464 | $enable_lineno = 1; |
---|
437 | 465 | } elsif ($cmd eq 'show-not-found') { |
---|
438 | | - $show_not_found = 1; |
---|
| 466 | + $show_not_found = 1; # A no-op but don't fail |
---|
| 467 | + } elsif ($cmd eq "sphinx-version") { |
---|
| 468 | + my $ver_string = shift @ARGV; |
---|
| 469 | + if ($ver_string =~ m/^(\d+)(\.\d+)?(\.\d+)?/) { |
---|
| 470 | + $sphinx_major = $1; |
---|
| 471 | + if (defined($2)) { |
---|
| 472 | + $sphinx_minor = substr($2,1); |
---|
| 473 | + } else { |
---|
| 474 | + $sphinx_minor = 0; |
---|
| 475 | + } |
---|
| 476 | + if (defined($3)) { |
---|
| 477 | + $sphinx_patch = substr($3,1) |
---|
| 478 | + } else { |
---|
| 479 | + $sphinx_patch = 0; |
---|
| 480 | + } |
---|
| 481 | + } else { |
---|
| 482 | + die "Sphinx version should either major.minor or major.minor.patch format\n"; |
---|
| 483 | + } |
---|
439 | 484 | } else { |
---|
440 | 485 | # Unknown argument |
---|
441 | 486 | usage(); |
---|
.. | .. |
---|
443 | 488 | } |
---|
444 | 489 | |
---|
445 | 490 | # continue execution near EOF; |
---|
| 491 | + |
---|
| 492 | +# The C domain dialect changed on Sphinx 3. So, we need to check the |
---|
| 493 | +# version in order to produce the right tags. |
---|
| 494 | +sub findprog($) |
---|
| 495 | +{ |
---|
| 496 | + foreach(split(/:/, $ENV{PATH})) { |
---|
| 497 | + return "$_/$_[0]" if(-x "$_/$_[0]"); |
---|
| 498 | + } |
---|
| 499 | +} |
---|
| 500 | + |
---|
| 501 | +sub get_sphinx_version() |
---|
| 502 | +{ |
---|
| 503 | + my $ver; |
---|
| 504 | + |
---|
| 505 | + my $cmd = "sphinx-build"; |
---|
| 506 | + if (!findprog($cmd)) { |
---|
| 507 | + my $cmd = "sphinx-build3"; |
---|
| 508 | + if (!findprog($cmd)) { |
---|
| 509 | + $sphinx_major = 1; |
---|
| 510 | + $sphinx_minor = 2; |
---|
| 511 | + $sphinx_patch = 0; |
---|
| 512 | + printf STDERR "Warning: Sphinx version not found. Using default (Sphinx version %d.%d.%d)\n", |
---|
| 513 | + $sphinx_major, $sphinx_minor, $sphinx_patch; |
---|
| 514 | + return; |
---|
| 515 | + } |
---|
| 516 | + } |
---|
| 517 | + |
---|
| 518 | + open IN, "$cmd --version 2>&1 |"; |
---|
| 519 | + while (<IN>) { |
---|
| 520 | + if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) { |
---|
| 521 | + $sphinx_major = $1; |
---|
| 522 | + $sphinx_minor = $2; |
---|
| 523 | + $sphinx_patch = $3; |
---|
| 524 | + last; |
---|
| 525 | + } |
---|
| 526 | + # Sphinx 1.2.x uses a different format |
---|
| 527 | + if (m/^\s*Sphinx.*\s+([\d]+)\.([\d\.]+)$/) { |
---|
| 528 | + $sphinx_major = $1; |
---|
| 529 | + $sphinx_minor = $2; |
---|
| 530 | + $sphinx_patch = $3; |
---|
| 531 | + last; |
---|
| 532 | + } |
---|
| 533 | + } |
---|
| 534 | + close IN; |
---|
| 535 | +} |
---|
446 | 536 | |
---|
447 | 537 | # get kernel version from env |
---|
448 | 538 | sub get_kernel_version() { |
---|
.. | .. |
---|
510 | 600 | return; |
---|
511 | 601 | } |
---|
512 | 602 | |
---|
| 603 | + return if (defined($nosymbol_table{$name})); |
---|
| 604 | + |
---|
513 | 605 | if (($output_selection == OUTPUT_ALL) || |
---|
514 | | - ($output_selection == OUTPUT_INCLUDE && |
---|
515 | | - defined($function_table{$name})) || |
---|
516 | | - ($output_selection == OUTPUT_EXCLUDE && |
---|
517 | | - !defined($function_table{$name}))) |
---|
| 606 | + (($output_selection == OUTPUT_INCLUDE) && |
---|
| 607 | + defined($function_table{$name}))) |
---|
518 | 608 | { |
---|
519 | 609 | dump_section($file, $name, $contents); |
---|
520 | 610 | output_blockhead({'sectionlist' => \@sectionlist, |
---|
.. | .. |
---|
597 | 687 | $type = $args{'parametertypes'}{$parameter}; |
---|
598 | 688 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
---|
599 | 689 | # pointer-to-function |
---|
600 | | - print ".BI \"" . $parenth . $1 . "\" " . $parameter . " \") (" . $2 . ")" . $post . "\"\n"; |
---|
| 690 | + print ".BI \"" . $parenth . $1 . "\" " . " \") (" . $2 . ")" . $post . "\"\n"; |
---|
601 | 691 | } else { |
---|
602 | 692 | $type =~ s/([^\*])$/$1 /; |
---|
603 | | - print ".BI \"" . $parenth . $type . "\" " . $parameter . " \"" . $post . "\"\n"; |
---|
| 693 | + print ".BI \"" . $parenth . $type . "\" " . " \"" . $post . "\"\n"; |
---|
604 | 694 | } |
---|
605 | 695 | $count++; |
---|
606 | 696 | $parenth = ""; |
---|
.. | .. |
---|
740 | 830 | my ($parameter, $section); |
---|
741 | 831 | |
---|
742 | 832 | foreach $section (@{$args{'sectionlist'}}) { |
---|
| 833 | + next if (defined($nosymbol_table{$section})); |
---|
| 834 | + |
---|
743 | 835 | if ($output_selection != OUTPUT_INCLUDE) { |
---|
744 | 836 | print "**$section**\n\n"; |
---|
745 | 837 | } |
---|
.. | .. |
---|
751 | 843 | |
---|
752 | 844 | # |
---|
753 | 845 | # Apply the RST highlights to a sub-block of text. |
---|
754 | | -# |
---|
| 846 | +# |
---|
755 | 847 | sub highlight_block($) { |
---|
756 | 848 | # The dohighlight kludge requires the text be called $contents |
---|
757 | 849 | my $contents = shift; |
---|
.. | .. |
---|
825 | 917 | my ($parameter, $section); |
---|
826 | 918 | my $oldprefix = $lineprefix; |
---|
827 | 919 | my $start = ""; |
---|
| 920 | + my $is_macro = 0; |
---|
828 | 921 | |
---|
829 | | - if ($args{'typedef'}) { |
---|
830 | | - print ".. c:type:: ". $args{'function'} . "\n\n"; |
---|
831 | | - print_lineno($declaration_start_line); |
---|
832 | | - print " **Typedef**: "; |
---|
833 | | - $lineprefix = ""; |
---|
834 | | - output_highlight_rst($args{'purpose'}); |
---|
835 | | - $start = "\n\n**Syntax**\n\n ``"; |
---|
| 922 | + if ($sphinx_major < 3) { |
---|
| 923 | + if ($args{'typedef'}) { |
---|
| 924 | + print ".. c:type:: ". $args{'function'} . "\n\n"; |
---|
| 925 | + print_lineno($declaration_start_line); |
---|
| 926 | + print " **Typedef**: "; |
---|
| 927 | + $lineprefix = ""; |
---|
| 928 | + output_highlight_rst($args{'purpose'}); |
---|
| 929 | + $start = "\n\n**Syntax**\n\n ``"; |
---|
| 930 | + $is_macro = 1; |
---|
| 931 | + } else { |
---|
| 932 | + print ".. c:function:: "; |
---|
| 933 | + } |
---|
836 | 934 | } else { |
---|
837 | | - print ".. c:function:: "; |
---|
| 935 | + if ($args{'typedef'} || $args{'functiontype'} eq "") { |
---|
| 936 | + $is_macro = 1; |
---|
| 937 | + print ".. c:macro:: ". $args{'function'} . "\n\n"; |
---|
| 938 | + } else { |
---|
| 939 | + print ".. c:function:: "; |
---|
| 940 | + } |
---|
| 941 | + |
---|
| 942 | + if ($args{'typedef'}) { |
---|
| 943 | + print_lineno($declaration_start_line); |
---|
| 944 | + print " **Typedef**: "; |
---|
| 945 | + $lineprefix = ""; |
---|
| 946 | + output_highlight_rst($args{'purpose'}); |
---|
| 947 | + $start = "\n\n**Syntax**\n\n ``"; |
---|
| 948 | + } else { |
---|
| 949 | + print "``" if ($is_macro); |
---|
| 950 | + } |
---|
838 | 951 | } |
---|
839 | 952 | if ($args{'functiontype'} ne "") { |
---|
840 | 953 | $start .= $args{'functiontype'} . " " . $args{'function'} . " ("; |
---|
.. | .. |
---|
853 | 966 | |
---|
854 | 967 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
---|
855 | 968 | # pointer-to-function |
---|
856 | | - print $1 . $parameter . ") (" . $2; |
---|
| 969 | + print $1 . $parameter . ") (" . $2 . ")"; |
---|
857 | 970 | } else { |
---|
858 | | - print $type . " " . $parameter; |
---|
| 971 | + print $type; |
---|
859 | 972 | } |
---|
860 | 973 | } |
---|
861 | | - if ($args{'typedef'}) { |
---|
862 | | - print ");``\n\n"; |
---|
| 974 | + if ($is_macro) { |
---|
| 975 | + print ")``\n\n"; |
---|
863 | 976 | } else { |
---|
864 | 977 | print ")\n\n"; |
---|
| 978 | + } |
---|
| 979 | + if (!$args{'typedef'}) { |
---|
865 | 980 | print_lineno($declaration_start_line); |
---|
866 | 981 | $lineprefix = " "; |
---|
867 | 982 | output_highlight_rst($args{'purpose'}); |
---|
.. | .. |
---|
876 | 991 | $type = $args{'parametertypes'}{$parameter}; |
---|
877 | 992 | |
---|
878 | 993 | if ($type ne "") { |
---|
879 | | - print "``$type $parameter``\n"; |
---|
| 994 | + print "``$type``\n"; |
---|
880 | 995 | } else { |
---|
881 | 996 | print "``$parameter``\n"; |
---|
882 | 997 | } |
---|
.. | .. |
---|
917 | 1032 | my ($parameter); |
---|
918 | 1033 | my $oldprefix = $lineprefix; |
---|
919 | 1034 | my $count; |
---|
920 | | - my $name = "enum " . $args{'enum'}; |
---|
921 | 1035 | |
---|
922 | | - print "\n\n.. c:type:: " . $name . "\n\n"; |
---|
| 1036 | + if ($sphinx_major < 3) { |
---|
| 1037 | + my $name = "enum " . $args{'enum'}; |
---|
| 1038 | + print "\n\n.. c:type:: " . $name . "\n\n"; |
---|
| 1039 | + } else { |
---|
| 1040 | + my $name = $args{'enum'}; |
---|
| 1041 | + print "\n\n.. c:enum:: " . $name . "\n\n"; |
---|
| 1042 | + } |
---|
923 | 1043 | print_lineno($declaration_start_line); |
---|
924 | 1044 | $lineprefix = " "; |
---|
925 | 1045 | output_highlight_rst($args{'purpose'}); |
---|
.. | .. |
---|
945 | 1065 | my %args = %{$_[0]}; |
---|
946 | 1066 | my ($parameter); |
---|
947 | 1067 | my $oldprefix = $lineprefix; |
---|
948 | | - my $name = "typedef " . $args{'typedef'}; |
---|
| 1068 | + my $name; |
---|
949 | 1069 | |
---|
| 1070 | + if ($sphinx_major < 3) { |
---|
| 1071 | + $name = "typedef " . $args{'typedef'}; |
---|
| 1072 | + } else { |
---|
| 1073 | + $name = $args{'typedef'}; |
---|
| 1074 | + } |
---|
950 | 1075 | print "\n\n.. c:type:: " . $name . "\n\n"; |
---|
951 | 1076 | print_lineno($declaration_start_line); |
---|
952 | 1077 | $lineprefix = " "; |
---|
.. | .. |
---|
961 | 1086 | my %args = %{$_[0]}; |
---|
962 | 1087 | my ($parameter); |
---|
963 | 1088 | my $oldprefix = $lineprefix; |
---|
964 | | - my $name = $args{'type'} . " " . $args{'struct'}; |
---|
965 | 1089 | |
---|
966 | | - print "\n\n.. c:type:: " . $name . "\n\n"; |
---|
| 1090 | + if ($sphinx_major < 3) { |
---|
| 1091 | + my $name = $args{'type'} . " " . $args{'struct'}; |
---|
| 1092 | + print "\n\n.. c:type:: " . $name . "\n\n"; |
---|
| 1093 | + } else { |
---|
| 1094 | + my $name = $args{'struct'}; |
---|
| 1095 | + if ($args{'type'} eq 'union') { |
---|
| 1096 | + print "\n\n.. c:union:: " . $name . "\n\n"; |
---|
| 1097 | + } else { |
---|
| 1098 | + print "\n\n.. c:struct:: " . $name . "\n\n"; |
---|
| 1099 | + } |
---|
| 1100 | + } |
---|
967 | 1101 | print_lineno($declaration_start_line); |
---|
968 | 1102 | $lineprefix = " "; |
---|
969 | 1103 | output_highlight_rst($args{'purpose'}); |
---|
.. | .. |
---|
1022 | 1156 | my $name = shift; |
---|
1023 | 1157 | my $functype = shift; |
---|
1024 | 1158 | my $func = "output_${functype}_$output_mode"; |
---|
| 1159 | + |
---|
| 1160 | + return if (defined($nosymbol_table{$name})); |
---|
| 1161 | + |
---|
1025 | 1162 | if (($output_selection == OUTPUT_ALL) || |
---|
1026 | 1163 | (($output_selection == OUTPUT_INCLUDE || |
---|
1027 | 1164 | $output_selection == OUTPUT_EXPORTED) && |
---|
1028 | 1165 | defined($function_table{$name})) || |
---|
1029 | | - (($output_selection == OUTPUT_EXCLUDE || |
---|
1030 | | - $output_selection == OUTPUT_INTERNAL) && |
---|
| 1166 | + ($output_selection == OUTPUT_INTERNAL && |
---|
1031 | 1167 | !($functype eq "function" && defined($function_table{$name})))) |
---|
1032 | 1168 | { |
---|
1033 | 1169 | &$func(@_); |
---|
.. | .. |
---|
1062 | 1198 | my $x = shift; |
---|
1063 | 1199 | my $file = shift; |
---|
1064 | 1200 | |
---|
1065 | | - if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) { |
---|
| 1201 | + if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) { |
---|
1066 | 1202 | my $decl_type = $1; |
---|
1067 | 1203 | $declaration_name = $2; |
---|
1068 | 1204 | my $members = $3; |
---|
.. | .. |
---|
1073 | 1209 | # strip comments: |
---|
1074 | 1210 | $members =~ s/\/\*.*?\*\///gos; |
---|
1075 | 1211 | # strip attributes |
---|
1076 | | - $members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i; |
---|
1077 | | - $members =~ s/__aligned\s*\([^;]*\)//gos; |
---|
1078 | | - $members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos; |
---|
| 1212 | + $members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)/ /gi; |
---|
| 1213 | + $members =~ s/\s*__aligned\s*\([^;]*\)/ /gos; |
---|
| 1214 | + $members =~ s/\s*__packed\s*/ /gos; |
---|
| 1215 | + $members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos; |
---|
| 1216 | + $members =~ s/\s*____cacheline_aligned_in_smp/ /gos; |
---|
| 1217 | + $members =~ s/\s*____cacheline_aligned/ /gos; |
---|
| 1218 | + # unwrap struct_group(): |
---|
| 1219 | + # - first eat non-declaration parameters and rewrite for final match |
---|
| 1220 | + # - then remove macro, outer parens, and trailing semicolon |
---|
| 1221 | + $members =~ s/\bstruct_group\s*\(([^,]*,)/STRUCT_GROUP(/gos; |
---|
| 1222 | + $members =~ s/\bstruct_group_(attr|tagged)\s*\(([^,]*,){2}/STRUCT_GROUP(/gos; |
---|
| 1223 | + $members =~ s/\b__struct_group\s*\(([^,]*,){3}/STRUCT_GROUP(/gos; |
---|
| 1224 | + $members =~ s/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/$2/gos; |
---|
| 1225 | + |
---|
1079 | 1226 | # replace DECLARE_BITMAP |
---|
| 1227 | + $members =~ s/__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)/DECLARE_BITMAP($1, __ETHTOOL_LINK_MODE_MASK_NBITS)/gos; |
---|
1080 | 1228 | $members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos; |
---|
1081 | 1229 | # replace DECLARE_HASHTABLE |
---|
1082 | 1230 | $members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos; |
---|
.. | .. |
---|
1203 | 1351 | my $functype = shift; |
---|
1204 | 1352 | my $name = shift; |
---|
1205 | 1353 | |
---|
| 1354 | + return 0 if (defined($nosymbol_table{$name})); |
---|
| 1355 | + |
---|
1206 | 1356 | return 1 if ($output_selection == OUTPUT_ALL); |
---|
1207 | 1357 | |
---|
1208 | 1358 | if ($output_selection == OUTPUT_EXPORTED) { |
---|
.. | .. |
---|
1226 | 1376 | return 0; |
---|
1227 | 1377 | } |
---|
1228 | 1378 | } |
---|
1229 | | - if ($output_selection == OUTPUT_EXCLUDE) { |
---|
1230 | | - if (!defined($function_table{$name})) { |
---|
1231 | | - return 1; |
---|
1232 | | - } else { |
---|
1233 | | - return 0; |
---|
1234 | | - } |
---|
1235 | | - } |
---|
1236 | 1379 | die("Please add the new output type at show_warnings()"); |
---|
1237 | 1380 | } |
---|
1238 | 1381 | |
---|
1239 | 1382 | sub dump_enum($$) { |
---|
1240 | 1383 | my $x = shift; |
---|
1241 | 1384 | my $file = shift; |
---|
| 1385 | + my $members; |
---|
| 1386 | + |
---|
1242 | 1387 | |
---|
1243 | 1388 | $x =~ s@/\*.*?\*/@@gos; # strip comments. |
---|
1244 | 1389 | # strip #define macros inside enums |
---|
1245 | 1390 | $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos; |
---|
1246 | 1391 | |
---|
1247 | | - if ($x =~ /enum\s+(\w+)\s*\{(.*)\}/) { |
---|
| 1392 | + if ($x =~ /typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;/) { |
---|
| 1393 | + $declaration_name = $2; |
---|
| 1394 | + $members = $1; |
---|
| 1395 | + } elsif ($x =~ /enum\s+(\w*)\s*\{(.*)\}/) { |
---|
1248 | 1396 | $declaration_name = $1; |
---|
1249 | | - my $members = $2; |
---|
| 1397 | + $members = $2; |
---|
| 1398 | + } |
---|
| 1399 | + |
---|
| 1400 | + if ($members) { |
---|
1250 | 1401 | my %_members; |
---|
1251 | 1402 | |
---|
1252 | 1403 | $members =~ s/\s+$//; |
---|
.. | .. |
---|
1281 | 1432 | 'sections' => \%sections, |
---|
1282 | 1433 | 'purpose' => $declaration_purpose |
---|
1283 | 1434 | }); |
---|
1284 | | - } |
---|
1285 | | - else { |
---|
| 1435 | + } else { |
---|
1286 | 1436 | print STDERR "${file}:$.: error: Cannot parse enum!\n"; |
---|
1287 | 1437 | ++$errors; |
---|
1288 | 1438 | } |
---|
1289 | 1439 | } |
---|
| 1440 | + |
---|
| 1441 | +my $typedef_type = qr { ((?:\s+[\w\*]+\b){1,8})\s* }x; |
---|
| 1442 | +my $typedef_ident = qr { \*?\s*(\w\S+)\s* }x; |
---|
| 1443 | +my $typedef_args = qr { \s*\((.*)\); }x; |
---|
| 1444 | + |
---|
| 1445 | +my $typedef1 = qr { typedef$typedef_type\($typedef_ident\)$typedef_args }x; |
---|
| 1446 | +my $typedef2 = qr { typedef$typedef_type$typedef_ident$typedef_args }x; |
---|
1290 | 1447 | |
---|
1291 | 1448 | sub dump_typedef($$) { |
---|
1292 | 1449 | my $x = shift; |
---|
.. | .. |
---|
1294 | 1451 | |
---|
1295 | 1452 | $x =~ s@/\*.*?\*/@@gos; # strip comments. |
---|
1296 | 1453 | |
---|
1297 | | - # Parse function prototypes |
---|
1298 | | - if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ || |
---|
1299 | | - $x =~ /typedef\s+(\w+)\s*(\w\S+)\s*\s*\((.*)\);/) { |
---|
1300 | | - |
---|
1301 | | - # Function typedefs |
---|
| 1454 | + # Parse function typedef prototypes |
---|
| 1455 | + if ($x =~ $typedef1 || $x =~ $typedef2) { |
---|
1302 | 1456 | $return_type = $1; |
---|
1303 | 1457 | $declaration_name = $2; |
---|
1304 | 1458 | my $args = $3; |
---|
| 1459 | + $return_type =~ s/^\s+//; |
---|
1305 | 1460 | |
---|
1306 | 1461 | create_parameterlist($args, ',', $file, $declaration_name); |
---|
1307 | 1462 | |
---|
.. | .. |
---|
1377 | 1532 | # Treat preprocessor directive as a typeless variable just to fill |
---|
1378 | 1533 | # corresponding data structures "correctly". Catch it later in |
---|
1379 | 1534 | # output_* subs. |
---|
1380 | | - push_parameter($arg, "", $file); |
---|
| 1535 | + push_parameter($arg, "", "", $file); |
---|
1381 | 1536 | } elsif ($arg =~ m/\(.+\)\s*\(/) { |
---|
1382 | 1537 | # pointer-to-function |
---|
1383 | 1538 | $arg =~ tr/#/,/; |
---|
.. | .. |
---|
1386 | 1541 | $type = $arg; |
---|
1387 | 1542 | $type =~ s/([^\(]+\(\*?)\s*$param/$1/; |
---|
1388 | 1543 | save_struct_actual($param); |
---|
1389 | | - push_parameter($param, $type, $file, $declaration_name); |
---|
| 1544 | + push_parameter($param, $type, $arg, $file, $declaration_name); |
---|
1390 | 1545 | } elsif ($arg) { |
---|
1391 | 1546 | $arg =~ s/\s*:\s*/:/g; |
---|
1392 | 1547 | $arg =~ s/\s*\[/\[/g; |
---|
.. | .. |
---|
1411 | 1566 | foreach $param (@args) { |
---|
1412 | 1567 | if ($param =~ m/^(\*+)\s*(.*)/) { |
---|
1413 | 1568 | save_struct_actual($2); |
---|
1414 | | - push_parameter($2, "$type $1", $file, $declaration_name); |
---|
| 1569 | + |
---|
| 1570 | + push_parameter($2, "$type $1", $arg, $file, $declaration_name); |
---|
1415 | 1571 | } |
---|
1416 | 1572 | elsif ($param =~ m/(.*?):(\d+)/) { |
---|
1417 | 1573 | if ($type ne "") { # skip unnamed bit-fields |
---|
1418 | 1574 | save_struct_actual($1); |
---|
1419 | | - push_parameter($1, "$type:$2", $file, $declaration_name) |
---|
| 1575 | + push_parameter($1, "$type:$2", $arg, $file, $declaration_name) |
---|
1420 | 1576 | } |
---|
1421 | 1577 | } |
---|
1422 | 1578 | else { |
---|
1423 | 1579 | save_struct_actual($param); |
---|
1424 | | - push_parameter($param, $type, $file, $declaration_name); |
---|
| 1580 | + push_parameter($param, $type, $arg, $file, $declaration_name); |
---|
1425 | 1581 | } |
---|
1426 | 1582 | } |
---|
1427 | 1583 | } |
---|
1428 | 1584 | } |
---|
1429 | 1585 | } |
---|
1430 | 1586 | |
---|
1431 | | -sub push_parameter($$$$) { |
---|
| 1587 | +sub push_parameter($$$$$) { |
---|
1432 | 1588 | my $param = shift; |
---|
1433 | 1589 | my $type = shift; |
---|
| 1590 | + my $org_arg = shift; |
---|
1434 | 1591 | my $file = shift; |
---|
1435 | 1592 | my $declaration_name = shift; |
---|
1436 | 1593 | |
---|
.. | .. |
---|
1447 | 1604 | if (!$param =~ /\w\.\.\.$/) { |
---|
1448 | 1605 | # handles unnamed variable parameters |
---|
1449 | 1606 | $param = "..."; |
---|
| 1607 | + } |
---|
| 1608 | + elsif ($param =~ /\w\.\.\.$/) { |
---|
| 1609 | + # for named variable parameters of the form `x...`, remove the dots |
---|
| 1610 | + $param =~ s/\.\.\.$//; |
---|
1450 | 1611 | } |
---|
1451 | 1612 | if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") { |
---|
1452 | 1613 | $parameterdescs{$param} = "variable arguments"; |
---|
.. | .. |
---|
1473 | 1634 | if (!defined $parameterdescs{$param} && $param !~ /^#/) { |
---|
1474 | 1635 | $parameterdescs{$param} = $undescribed; |
---|
1475 | 1636 | |
---|
1476 | | - if (show_warnings($type, $declaration_name)) { |
---|
| 1637 | + if (show_warnings($type, $declaration_name) && $param !~ /\./) { |
---|
1477 | 1638 | print STDERR |
---|
1478 | 1639 | "${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n"; |
---|
1479 | 1640 | ++$warnings; |
---|
.. | .. |
---|
1490 | 1651 | # "[blah" in a parameter string; |
---|
1491 | 1652 | ###$param =~ s/\s*//g; |
---|
1492 | 1653 | push @parameterlist, $param; |
---|
1493 | | - $type =~ s/\s\s+/ /g; |
---|
1494 | | - $parametertypes{$param} = $type; |
---|
| 1654 | + $org_arg =~ s/\s\s+/ /g; |
---|
| 1655 | + $parametertypes{$param} = $org_arg; |
---|
1495 | 1656 | } |
---|
1496 | 1657 | |
---|
1497 | 1658 | sub check_sections($$$$$) { |
---|
.. | .. |
---|
1565 | 1726 | my $file = shift; |
---|
1566 | 1727 | my $noret = 0; |
---|
1567 | 1728 | |
---|
| 1729 | + print_lineno($new_start_line); |
---|
| 1730 | + |
---|
1568 | 1731 | $prototype =~ s/^static +//; |
---|
1569 | 1732 | $prototype =~ s/^extern +//; |
---|
1570 | 1733 | $prototype =~ s/^asmlinkage +//; |
---|
.. | .. |
---|
1579 | 1742 | $prototype =~ s/__must_check +//; |
---|
1580 | 1743 | $prototype =~ s/__weak +//; |
---|
1581 | 1744 | $prototype =~ s/__sched +//; |
---|
| 1745 | + $prototype =~ s/__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +//; |
---|
1582 | 1746 | my $define = $prototype =~ s/^#\s*define\s+//; #ak added |
---|
1583 | 1747 | $prototype =~ s/__attribute__\s*\(\( |
---|
1584 | 1748 | (?: |
---|
.. | .. |
---|
1639 | 1803 | return; |
---|
1640 | 1804 | } |
---|
1641 | 1805 | |
---|
1642 | | - my $prms = join " ", @parameterlist; |
---|
1643 | | - check_sections($file, $declaration_name, "function", $sectcheck, $prms); |
---|
| 1806 | + my $prms = join " ", @parameterlist; |
---|
| 1807 | + check_sections($file, $declaration_name, "function", $sectcheck, $prms); |
---|
1644 | 1808 | |
---|
1645 | | - # This check emits a lot of warnings at the moment, because many |
---|
1646 | | - # functions don't have a 'Return' doc section. So until the number |
---|
1647 | | - # of warnings goes sufficiently down, the check is only performed in |
---|
1648 | | - # verbose mode. |
---|
1649 | | - # TODO: always perform the check. |
---|
1650 | | - if ($verbose && !$noret) { |
---|
1651 | | - check_return_section($file, $declaration_name, $return_type); |
---|
1652 | | - } |
---|
| 1809 | + # This check emits a lot of warnings at the moment, because many |
---|
| 1810 | + # functions don't have a 'Return' doc section. So until the number |
---|
| 1811 | + # of warnings goes sufficiently down, the check is only performed in |
---|
| 1812 | + # verbose mode. |
---|
| 1813 | + # TODO: always perform the check. |
---|
| 1814 | + if ($verbose && !$noret) { |
---|
| 1815 | + check_return_section($file, $declaration_name, $return_type); |
---|
| 1816 | + } |
---|
1653 | 1817 | |
---|
1654 | | - output_declaration($declaration_name, |
---|
1655 | | - 'function', |
---|
1656 | | - {'function' => $declaration_name, |
---|
1657 | | - 'module' => $modulename, |
---|
1658 | | - 'functiontype' => $return_type, |
---|
1659 | | - 'parameterlist' => \@parameterlist, |
---|
1660 | | - 'parameterdescs' => \%parameterdescs, |
---|
1661 | | - 'parametertypes' => \%parametertypes, |
---|
1662 | | - 'sectionlist' => \@sectionlist, |
---|
1663 | | - 'sections' => \%sections, |
---|
1664 | | - 'purpose' => $declaration_purpose |
---|
1665 | | - }); |
---|
| 1818 | + # The function parser can be called with a typedef parameter. |
---|
| 1819 | + # Handle it. |
---|
| 1820 | + if ($return_type =~ /typedef/) { |
---|
| 1821 | + output_declaration($declaration_name, |
---|
| 1822 | + 'function', |
---|
| 1823 | + {'function' => $declaration_name, |
---|
| 1824 | + 'typedef' => 1, |
---|
| 1825 | + 'module' => $modulename, |
---|
| 1826 | + 'functiontype' => $return_type, |
---|
| 1827 | + 'parameterlist' => \@parameterlist, |
---|
| 1828 | + 'parameterdescs' => \%parameterdescs, |
---|
| 1829 | + 'parametertypes' => \%parametertypes, |
---|
| 1830 | + 'sectionlist' => \@sectionlist, |
---|
| 1831 | + 'sections' => \%sections, |
---|
| 1832 | + 'purpose' => $declaration_purpose |
---|
| 1833 | + }); |
---|
| 1834 | + } else { |
---|
| 1835 | + output_declaration($declaration_name, |
---|
| 1836 | + 'function', |
---|
| 1837 | + {'function' => $declaration_name, |
---|
| 1838 | + 'module' => $modulename, |
---|
| 1839 | + 'functiontype' => $return_type, |
---|
| 1840 | + 'parameterlist' => \@parameterlist, |
---|
| 1841 | + 'parameterdescs' => \%parameterdescs, |
---|
| 1842 | + 'parametertypes' => \%parametertypes, |
---|
| 1843 | + 'sectionlist' => \@sectionlist, |
---|
| 1844 | + 'sections' => \%sections, |
---|
| 1845 | + 'purpose' => $declaration_purpose |
---|
| 1846 | + }); |
---|
| 1847 | + } |
---|
1666 | 1848 | } |
---|
1667 | 1849 | |
---|
1668 | 1850 | sub reset_state { |
---|
.. | .. |
---|
1757 | 1939 | $prototype =~ s@/\*.*?\*/@@gos; # strip comments. |
---|
1758 | 1940 | $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. |
---|
1759 | 1941 | $prototype =~ s@^\s+@@gos; # strip leading spaces |
---|
| 1942 | + |
---|
| 1943 | + # Handle prototypes for function pointers like: |
---|
| 1944 | + # int (*pcs_config)(struct foo) |
---|
| 1945 | + $prototype =~ s@^(\S+\s+)\(\s*\*(\S+)\)@$1$2@gos; |
---|
| 1946 | + |
---|
1760 | 1947 | if ($prototype =~ /SYSCALL_DEFINE/) { |
---|
1761 | 1948 | syscall_munge(); |
---|
1762 | 1949 | } |
---|
.. | .. |
---|
1835 | 2022 | |
---|
1836 | 2023 | while (<IN>) { |
---|
1837 | 2024 | if (/$export_symbol/) { |
---|
| 2025 | + next if (defined($nosymbol_table{$2})); |
---|
1838 | 2026 | $function_table{$2} = 1; |
---|
1839 | 2027 | } |
---|
1840 | 2028 | } |
---|
.. | .. |
---|
1866 | 2054 | if (/$doc_block/o) { |
---|
1867 | 2055 | $state = STATE_DOCBLOCK; |
---|
1868 | 2056 | $contents = ""; |
---|
1869 | | - $new_start_line = $. + 1; |
---|
| 2057 | + $new_start_line = $.; |
---|
1870 | 2058 | |
---|
1871 | 2059 | if ( $1 eq "" ) { |
---|
1872 | 2060 | $section = $section_intro; |
---|
.. | .. |
---|
1904 | 2092 | ++$warnings; |
---|
1905 | 2093 | } |
---|
1906 | 2094 | |
---|
1907 | | - if ($identifier =~ m/^struct/) { |
---|
| 2095 | + if ($identifier =~ m/^struct\b/) { |
---|
1908 | 2096 | $decl_type = 'struct'; |
---|
1909 | | - } elsif ($identifier =~ m/^union/) { |
---|
| 2097 | + } elsif ($identifier =~ m/^union\b/) { |
---|
1910 | 2098 | $decl_type = 'union'; |
---|
1911 | | - } elsif ($identifier =~ m/^enum/) { |
---|
| 2099 | + } elsif ($identifier =~ m/^enum\b/) { |
---|
1912 | 2100 | $decl_type = 'enum'; |
---|
1913 | | - } elsif ($identifier =~ m/^typedef/) { |
---|
| 2101 | + } elsif ($identifier =~ m/^typedef\b/) { |
---|
1914 | 2102 | $decl_type = 'typedef'; |
---|
1915 | 2103 | } else { |
---|
1916 | 2104 | $decl_type = 'function'; |
---|
.. | .. |
---|
1933 | 2121 | # |
---|
1934 | 2122 | sub process_body($$) { |
---|
1935 | 2123 | my $file = shift; |
---|
| 2124 | + |
---|
| 2125 | + # Until all named variable macro parameters are |
---|
| 2126 | + # documented using the bare name (`x`) rather than with |
---|
| 2127 | + # dots (`x...`), strip the dots: |
---|
| 2128 | + if ($section =~ /\w\.\.\.$/) { |
---|
| 2129 | + $section =~ s/\.\.\.$//; |
---|
| 2130 | + |
---|
| 2131 | + if ($verbose) { |
---|
| 2132 | + print STDERR "${file}:$.: warning: Variable macro arguments should be documented without dots\n"; |
---|
| 2133 | + ++$warnings; |
---|
| 2134 | + } |
---|
| 2135 | + } |
---|
| 2136 | + |
---|
| 2137 | + if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) { |
---|
| 2138 | + dump_section($file, $section, $contents); |
---|
| 2139 | + $section = $section_default; |
---|
| 2140 | + $new_start_line = $.; |
---|
| 2141 | + $contents = ""; |
---|
| 2142 | + } |
---|
1936 | 2143 | |
---|
1937 | 2144 | if (/$doc_sect/i) { # case insensitive for supported section names |
---|
1938 | 2145 | $newsection = $1; |
---|
.. | .. |
---|
1986 | 2193 | $prototype = ""; |
---|
1987 | 2194 | $state = STATE_PROTO; |
---|
1988 | 2195 | $brcount = 0; |
---|
| 2196 | + $new_start_line = $. + 1; |
---|
1989 | 2197 | } elsif (/$doc_content/) { |
---|
1990 | | - # miguel-style comment kludge, look for blank lines after |
---|
1991 | | - # @parameter line to signify start of description |
---|
1992 | 2198 | if ($1 eq "") { |
---|
1993 | | - if ($section =~ m/^@/ || $section eq $section_context) { |
---|
| 2199 | + if ($section eq $section_context) { |
---|
1994 | 2200 | dump_section($file, $section, $contents); |
---|
1995 | 2201 | $section = $section_default; |
---|
1996 | 2202 | $contents = ""; |
---|
1997 | 2203 | $new_start_line = $.; |
---|
| 2204 | + $state = STATE_BODY; |
---|
1998 | 2205 | } else { |
---|
| 2206 | + if ($section ne $section_default) { |
---|
| 2207 | + $state = STATE_BODY_WITH_BLANK_LINE; |
---|
| 2208 | + } else { |
---|
| 2209 | + $state = STATE_BODY; |
---|
| 2210 | + } |
---|
1999 | 2211 | $contents .= "\n"; |
---|
2000 | 2212 | } |
---|
2001 | | - $state = STATE_BODY; |
---|
2002 | 2213 | } elsif ($state == STATE_BODY_MAYBE) { |
---|
2003 | 2214 | # Continued declaration purpose |
---|
2004 | 2215 | chomp($declaration_purpose); |
---|
.. | .. |
---|
2130 | 2341 | |
---|
2131 | 2342 | $file = map_filename($orig_file); |
---|
2132 | 2343 | |
---|
2133 | | - if (!open(IN,"<$file")) { |
---|
| 2344 | + if (!open(IN_FILE,"<$file")) { |
---|
2134 | 2345 | print STDERR "Error: Cannot open file $file\n"; |
---|
2135 | 2346 | ++$errors; |
---|
2136 | 2347 | return; |
---|
.. | .. |
---|
2139 | 2350 | $. = 1; |
---|
2140 | 2351 | |
---|
2141 | 2352 | $section_counter = 0; |
---|
2142 | | - while (<IN>) { |
---|
| 2353 | + while (<IN_FILE>) { |
---|
2143 | 2354 | while (s/\\\s*$//) { |
---|
2144 | | - $_ .= <IN>; |
---|
| 2355 | + $_ .= <IN_FILE>; |
---|
2145 | 2356 | } |
---|
2146 | 2357 | # Replace tabs by spaces |
---|
2147 | 2358 | while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; |
---|
.. | .. |
---|
2150 | 2361 | process_normal(); |
---|
2151 | 2362 | } elsif ($state == STATE_NAME) { |
---|
2152 | 2363 | process_name($file, $_); |
---|
2153 | | - } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { |
---|
| 2364 | + } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE || |
---|
| 2365 | + $state == STATE_BODY_WITH_BLANK_LINE) { |
---|
2154 | 2366 | process_body($file, $_); |
---|
2155 | 2367 | } elsif ($state == STATE_INLINE) { # scanning for inline parameters |
---|
2156 | 2368 | process_inline($file, $_); |
---|
.. | .. |
---|
2162 | 2374 | } |
---|
2163 | 2375 | |
---|
2164 | 2376 | # Make sure we got something interesting. |
---|
2165 | | - if ($initial_section_counter == $section_counter) { |
---|
2166 | | - if ($output_mode ne "none") { |
---|
| 2377 | + if ($initial_section_counter == $section_counter && $ |
---|
| 2378 | + output_mode ne "none") { |
---|
| 2379 | + if ($output_selection == OUTPUT_INCLUDE) { |
---|
| 2380 | + print STDERR "${file}:1: warning: '$_' not found\n" |
---|
| 2381 | + for keys %function_table; |
---|
| 2382 | + } |
---|
| 2383 | + else { |
---|
2167 | 2384 | print STDERR "${file}:1: warning: no structured comments found\n"; |
---|
2168 | 2385 | } |
---|
2169 | | - if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) { |
---|
2170 | | - print STDERR " Was looking for '$_'.\n" for keys %function_table; |
---|
2171 | | - } |
---|
2172 | 2386 | } |
---|
| 2387 | + close IN_FILE; |
---|
2173 | 2388 | } |
---|
2174 | 2389 | |
---|
| 2390 | + |
---|
| 2391 | +if ($output_mode eq "rst") { |
---|
| 2392 | + get_sphinx_version() if (!$sphinx_major); |
---|
| 2393 | +} |
---|
2175 | 2394 | |
---|
2176 | 2395 | $kernelversion = get_kernel_version(); |
---|
2177 | 2396 | |
---|
.. | .. |
---|
2219 | 2438 | print STDERR "$warnings warnings\n"; |
---|
2220 | 2439 | } |
---|
2221 | 2440 | |
---|
2222 | | -exit($output_mode eq "none" ? 0 : $errors); |
---|
| 2441 | +if ($Werror && $warnings) { |
---|
| 2442 | + print STDERR "$warnings warnings as Errors\n"; |
---|
| 2443 | + exit($warnings); |
---|
| 2444 | +} else { |
---|
| 2445 | + exit($output_mode eq "none" ? 0 : $errors) |
---|
| 2446 | +} |
---|