kernel-doc (07048d13136bc068efb20e1d3e372577c2ef6906) kernel-doc (3cac2bc41d1b4c51a1f31059bf65f4dc7cfb35f5)
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 ##

--- 1779 unchanged lines hidden (view full) ---

1788sub process_normal() {
1789 if (/$doc_start/o) {
1790 $state = STATE_NAME; # next line is always the function name
1791 $in_doc_sect = 0;
1792 $declaration_start_line = $. + 1;
1793 }
1794}
1795
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 ##

--- 1779 unchanged lines hidden (view full) ---

1788sub process_normal() {
1789 if (/$doc_start/o) {
1790 $state = STATE_NAME; # next line is always the function name
1791 $in_doc_sect = 0;
1792 $declaration_start_line = $. + 1;
1793 }
1794}
1795
1796#
1797# STATE_NAME: Looking for the "name - description" line
1798#
1799sub process_name($$) {
1800 my $file = shift;
1801 my $identifier;
1802 my $descr;
1796
1803
1804 if (/$doc_block/o) {
1805 $state = STATE_DOCBLOCK;
1806 $contents = "";
1807 $new_start_line = $. + 1;
1797
1808
1809 if ( $1 eq "" ) {
1810 $section = $section_intro;
1811 } else {
1812 $section = $1;
1813 }
1814 }
1815 elsif (/$doc_decl/o) {
1816 $identifier = $1;
1817 if (/\s*([\w\s]+?)\s*-/) {
1818 $identifier = $1;
1819 }
1820
1821 $state = STATE_BODY;
1822 # if there's no @param blocks need to set up default section
1823 # here
1824 $contents = "";
1825 $section = $section_default;
1826 $new_start_line = $. + 1;
1827 if (/-(.*)/) {
1828 # strip leading/trailing/multiple spaces
1829 $descr= $1;
1830 $descr =~ s/^\s*//;
1831 $descr =~ s/\s*$//;
1832 $descr =~ s/\s+/ /g;
1833 $declaration_purpose = $descr;
1834 $state = STATE_BODY_MAYBE;
1835 } else {
1836 $declaration_purpose = "";
1837 }
1838
1839 if (($declaration_purpose eq "") && $verbose) {
1840 print STDERR "${file}:$.: warning: missing initial short description on line:\n";
1841 print STDERR $_;
1842 ++$warnings;
1843 }
1844
1845 if ($identifier =~ m/^struct/) {
1846 $decl_type = 'struct';
1847 } elsif ($identifier =~ m/^union/) {
1848 $decl_type = 'union';
1849 } elsif ($identifier =~ m/^enum/) {
1850 $decl_type = 'enum';
1851 } elsif ($identifier =~ m/^typedef/) {
1852 $decl_type = 'typedef';
1853 } else {
1854 $decl_type = 'function';
1855 }
1856
1857 if ($verbose) {
1858 print STDERR "${file}:$.: info: Scanning doc for $identifier\n";
1859 }
1860 } else {
1861 print STDERR "${file}:$.: warning: Cannot understand $_ on line $.",
1862 " - I thought it was a doc line\n";
1863 ++$warnings;
1864 $state = STATE_NORMAL;
1865 }
1866}
1867
1798sub process_file($) {
1799 my $file;
1868sub process_file($) {
1869 my $file;
1800 my $identifier;
1801 my $func;
1870 my $func;
1802 my $descr;
1803 my $initial_section_counter = $section_counter;
1804 my ($orig_file) = @_;
1805 my $leading_space;
1806
1807 $file = map_filename($orig_file);
1808
1809 if (!open(IN,"<$file")) {
1810 print STDERR "Error: Cannot open file $file\n";

--- 7 unchanged lines hidden (view full) ---

1818 while (<IN>) {
1819 while (s/\\\s*$//) {
1820 $_ .= <IN>;
1821 }
1822 # Replace tabs by spaces
1823 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
1824 if ($state == STATE_NORMAL) {
1825 process_normal();
1871 my $initial_section_counter = $section_counter;
1872 my ($orig_file) = @_;
1873 my $leading_space;
1874
1875 $file = map_filename($orig_file);
1876
1877 if (!open(IN,"<$file")) {
1878 print STDERR "Error: Cannot open file $file\n";

--- 7 unchanged lines hidden (view full) ---

1886 while (<IN>) {
1887 while (s/\\\s*$//) {
1888 $_ .= <IN>;
1889 }
1890 # Replace tabs by spaces
1891 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
1892 if ($state == STATE_NORMAL) {
1893 process_normal();
1826 } elsif ($state == STATE_NAME) {# this line is the function name (always)
1827 if (/$doc_block/o) {
1828 $state = STATE_DOCBLOCK;
1829 $contents = "";
1830 $new_start_line = $. + 1;
1831
1832 if ( $1 eq "" ) {
1833 $section = $section_intro;
1834 } else {
1835 $section = $1;
1836 }
1837 }
1838 elsif (/$doc_decl/o) {
1839 $identifier = $1;
1840 if (/\s*([\w\s]+?)\s*-/) {
1841 $identifier = $1;
1842 }
1843
1844 $state = STATE_BODY;
1845 # if there's no @param blocks need to set up default section
1846 # here
1847 $contents = "";
1848 $section = $section_default;
1849 $new_start_line = $. + 1;
1850 if (/-(.*)/) {
1851 # strip leading/trailing/multiple spaces
1852 $descr= $1;
1853 $descr =~ s/^\s*//;
1854 $descr =~ s/\s*$//;
1855 $descr =~ s/\s+/ /g;
1856 $declaration_purpose = $descr;
1857 $state = STATE_BODY_MAYBE;
1858 } else {
1859 $declaration_purpose = "";
1860 }
1861
1862 if (($declaration_purpose eq "") && $verbose) {
1863 print STDERR "${file}:$.: warning: missing initial short description on line:\n";
1864 print STDERR $_;
1865 ++$warnings;
1866 }
1867
1868 if ($identifier =~ m/^struct/) {
1869 $decl_type = 'struct';
1870 } elsif ($identifier =~ m/^union/) {
1871 $decl_type = 'union';
1872 } elsif ($identifier =~ m/^enum/) {
1873 $decl_type = 'enum';
1874 } elsif ($identifier =~ m/^typedef/) {
1875 $decl_type = 'typedef';
1876 } else {
1877 $decl_type = 'function';
1878 }
1879
1880 if ($verbose) {
1881 print STDERR "${file}:$.: info: Scanning doc for $identifier\n";
1882 }
1883 } else {
1884 print STDERR "${file}:$.: warning: Cannot understand $_ on line $.",
1885 " - I thought it was a doc line\n";
1886 ++$warnings;
1887 $state = STATE_NORMAL;
1888 }
1894 } elsif ($state == STATE_NAME) {
1895 process_name($file, $_);
1889 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) {
1890 if (/$doc_sect/i) { # case insensitive for supported section names
1891 $newsection = $1;
1892 $newcontents = $2;
1893
1894 # map the supported section names to the canonical names
1895 if ($newsection =~ m/^description$/i) {
1896 $newsection = $section_default;

--- 225 unchanged lines hidden ---
1896 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) {
1897 if (/$doc_sect/i) { # case insensitive for supported section names
1898 $newsection = $1;
1899 $newcontents = $2;
1900
1901 # map the supported section names to the canonical names
1902 if ($newsection =~ m/^description$/i) {
1903 $newsection = $section_default;

--- 225 unchanged lines hidden ---