Lines Matching +full:sub +full:- +full:block
2 # SPDX-License-Identifier: GPL-2.0
11 ## Copyright (C) 2005-2012 Randy Dunlap ##
23 kernel-doc - Print formatted kernel documentation to stdout
27 …kernel-doc [-h] [-v] [-Werror] [-Wall] [-Wreturn] [-Wshort-desc[ription]] [-Wcontents-before-secti…
28 [ -man |
29 -rst [-sphinx-version VERSION] [-enable-lineno] |
30 -none
33 -export |
34 -internal |
35 [-function NAME] ... |
36 [-nosymbol NAME] ...
38 [-no-doc-sections]
39 [-export-file FILE] ...
42 Run `kernel-doc -h` for details.
51 See Documentation/doc-guide/kernel-doc.rst for the documentation comment syntax.
65 my $type_constant2 = '\%([-_*\w]+)';
67 my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
68 my $type_param_ref = '([\!~\*]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
70 my $type_fp_param2 = '\@(\w+->\S+)\(\)'; # Special RST handling for structs with func ptr params
76 my $type_member = '\&([_\w]+)(\.|->)([_\w]+)';
99 # rst-mode
122 if ($#ARGV == -1) {
124 -message => "No arguments!\n",
125 -exitval => 1,
126 -verbose => 99,
127 -sections => 'SYNOPSIS',
128 -output => \*STDERR,
154 OUTPUT_INTERNAL => 3, # output non-exported symbols
163 (my $seconds = `date -d "${ENV{'KBUILD_BUILD_TIMESTAMP'}}" +%s`) ne '') {
191 if ($kcflags =~ /(\s|^)-Werror(\s|$)/) {
202 # other environment variables are converted to command-line
206 # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
207 # https://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
219 STATE_BODY_MAYBE => 2, # body - or maybe more description
223 STATE_DOCBLOCK => 6, # documentation block
224 STATE_INLINE => 7, # gathering doc outside main block
236 STATE_INLINE_ERROR => 4, # error - Comment without header was found.
238 # proper kernel-doc and ignore the rest.
246 # Name of the kernel-doc identifier for non-DOC markups
258 # @{section-name}:
259 # while trying to not match literal block starts like "example::"
272 my $attribute = qr{__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)}i;
293 my $undescribed = "-- undescribed --";
297 while ($ARGV[0] =~ m/^--?(.*)/) {
322 } elsif ($cmd eq "internal") { # only non-exported symbols
325 } elsif ($cmd eq "export-file") {
334 } elsif ($cmd eq "Wshort-desc" or $cmd eq "Wshort-description") {
336 } elsif ($cmd eq "Wcontents-before-sections") {
343 pod2usage(-exitval => 0, -verbose => 2);
344 } elsif ($cmd eq 'no-doc-sections') {
346 } elsif ($cmd eq 'enable-lineno') {
348 } elsif ($cmd eq 'show-not-found') {
349 $show_not_found = 1; # A no-op but don't fail
350 } elsif ($cmd eq "sphinx-version") {
370 -message => "Argument unknown!\n",
371 -exitval => 1,
372 -verbose => 99,
373 -sections => 'SYNOPSIS',
374 -output => \*STDERR,
379 -message => "FILE argument missing\n",
380 -exitval => 1,
381 -verbose => 99,
382 -sections => 'SYNOPSIS',
383 -output => \*STDERR,
392 sub findprog($)
395 return "$_/$_[0]" if(-x "$_/$_[0]");
399 sub get_sphinx_version()
403 my $cmd = "sphinx-build";
405 my $cmd = "sphinx-build3";
416 open IN, "$cmd --version 2>&1 |";
418 if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) {
436 sub get_kernel_version() {
446 sub print_lineno {
453 sub emit_warning {
462 sub dump_section {
498 sub dump_doc_section {
517 'content-only' => ($output_selection != OUTPUT_ALL), });
532 sub output_highlight {
568 sub output_function_man(%) {
573 my $paramcount = $#{$args{'parameterlist'}}; # -1 is empty
578 print $args{'function'} . " \\- " . $args{'purpose'} . "\n";
595 # pointer-to-function
605 $paramcount = $#{$args{'parameterlist'}}; # -1 is empty
624 sub output_enum_man(%) {
632 print "enum " . $args{'enum'} . " \\- " . $args{'purpose'} . "\n";
664 sub output_struct_man(%) {
671 print $args{'type'} . " " . $args{'struct'} . " \\- " . $args{'purpose'} . "\n";
699 sub output_typedef_man(%) {
706 print "typedef " . $args{'typedef'} . " \\- " . $args{'purpose'} . "\n";
714 sub output_blockhead_man(%) {
736 sub output_blockhead_rst(%) {
754 # Apply the RST highlights to a sub-block of text.
756 sub highlight_block($) {
768 my $sphinx_cblock = '^\.\.\ +code-block::';
770 sub output_highlight_rst {
776 my $block = "";
780 # If we're in a literal block, see if we should drop out
786 # If this is the first non-blank line in a literal
787 # block we need to figure out what the proper indent is.
803 # Not in a literal block (or just dropped out)
806 $block .= $line . "\n";
810 $output .= highlight_block($block);
811 $block = ""
816 if ($block) {
817 $output .= highlight_block($block);
824 sub output_function_rst(%) {
831 my $paramcount = $#{$args{'parameterlist'}}; # -1 is empty
851 # pointer-to-function
937 sub output_section_rst(%) {
951 sub output_enum_rst(%) {
989 sub output_typedef_rst(%) {
1010 sub output_struct_rst(%) {
1063 sub output_function_none(%) {
1066 sub output_enum_none(%) {
1069 sub output_typedef_none(%) {
1072 sub output_struct_none(%) {
1075 sub output_blockhead_none(%) {
1082 sub output_declaration {
1103 # generic output function - calls the right one based on current output mode.
1104 sub output_blockhead {
1114 sub dump_declaration($$) {
1121 sub dump_union($$) {
1125 sub dump_struct($$) {
1167 # - first eat non-declaration parameters and rewrite for final match
1168 # - then remove macro, outer parens, and trailing semicolon
1181 … $members =~ s/DECLARE_HASHTABLE\s*\($args,\s*$args\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
1208 # pointer-to-function
1278 $level-- if ($clause =~ m/(\})/ && $level > 1);
1305 sub show_warnings($$) {
1337 sub dump_enum($$) {
1361 emit_warning("${file}:$.", "wrong kernel-doc identifier on line:\n");
1417 sub dump_typedef($$) {
1480 sub save_struct_actual($) {
1488 sub create_parameterlist($$$$) {
1518 # pointer-to-function
1527 # array-of-pointers
1562 if ($type ne "") { # skip unnamed bit-fields
1575 sub push_parameter($$$$$) {
1648 sub check_sections($$$$$) {
1695 sub check_return_section {
1719 sub dump_function($$) {
1770 # - parport_register_device (function pointer parameters)
1771 # - atomic_set (macro)
1772 # - pci_match_device, __copy_to_user (long return type)
1773 my $name = qr{[a-zA-Z0-9_~:]+};
1781 # This is an object-like macro, it has no return type and no parameter
1783 # Function-like macros are not allowed to have spaces between
1812 # -Wreturn mode.
1852 sub reset_state {
1867 sub tracepoint_munge($) {
1894 sub syscall_munge() {
1898 ## if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) {
1911 # now delete all of the odd-number commas in $prototype
1916 $len = 0; # skip the for-loop
1928 sub process_proto_function($$) {
1932 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1962 sub process_proto_type($$) {
1969 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1983 ($2 eq '}') && $brcount--;
1998 sub map_filename($) {
2015 sub process_export_file($) {
2044 sub process_normal() {
2053 # STATE_NAME: Looking for the "name - description" line
2055 sub process_name($$) {
2073 # test for pointer declaration type, foo * bar() - desc
2076 my $decl_end = qr{[-:].*};
2085 # Look for foo() or static void foo() - description; or misspelt
2088 /^$decl_start$fn_type?(\w+[^-:]*)$parenthesis?\s*$decl_end$/) {
2102 if (/[-:](.*)/) {
2115 …"This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/ker…
2124 emit_warning("${file}:$.", "wrong kernel-doc identifier on line:\n$_");
2132 … emit_warning("${file}:$.", "Cannot understand $_ on line $. - I thought it was a doc line\n");
2141 sub process_body($$) {
2195 if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') {
2239 # i dont know - bad line? ignore.
2248 sub process_proto($$) {
2271 # STATE_DOCBLOCK: within a DOC: block.
2273 sub process_docblock($$) {
2300 sub process_inline($$) {
2315 # Documentation block end */
2334 emit_warning("${file}:$.", "Incorrect use of kernel-doc format: $_");
2340 sub process_file($) {
2360 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
2456 =item -man
2460 =item -rst
2464 =item -none
2476 =item -sphinx-version VERSION
2480 If not specified, kernel-doc will auto-detect using the sphinx-build version
2489 =item -export
2492 EXPORT_SYMBOL() and related macros in any input FILE or -export-file FILE.
2494 =item -internal
2497 EXPORT_SYMBOL() and related macros in any input FILE or -export-file FILE.
2499 =item -function NAME
2506 =item -nosymbol NAME
2518 =item -no-doc-sections
2522 =item -export-file FILE
2526 To be used with -export or -internal.
2536 =item -enable-lineno
2546 =item -h, -help
2550 =item -v
2554 =item -Werror