kernel-doc (0bba924ce99aadf8dcd316b8bf8b98902925ea8a) | kernel-doc (17b787171e693778eb9246978ad6116e52fa692c) |
---|---|
1#!/usr/bin/env perl 2 3use warnings; 4use strict; 5 6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 8## Copyright (C) 2001 Simon Huggins ## --- 314 unchanged lines hidden (view full) --- 323my $section_counter = 0; 324 325my $lineprefix=""; 326 327# Parser states 328use constant { 329 STATE_NORMAL => 0, # normal code 330 STATE_NAME => 1, # looking for function name | 1#!/usr/bin/env perl 2 3use warnings; 4use strict; 5 6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 8## Copyright (C) 2001 Simon Huggins ## --- 314 unchanged lines hidden (view full) --- 323my $section_counter = 0; 324 325my $lineprefix=""; 326 327# Parser states 328use constant { 329 STATE_NORMAL => 0, # normal code 330 STATE_NAME => 1, # looking for function name |
331 STATE_FIELD => 2, # scanning field start 332 STATE_PROTO => 3, # scanning prototype 333 STATE_DOCBLOCK => 4, # documentation block 334 STATE_INLINE => 5, # gathering documentation outside main block | 331 STATE_BODY_MAYBE => 2, # body - or maybe more description 332 STATE_BODY => 3, # the body of the comment 333 STATE_PROTO => 4, # scanning prototype 334 STATE_DOCBLOCK => 5, # documentation block 335 STATE_INLINE => 6, # gathering documentation outside main block |
335}; 336my $state; 337my $in_doc_sect; 338 339# Inline documentation state 340use constant { 341 STATE_INLINE_NA => 0, # not applicable ($state != STATE_INLINE) 342 STATE_INLINE_NAME => 1, # looking for member name (@foo:) --- 1436 unchanged lines hidden (view full) --- 1779 close(IN); 1780} 1781 1782sub process_file($) { 1783 my $file; 1784 my $identifier; 1785 my $func; 1786 my $descr; | 336}; 337my $state; 338my $in_doc_sect; 339 340# Inline documentation state 341use constant { 342 STATE_INLINE_NA => 0, # not applicable ($state != STATE_INLINE) 343 STATE_INLINE_NAME => 1, # looking for member name (@foo:) --- 1436 unchanged lines hidden (view full) --- 1780 close(IN); 1781} 1782 1783sub process_file($) { 1784 my $file; 1785 my $identifier; 1786 my $func; 1787 my $descr; |
1787 my $in_purpose = 0; | |
1788 my $initial_section_counter = $section_counter; 1789 my ($orig_file) = @_; 1790 my $leading_space; 1791 1792 $file = map_filename($orig_file); 1793 1794 if (!open(IN,"<$file")) { 1795 print STDERR "Error: Cannot open file $file\n"; --- 29 unchanged lines hidden (view full) --- 1825 } 1826 } 1827 elsif (/$doc_decl/o) { 1828 $identifier = $1; 1829 if (/\s*([\w\s]+?)\s*-/) { 1830 $identifier = $1; 1831 } 1832 | 1788 my $initial_section_counter = $section_counter; 1789 my ($orig_file) = @_; 1790 my $leading_space; 1791 1792 $file = map_filename($orig_file); 1793 1794 if (!open(IN,"<$file")) { 1795 print STDERR "Error: Cannot open file $file\n"; --- 29 unchanged lines hidden (view full) --- 1825 } 1826 } 1827 elsif (/$doc_decl/o) { 1828 $identifier = $1; 1829 if (/\s*([\w\s]+?)\s*-/) { 1830 $identifier = $1; 1831 } 1832 |
1833 $state = STATE_FIELD; | 1833 $state = STATE_BODY; |
1834 # if there's no @param blocks need to set up default section 1835 # here 1836 $contents = ""; 1837 $section = $section_default; 1838 $new_start_line = $. + 1; 1839 if (/-(.*)/) { 1840 # strip leading/trailing/multiple spaces 1841 $descr= $1; 1842 $descr =~ s/^\s*//; 1843 $descr =~ s/\s*$//; 1844 $descr =~ s/\s+/ /g; 1845 $declaration_purpose = $descr; | 1834 # if there's no @param blocks need to set up default section 1835 # here 1836 $contents = ""; 1837 $section = $section_default; 1838 $new_start_line = $. + 1; 1839 if (/-(.*)/) { 1840 # strip leading/trailing/multiple spaces 1841 $descr= $1; 1842 $descr =~ s/^\s*//; 1843 $descr =~ s/\s*$//; 1844 $descr =~ s/\s+/ /g; 1845 $declaration_purpose = $descr; |
1846 $in_purpose = 1; | 1846 $state = STATE_BODY_MAYBE; |
1847 } else { 1848 $declaration_purpose = ""; 1849 } 1850 1851 if (($declaration_purpose eq "") && $verbose) { 1852 print STDERR "${file}:$.: warning: missing initial short description on line:\n"; 1853 print STDERR $_; 1854 ++$warnings; --- 15 unchanged lines hidden (view full) --- 1870 print STDERR "${file}:$.: info: Scanning doc for $identifier\n"; 1871 } 1872 } else { 1873 print STDERR "${file}:$.: warning: Cannot understand $_ on line $.", 1874 " - I thought it was a doc line\n"; 1875 ++$warnings; 1876 $state = STATE_NORMAL; 1877 } | 1847 } else { 1848 $declaration_purpose = ""; 1849 } 1850 1851 if (($declaration_purpose eq "") && $verbose) { 1852 print STDERR "${file}:$.: warning: missing initial short description on line:\n"; 1853 print STDERR $_; 1854 ++$warnings; --- 15 unchanged lines hidden (view full) --- 1870 print STDERR "${file}:$.: info: Scanning doc for $identifier\n"; 1871 } 1872 } else { 1873 print STDERR "${file}:$.: warning: Cannot understand $_ on line $.", 1874 " - I thought it was a doc line\n"; 1875 ++$warnings; 1876 $state = STATE_NORMAL; 1877 } |
1878 } elsif ($state == STATE_FIELD) { # look for head: lines, and include content | 1878 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { |
1879 if (/$doc_sect/i) { # case insensitive for supported section names 1880 $newsection = $1; 1881 $newcontents = $2; 1882 1883 # map the supported section names to the canonical names 1884 if ($newsection =~ m/^description$/i) { 1885 $newsection = $section_default; 1886 } elsif ($newsection =~ m/^context$/i) { --- 10 unchanged lines hidden (view full) --- 1897 print STDERR "${file}:$.: warning: contents before sections\n"; 1898 ++$warnings; 1899 } 1900 dump_section($file, $section, $contents); 1901 $section = $section_default; 1902 } 1903 1904 $in_doc_sect = 1; | 1879 if (/$doc_sect/i) { # case insensitive for supported section names 1880 $newsection = $1; 1881 $newcontents = $2; 1882 1883 # map the supported section names to the canonical names 1884 if ($newsection =~ m/^description$/i) { 1885 $newsection = $section_default; 1886 } elsif ($newsection =~ m/^context$/i) { --- 10 unchanged lines hidden (view full) --- 1897 print STDERR "${file}:$.: warning: contents before sections\n"; 1898 ++$warnings; 1899 } 1900 dump_section($file, $section, $contents); 1901 $section = $section_default; 1902 } 1903 1904 $in_doc_sect = 1; |
1905 $in_purpose = 0; | 1905 $state = STATE_BODY; |
1906 $contents = $newcontents; 1907 $new_start_line = $.; 1908 while (substr($contents, 0, 1) eq " ") { 1909 $contents = substr($contents, 1); 1910 } 1911 if ($contents ne "") { 1912 $contents .= "\n"; 1913 } --- 22 unchanged lines hidden (view full) --- 1936 if ($section =~ m/^@/ || $section eq $section_context) { 1937 dump_section($file, $section, $contents); 1938 $section = $section_default; 1939 $contents = ""; 1940 $new_start_line = $.; 1941 } else { 1942 $contents .= "\n"; 1943 } | 1906 $contents = $newcontents; 1907 $new_start_line = $.; 1908 while (substr($contents, 0, 1) eq " ") { 1909 $contents = substr($contents, 1); 1910 } 1911 if ($contents ne "") { 1912 $contents .= "\n"; 1913 } --- 22 unchanged lines hidden (view full) --- 1936 if ($section =~ m/^@/ || $section eq $section_context) { 1937 dump_section($file, $section, $contents); 1938 $section = $section_default; 1939 $contents = ""; 1940 $new_start_line = $.; 1941 } else { 1942 $contents .= "\n"; 1943 } |
1944 $in_purpose = 0; 1945 } elsif ($in_purpose == 1) { | 1944 $state = STATE_BODY; 1945 } elsif ($state == STATE_BODY_MAYBE) { |
1946 # Continued declaration purpose 1947 chomp($declaration_purpose); 1948 $declaration_purpose .= " " . $1; 1949 $declaration_purpose =~ s/\s+/ /g; 1950 } else { 1951 my $cont = $1; 1952 if ($section =~ m/^@/ || $section eq $section_context) { 1953 if (!defined $leading_space) { --- 157 unchanged lines hidden --- | 1946 # Continued declaration purpose 1947 chomp($declaration_purpose); 1948 $declaration_purpose .= " " . $1; 1949 $declaration_purpose =~ s/\s+/ /g; 1950 } else { 1951 my $cont = $1; 1952 if ($section =~ m/^@/ || $section eq $section_context) { 1953 if (!defined $leading_space) { --- 157 unchanged lines hidden --- |