kernel-doc (ee2aa7590398ecc0877552191e38d8a282f21cb8) | kernel-doc (0d55d48b19ff3a31b295836da23223a52de7ef06) |
---|---|
1#!/usr/bin/env perl 2# SPDX-License-Identifier: GPL-2.0 3 4use warnings; 5use strict; 6 7## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 8## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## --- 317 unchanged lines hidden (view full) --- 326# if needs be to ensure the expanded template can be postprocessed 327# into html. 328my $section_counter = 0; 329 330my $lineprefix=""; 331 332# Parser states 333use constant { | 1#!/usr/bin/env perl 2# SPDX-License-Identifier: GPL-2.0 3 4use warnings; 5use strict; 6 7## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 8## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## --- 317 unchanged lines hidden (view full) --- 326# if needs be to ensure the expanded template can be postprocessed 327# into html. 328my $section_counter = 0; 329 330my $lineprefix=""; 331 332# Parser states 333use constant { |
334 STATE_NORMAL => 0, # normal code 335 STATE_NAME => 1, # looking for function name 336 STATE_BODY_MAYBE => 2, # body - or maybe more description 337 STATE_BODY => 3, # the body of the comment 338 STATE_PROTO => 4, # scanning prototype 339 STATE_DOCBLOCK => 5, # documentation block 340 STATE_INLINE => 6, # gathering documentation outside main block | 334 STATE_NORMAL => 0, # normal code 335 STATE_NAME => 1, # looking for function name 336 STATE_BODY_MAYBE => 2, # body - or maybe more description 337 STATE_BODY => 3, # the body of the comment 338 STATE_BODY_WITH_BLANK_LINE => 4, # the body, which has a blank line 339 STATE_PROTO => 5, # scanning prototype 340 STATE_DOCBLOCK => 6, # documentation block 341 STATE_INLINE => 7, # gathering doc outside main block |
341}; 342my $state; 343my $in_doc_sect; 344my $leading_space; 345 346# Inline documentation state 347use constant { 348 STATE_INLINE_NA => 0, # not applicable ($state != STATE_INLINE) --- 1603 unchanged lines hidden (view full) --- 1952 $section =~ s/\.\.\.$//; 1953 1954 if ($verbose) { 1955 print STDERR "${file}:$.: warning: Variable macro arguments should be documented without dots\n"; 1956 ++$warnings; 1957 } 1958 } 1959 | 342}; 343my $state; 344my $in_doc_sect; 345my $leading_space; 346 347# Inline documentation state 348use constant { 349 STATE_INLINE_NA => 0, # not applicable ($state != STATE_INLINE) --- 1603 unchanged lines hidden (view full) --- 1953 $section =~ s/\.\.\.$//; 1954 1955 if ($verbose) { 1956 print STDERR "${file}:$.: warning: Variable macro arguments should be documented without dots\n"; 1957 ++$warnings; 1958 } 1959 } 1960 |
1961 if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) { 1962 dump_section($file, $section, $contents); 1963 $section = $section_default; 1964 $contents = ""; 1965 } 1966 |
|
1960 if (/$doc_sect/i) { # case insensitive for supported section names 1961 $newsection = $1; 1962 $newcontents = $2; 1963 1964 # map the supported section names to the canonical names 1965 if ($newsection =~ m/^description$/i) { 1966 $newsection = $section_default; 1967 } elsif ($newsection =~ m/^context$/i) { --- 37 unchanged lines hidden (view full) --- 2005 print STDERR "${file}:$.: warning: suspicious ending line: $_"; 2006 ++$warnings; 2007 } 2008 2009 $prototype = ""; 2010 $state = STATE_PROTO; 2011 $brcount = 0; 2012 } elsif (/$doc_content/) { | 1967 if (/$doc_sect/i) { # case insensitive for supported section names 1968 $newsection = $1; 1969 $newcontents = $2; 1970 1971 # map the supported section names to the canonical names 1972 if ($newsection =~ m/^description$/i) { 1973 $newsection = $section_default; 1974 } elsif ($newsection =~ m/^context$/i) { --- 37 unchanged lines hidden (view full) --- 2012 print STDERR "${file}:$.: warning: suspicious ending line: $_"; 2013 ++$warnings; 2014 } 2015 2016 $prototype = ""; 2017 $state = STATE_PROTO; 2018 $brcount = 0; 2019 } elsif (/$doc_content/) { |
2013 # miguel-style comment kludge, look for blank lines after 2014 # @parameter line to signify start of description | |
2015 if ($1 eq "") { | 2020 if ($1 eq "") { |
2016 if ($section =~ m/^@/ || $section eq $section_context) { | 2021 if ($section eq $section_context) { |
2017 dump_section($file, $section, $contents); 2018 $section = $section_default; 2019 $contents = ""; 2020 $new_start_line = $.; | 2022 dump_section($file, $section, $contents); 2023 $section = $section_default; 2024 $contents = ""; 2025 $new_start_line = $.; |
2026 $state = STATE_BODY; |
|
2021 } else { | 2027 } else { |
2028 if ($section ne $section_default) { 2029 $state = STATE_BODY_WITH_BLANK_LINE; 2030 } else { 2031 $state = STATE_BODY; 2032 } |
|
2022 $contents .= "\n"; 2023 } | 2033 $contents .= "\n"; 2034 } |
2024 $state = STATE_BODY; | |
2025 } elsif ($state == STATE_BODY_MAYBE) { 2026 # Continued declaration purpose 2027 chomp($declaration_purpose); 2028 $declaration_purpose .= " " . $1; 2029 $declaration_purpose =~ s/\s+/ /g; 2030 } else { 2031 my $cont = $1; 2032 if ($section =~ m/^@/ || $section eq $section_context) { --- 135 unchanged lines hidden (view full) --- 2168 } 2169 # Replace tabs by spaces 2170 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; 2171 # Hand this line to the appropriate state handler 2172 if ($state == STATE_NORMAL) { 2173 process_normal(); 2174 } elsif ($state == STATE_NAME) { 2175 process_name($file, $_); | 2035 } elsif ($state == STATE_BODY_MAYBE) { 2036 # Continued declaration purpose 2037 chomp($declaration_purpose); 2038 $declaration_purpose .= " " . $1; 2039 $declaration_purpose =~ s/\s+/ /g; 2040 } else { 2041 my $cont = $1; 2042 if ($section =~ m/^@/ || $section eq $section_context) { --- 135 unchanged lines hidden (view full) --- 2178 } 2179 # Replace tabs by spaces 2180 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; 2181 # Hand this line to the appropriate state handler 2182 if ($state == STATE_NORMAL) { 2183 process_normal(); 2184 } elsif ($state == STATE_NAME) { 2185 process_name($file, $_); |
2176 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { | 2186 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE || 2187 $state == STATE_BODY_WITH_BLANK_LINE) { |
2177 process_body($file, $_); 2178 } elsif ($state == STATE_INLINE) { # scanning for inline parameters 2179 process_inline($file, $_); 2180 } elsif ($state == STATE_PROTO) { 2181 process_proto($file, $_); 2182 } elsif ($state == STATE_DOCBLOCK) { 2183 process_docblock($file, $_); 2184 } --- 63 unchanged lines hidden --- | 2188 process_body($file, $_); 2189 } elsif ($state == STATE_INLINE) { # scanning for inline parameters 2190 process_inline($file, $_); 2191 } elsif ($state == STATE_PROTO) { 2192 process_proto($file, $_); 2193 } elsif ($state == STATE_DOCBLOCK) { 2194 process_docblock($file, $_); 2195 } --- 63 unchanged lines hidden --- |