aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2018-02-05 18:11:47 -0500
committerJonathan Corbet <corbet@lwn.net>2018-02-15 15:11:24 -0500
commitc17add56ca4ee618b07ed9a21e2a29f0a90dc0ba (patch)
tree6f714d85ae2ead5cf00b6ee164eb4475e3e2fc31 /scripts/kernel-doc
parentcc794812eba917f271c6a09ac4cb1750497e404c (diff)
docs: kernel-doc: Finish moving STATE_* code out of process_file()
Move STATE_INLINE and STATE_DOCBLOCK code out of process_file(), which now actually fits on a single screen. Delete an unused variable and add a couple of comments while I'm at it. Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-xscripts/kernel-doc139
1 files changed, 77 insertions, 62 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 2deddb876156..fb8fbdb25036 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1990,10 +1990,80 @@ sub process_proto($$) {
1990 } 1990 }
1991} 1991}
1992 1992
1993#
1994# STATE_DOCBLOCK: within a DOC: block.
1995#
1996sub process_docblock($$) {
1997 my $file = shift;
1998
1999 if (/$doc_end/) {
2000 dump_doc_section($file, $section, $contents);
2001 $section = $section_default;
2002 $contents = "";
2003 $function = "";
2004 %parameterdescs = ();
2005 %parametertypes = ();
2006 @parameterlist = ();
2007 %sections = ();
2008 @sectionlist = ();
2009 $prototype = "";
2010 $state = STATE_NORMAL;
2011 } elsif (/$doc_content/) {
2012 if ( $1 eq "" ) {
2013 $contents .= $blankline;
2014 } else {
2015 $contents .= $1 . "\n";
2016 }
2017 }
2018}
2019
2020#
2021# STATE_INLINE: docbook comments within a prototype.
2022#
2023sub process_inline($$) {
2024 my $file = shift;
2025
2026 # First line (state 1) needs to be a @parameter
2027 if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) {
2028 $section = $1;
2029 $contents = $2;
2030 $new_start_line = $.;
2031 if ($contents ne "") {
2032 while (substr($contents, 0, 1) eq " ") {
2033 $contents = substr($contents, 1);
2034 }
2035 $contents .= "\n";
2036 }
2037 $inline_doc_state = STATE_INLINE_TEXT;
2038 # Documentation block end */
2039 } elsif (/$doc_inline_end/) {
2040 if (($contents ne "") && ($contents ne "\n")) {
2041 dump_section($file, $section, $contents);
2042 $section = $section_default;
2043 $contents = "";
2044 }
2045 $state = STATE_PROTO;
2046 $inline_doc_state = STATE_INLINE_NA;
2047 # Regular text
2048 } elsif (/$doc_content/) {
2049 if ($inline_doc_state == STATE_INLINE_TEXT) {
2050 $contents .= $1 . "\n";
2051 # nuke leading blank lines
2052 if ($contents =~ /^\s*$/) {
2053 $contents = "";
2054 }
2055 } elsif ($inline_doc_state == STATE_INLINE_NAME) {
2056 $inline_doc_state = STATE_INLINE_ERROR;
2057 print STDERR "${file}:$.: warning: ";
2058 print STDERR "Incorrect use of kernel-doc format: $_";
2059 ++$warnings;
2060 }
2061 }
2062}
2063
1993 2064
1994sub process_file($) { 2065sub process_file($) {
1995 my $file; 2066 my $file;
1996 my $func;
1997 my $initial_section_counter = $section_counter; 2067 my $initial_section_counter = $section_counter;
1998 my ($orig_file) = @_; 2068 my ($orig_file) = @_;
1999 2069
@@ -2014,6 +2084,8 @@ sub process_file($) {
2014 } 2084 }
2015 # Replace tabs by spaces 2085 # Replace tabs by spaces
2016 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; 2086 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
2087
2088 # Hand this line to the appropriate state handler
2017 if ($state == STATE_NORMAL) { 2089 if ($state == STATE_NORMAL) {
2018 process_normal(); 2090 process_normal();
2019 } elsif ($state == STATE_NAME) { 2091 } elsif ($state == STATE_NAME) {
@@ -2021,72 +2093,15 @@ sub process_file($) {
2021 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { 2093 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) {
2022 process_body($file, $_); 2094 process_body($file, $_);
2023 } elsif ($state == STATE_INLINE) { # scanning for inline parameters 2095 } elsif ($state == STATE_INLINE) { # scanning for inline parameters
2024 # First line (state 1) needs to be a @parameter 2096 process_inline($file, $_);
2025 if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) {
2026 $section = $1;
2027 $contents = $2;
2028 $new_start_line = $.;
2029 if ($contents ne "") {
2030 while (substr($contents, 0, 1) eq " ") {
2031 $contents = substr($contents, 1);
2032 }
2033 $contents .= "\n";
2034 }
2035 $inline_doc_state = STATE_INLINE_TEXT;
2036 # Documentation block end */
2037 } elsif (/$doc_inline_end/) {
2038 if (($contents ne "") && ($contents ne "\n")) {
2039 dump_section($file, $section, $contents);
2040 $section = $section_default;
2041 $contents = "";
2042 }
2043 $state = STATE_PROTO;
2044 $inline_doc_state = STATE_INLINE_NA;
2045 # Regular text
2046 } elsif (/$doc_content/) {
2047 if ($inline_doc_state == STATE_INLINE_TEXT) {
2048 $contents .= $1 . "\n";
2049 # nuke leading blank lines
2050 if ($contents =~ /^\s*$/) {
2051 $contents = "";
2052 }
2053 } elsif ($inline_doc_state == STATE_INLINE_NAME) {
2054 $inline_doc_state = STATE_INLINE_ERROR;
2055 print STDERR "${file}:$.: warning: ";
2056 print STDERR "Incorrect use of kernel-doc format: $_";
2057 ++$warnings;
2058 }
2059 }
2060 } elsif ($state == STATE_PROTO) { 2097 } elsif ($state == STATE_PROTO) {
2061 process_proto($file, $_); 2098 process_proto($file, $_);
2062 } elsif ($state == STATE_DOCBLOCK) { 2099 } elsif ($state == STATE_DOCBLOCK) {
2063 if (/$doc_end/) 2100 process_docblock($file, $_);
2064 {
2065 dump_doc_section($file, $section, $contents);
2066 $section = $section_default;
2067 $contents = "";
2068 $function = "";
2069 %parameterdescs = ();
2070 %parametertypes = ();
2071 @parameterlist = ();
2072 %sections = ();
2073 @sectionlist = ();
2074 $prototype = "";
2075 $state = STATE_NORMAL;
2076 }
2077 elsif (/$doc_content/)
2078 {
2079 if ( $1 eq "" )
2080 {
2081 $contents .= $blankline;
2082 }
2083 else
2084 {
2085 $contents .= $1 . "\n";
2086 }
2087 }
2088 } 2101 }
2089 } 2102 }
2103
2104 # Make sure we got something interesting.
2090 if ($initial_section_counter == $section_counter) { 2105 if ($initial_section_counter == $section_counter) {
2091 if ($output_mode ne "none") { 2106 if ($output_mode ne "none") {
2092 print STDERR "${file}:1: warning: no structured comments found\n"; 2107 print STDERR "${file}:1: warning: no structured comments found\n";