@@ -54,13 +54,13 @@ use strict;
5454# Set output format using one of -docbook -html -text or -man. Default is man.
5555#
5656# -function funcname
57- # If set, then only generate documentation for the given function(s). All
58- # other functions are ignored.
57+ # If set, then only generate documentation for the given function(s) or
58+ # DOC: section titles. All other functions and DOC: sections are ignored.
5959#
6060# -nofunction funcname
61- # If set, then only generate documentation for the other function(s).
62- # Cannot be used together with -function
63- # (yes, that's a bug -- perl hackers can fix it 8))
61+ # If set, then only generate documentation for the other function(s)/DOC:
62+ # sections. Cannot be used together with -function (yes, that's a bug --
63+ # perl hackers can fix it 8))
6464#
6565# c files - list of 'c' files to process
6666#
@@ -373,6 +373,25 @@ sub dump_section {
373373 }
374374}
375375
376+ # #
377+ # dump DOC: section after checking that it should go out
378+ #
379+ sub 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+
376395# #
377396# output function
378397#
@@ -564,8 +583,8 @@ sub output_function_html(%) {
564583 print " <hr>\n " ;
565584}
566585
567- # output intro in html
568- sub output_intro_html (%) {
586+ # output DOC: block header in html
587+ sub output_blockhead_html (%) {
569588 my %args = %{$_ [0]};
570589 my ($parameter , $section );
571590 my $count ;
@@ -871,7 +890,7 @@ sub output_typedef_xml(%) {
871890}
872891
873892# output in XML DocBook
874- sub output_intro_xml (%) {
893+ sub output_blockhead_xml (%) {
875894 my %args = %{$_ [0]};
876895 my ($parameter , $section );
877896 my $count ;
@@ -882,15 +901,23 @@ sub output_intro_xml(%) {
882901 # print out each section
883902 $lineprefix =" " ;
884903 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+ }
886907 if ($section =~ m / EXAMPLE/ i ) {
887908 print " <example><para>\n " ;
909+ } else {
910+ print " <para>\n " ;
888911 }
889912 output_highlight($args {' sections' }{$section });
890913 if ($section =~ m / EXAMPLE/ i ) {
891914 print " </para></example>\n " ;
915+ } else {
916+ print " </para>" ;
917+ }
918+ if (!$args {' content-only' }) {
919+ print " \n </refsect1>\n " ;
892920 }
893- print " </para>\n </refsect1>\n " ;
894921 }
895922
896923 print " \n\n " ;
@@ -1137,7 +1164,7 @@ sub output_typedef_man(%) {
11371164 }
11381165}
11391166
1140- sub output_intro_man (%) {
1167+ sub output_blockhead_man (%) {
11411168 my %args = %{$_ [0]};
11421169 my ($parameter , $section );
11431170 my $count ;
@@ -1294,7 +1321,7 @@ sub output_struct_text(%) {
12941321 output_section_text(@_ );
12951322}
12961323
1297- sub output_intro_text (%) {
1324+ sub output_blockhead_text (%) {
12981325 my %args = %{$_ [0]};
12991326 my ($parameter , $section );
13001327
@@ -1325,9 +1352,9 @@ sub output_declaration {
13251352
13261353# #
13271354# generic output function - calls the right one based on current output mode.
1328- sub output_intro {
1355+ sub output_blockhead {
13291356 no strict ' refs' ;
1330- my $func = " output_intro_ " .$output_mode ;
1357+ my $func = " output_blockhead_ " .$output_mode ;
13311358 &$func (@_ );
13321359 $section_counter ++;
13331360}
@@ -1926,9 +1953,7 @@ sub process_file($) {
19261953 } elsif ($state == 4) {
19271954 # Documentation block
19281955 if (/ $doc_block / ) {
1929- dump_section($section , xml_escape($contents ));
1930- output_intro({' sectionlist' => \@sectionlist ,
1931- ' sections' => \%sections });
1956+ dump_doc_section($section , xml_escape($contents ));
19321957 $contents = " " ;
19331958 $function = " " ;
19341959 %constants = ();
@@ -1946,9 +1971,7 @@ sub process_file($) {
19461971 }
19471972 elsif (/ $doc_end / )
19481973 {
1949- dump_section($section , xml_escape($contents ));
1950- output_intro({' sectionlist' => \@sectionlist ,
1951- ' sections' => \%sections });
1974+ dump_doc_section($section , xml_escape($contents ));
19521975 $contents = " " ;
19531976 $function = " " ;
19541977 %constants = ();
0 commit comments