aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-10-24 18:08:48 -0400
committerSam Ravnborg <sam@ravnborg.org>2008-01-28 17:14:35 -0500
commitb112e0f73fe8e9e69e60bc9d6d16217795259c3c (patch)
treecbf68c1d7788f952ebed3601f645d5557c977a73
parent1b9bc22d71c75d4145688428c92c5123bd8697e3 (diff)
kernel-doc: single DOC: selection
Currently, DOC: sections are always output even if only a single function is requested, fix this and also make it possible to just output a single DOC: section by giving its title as the function name to output. Also fixes docbook XML well-formedness for sections with examples. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
-rwxr-xr-xscripts/kernel-doc63
1 files changed, 43 insertions, 20 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 8cf528b5e65a..8255f723b7e8 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -54,13 +54,13 @@ use strict;
54# Set output format using one of -docbook -html -text or -man. Default is man. 54# Set output format using one of -docbook -html -text or -man. Default is man.
55# 55#
56# -function funcname 56# -function funcname
57# If set, then only generate documentation for the given function(s). All 57# If set, then only generate documentation for the given function(s) or
58# other functions are ignored. 58# DOC: section titles. All other functions and DOC: sections are ignored.
59# 59#
60# -nofunction funcname 60# -nofunction funcname
61# If set, then only generate documentation for the other function(s). 61# If set, then only generate documentation for the other function(s)/DOC:
62# Cannot be used together with -function 62# sections. Cannot be used together with -function (yes, that's a bug --
63# (yes, that's a bug -- perl hackers can fix it 8)) 63# perl hackers can fix it 8))
64# 64#
65# c files - list of 'c' files to process 65# c files - list of 'c' files to process
66# 66#
@@ -374,6 +374,25 @@ sub dump_section {
374} 374}
375 375
376## 376##
377# dump DOC: section after checking that it should go out
378#
379sub dump_doc_section {
380 my $name = shift;
381 my $contents = join "\n", @_;
382
383 if (($function_only == 0) ||
384 ( $function_only == 1 && defined($function_table{$name})) ||
385 ( $function_only == 2 && !defined($function_table{$name})))
386 {
387 dump_section $name, $contents;
388 output_blockhead({'sectionlist' => \@sectionlist,
389 'sections' => \%sections,
390 'module' => $modulename,
391 'content-only' => ($function_only != 0), });
392 }
393}
394
395##
377# output function 396# output function
378# 397#
379# parameterdescs, a hash. 398# parameterdescs, a hash.
@@ -564,8 +583,8 @@ sub output_function_html(%) {
564 print "<hr>\n"; 583 print "<hr>\n";
565} 584}
566 585
567# output intro in html 586# output DOC: block header in html
568sub output_intro_html(%) { 587sub output_blockhead_html(%) {
569 my %args = %{$_[0]}; 588 my %args = %{$_[0]};
570 my ($parameter, $section); 589 my ($parameter, $section);
571 my $count; 590 my $count;
@@ -871,7 +890,7 @@ sub output_typedef_xml(%) {
871} 890}
872 891
873# output in XML DocBook 892# output in XML DocBook
874sub output_intro_xml(%) { 893sub output_blockhead_xml(%) {
875 my %args = %{$_[0]}; 894 my %args = %{$_[0]};
876 my ($parameter, $section); 895 my ($parameter, $section);
877 my $count; 896 my $count;
@@ -882,15 +901,23 @@ sub output_intro_xml(%) {
882 # print out each section 901 # print out each section
883 $lineprefix=" "; 902 $lineprefix=" ";
884 foreach $section (@{$args{'sectionlist'}}) { 903 foreach $section (@{$args{'sectionlist'}}) {
885 print "<refsect1>\n <title>$section</title>\n <para>\n"; 904 if (!$args{'content-only'}) {
905 print "<refsect1>\n <title>$section</title>\n";
906 }
886 if ($section =~ m/EXAMPLE/i) { 907 if ($section =~ m/EXAMPLE/i) {
887 print "<example><para>\n"; 908 print "<example><para>\n";
909 } else {
910 print "<para>\n";
888 } 911 }
889 output_highlight($args{'sections'}{$section}); 912 output_highlight($args{'sections'}{$section});
890 if ($section =~ m/EXAMPLE/i) { 913 if ($section =~ m/EXAMPLE/i) {
891 print "</para></example>\n"; 914 print "</para></example>\n";
915 } else {
916 print "</para>";
917 }
918 if (!$args{'content-only'}) {
919 print "\n</refsect1>\n";
892 } 920 }
893 print " </para>\n</refsect1>\n";
894 } 921 }
895 922
896 print "\n\n"; 923 print "\n\n";
@@ -1137,7 +1164,7 @@ sub output_typedef_man(%) {
1137 } 1164 }
1138} 1165}
1139 1166
1140sub output_intro_man(%) { 1167sub output_blockhead_man(%) {
1141 my %args = %{$_[0]}; 1168 my %args = %{$_[0]};
1142 my ($parameter, $section); 1169 my ($parameter, $section);
1143 my $count; 1170 my $count;
@@ -1294,7 +1321,7 @@ sub output_struct_text(%) {
1294 output_section_text(@_); 1321 output_section_text(@_);
1295} 1322}
1296 1323
1297sub output_intro_text(%) { 1324sub output_blockhead_text(%) {
1298 my %args = %{$_[0]}; 1325 my %args = %{$_[0]};
1299 my ($parameter, $section); 1326 my ($parameter, $section);
1300 1327
@@ -1325,9 +1352,9 @@ sub output_declaration {
1325 1352
1326## 1353##
1327# generic output function - calls the right one based on current output mode. 1354# generic output function - calls the right one based on current output mode.
1328sub output_intro { 1355sub output_blockhead {
1329 no strict 'refs'; 1356 no strict 'refs';
1330 my $func = "output_intro_".$output_mode; 1357 my $func = "output_blockhead_".$output_mode;
1331 &$func(@_); 1358 &$func(@_);
1332 $section_counter++; 1359 $section_counter++;
1333} 1360}
@@ -1926,9 +1953,7 @@ sub process_file($) {
1926 } elsif ($state == 4) { 1953 } elsif ($state == 4) {
1927 # Documentation block 1954 # Documentation block
1928 if (/$doc_block/) { 1955 if (/$doc_block/) {
1929 dump_section($section, xml_escape($contents)); 1956 dump_doc_section($section, xml_escape($contents));
1930 output_intro({'sectionlist' => \@sectionlist,
1931 'sections' => \%sections });
1932 $contents = ""; 1957 $contents = "";
1933 $function = ""; 1958 $function = "";
1934 %constants = (); 1959 %constants = ();
@@ -1946,9 +1971,7 @@ sub process_file($) {
1946 } 1971 }
1947 elsif (/$doc_end/) 1972 elsif (/$doc_end/)
1948 { 1973 {
1949 dump_section($section, xml_escape($contents)); 1974 dump_doc_section($section, xml_escape($contents));
1950 output_intro({'sectionlist' => \@sectionlist,
1951 'sections' => \%sections });
1952 $contents = ""; 1975 $contents = "";
1953 $function = ""; 1976 $function = "";
1954 %constants = (); 1977 %constants = ();