Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbdI0Ohf (ORCPT ); Wed, 27 Sep 2017 10:37:35 -0400 Received: from mga05.intel.com ([192.55.52.43]:35230 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751245AbdI0Ohd (ORCPT ); Wed, 27 Sep 2017 10:37:33 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,445,1500966000"; d="scan'208";a="904409709" From: Jani Nikula To: Mauro Carvalho Chehab , Linux Media Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Linux Doc Mailing List , linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/10] scripts: kernel-doc: get rid of unused output formats In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: Date: Wed, 27 Sep 2017 17:36:59 +0300 Message-ID: <87vak46wdw.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 43675 Lines: 1325 On Tue, 26 Sep 2017, Mauro Carvalho Chehab wrote: > Since there isn't any docbook code anymore upstream, > we can get rid of several output formats: > > - docbook/xml, html, html5 and list formats were used by > the old build system; > - As ReST is text, there's not much sense on outputting > on a different text format. > > After this patch, only man and rst output formats are > supported. FWIW, Acked-by: Jani Nikula Please do keep at least two output formats going forward. Otherwise the mechanisms of having more than one output format will bitrot and get conflated into the one output format. > > Signed-off-by: Mauro Carvalho Chehab > --- > scripts/kernel-doc | 1182 +--------------------------------------------------- > 1 file changed, 4 insertions(+), 1178 deletions(-) > > diff --git a/scripts/kernel-doc b/scripts/kernel-doc > index 9d3eafea58f0..69757ee9db4c 100755 > --- a/scripts/kernel-doc > +++ b/scripts/kernel-doc > @@ -51,13 +51,8 @@ The documentation comments are identified by "/**" opening comment mark. See > Documentation/kernel-doc-nano-HOWTO.txt for the documentation comment syntax. > > Output format selection (mutually exclusive): > - -docbook Output DocBook format. > - -html Output HTML format. > - -html5 Output HTML5 format. > - -list Output symbol list format. This is for use by docproc. > -man Output troff manual page format. This is the default. > -rst Output reStructuredText format. > - -text Output plain text format. > > Output selection (mutually exclusive): > -export Only output documentation for symbols that have been > @@ -224,84 +219,11 @@ my $type_typedef = '\&(typedef\s*([_\w]+))'; > my $type_union = '\&(union\s*([_\w]+))'; > my $type_member = '\&([_\w]+)(\.|->)([_\w]+)'; > my $type_fallback = '\&([_\w]+)'; > -my $type_enum_xml = '\&(enum\s*([_\w]+))'; > -my $type_struct_xml = '\&(struct\s*([_\w]+))'; > -my $type_typedef_xml = '\&(typedef\s*([_\w]+))'; > -my $type_union_xml = '\&(union\s*([_\w]+))'; > -my $type_member_xml = '\&([_\w]+)(\.|-\>)([_\w]+)'; > -my $type_fallback_xml = '\&([_\w]+)'; > my $type_member_func = $type_member . '\(\)'; > > # Output conversion substitutions. > # One for each output format > > -# these work fairly well > -my @highlights_html = ( > - [$type_constant, "\$1"], > - [$type_constant2, "\$1"], > - [$type_func, "\$1"], > - [$type_enum_xml, "\$1"], > - [$type_struct_xml, "\$1"], > - [$type_typedef_xml, "\$1"], > - [$type_union_xml, "\$1"], > - [$type_env, "\$1"], > - [$type_param, "\$1"], > - [$type_member_xml, "\$1\$2\$3"], > - [$type_fallback_xml, "\$1"] > - ); > -my $local_lt = "\\\\\\\\lt:"; > -my $local_gt = "\\\\\\\\gt:"; > -my $blankline_html = $local_lt . "p" . $local_gt; # was "

" > - > -# html version 5 > -my @highlights_html5 = ( > - [$type_constant, "\$1"], > - [$type_constant2, "\$1"], > - [$type_func, "\$1"], > - [$type_enum_xml, "\$1"], > - [$type_struct_xml, "\$1"], > - [$type_typedef_xml, "\$1"], > - [$type_union_xml, "\$1"], > - [$type_env, "\$1"], > - [$type_param, "\$1]"], > - [$type_member_xml, "\$1\$2\$3"], > - [$type_fallback_xml, "\$1"] > - ); > -my $blankline_html5 = $local_lt . "br /" . $local_gt; > - > -# XML, docbook format > -my @highlights_xml = ( > - ["([^=])\\\"([^\\\"<]+)\\\"", "\$1\$2"], > - [$type_constant, "\$1"], > - [$type_constant2, "\$1"], > - [$type_enum_xml, "\$1"], > - [$type_struct_xml, "\$1"], > - [$type_typedef_xml, "\$1"], > - [$type_union_xml, "\$1"], > - [$type_param, "\$1"], > - [$type_func, "\$1"], > - [$type_env, "\$1"], > - [$type_member_xml, "\$1\$2\$3"], > - [$type_fallback_xml, "\$1"] > - ); > -my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; > - > -# gnome, docbook format > -my @highlights_gnome = ( > - [$type_constant, "\$1"], > - [$type_constant2, "\$1"], > - [$type_func, "\$1"], > - [$type_enum, "\$1"], > - [$type_struct, "\$1"], > - [$type_typedef, "\$1"], > - [$type_union, "\$1"], > - [$type_env, "\$1"], > - [$type_param, "\$1" ], > - [$type_member, "\$1\$2\$3"], > - [$type_fallback, "\$1"] > - ); > -my $blankline_gnome = "\n"; > - > # these are pretty rough > my @highlights_man = ( > [$type_constant, "\$1"], > @@ -317,21 +239,6 @@ my @highlights_man = ( > ); > my $blankline_man = ""; > > -# text-mode > -my @highlights_text = ( > - [$type_constant, "\$1"], > - [$type_constant2, "\$1"], > - [$type_func, "\$1"], > - [$type_enum, "\$1"], > - [$type_struct, "\$1"], > - [$type_typedef, "\$1"], > - [$type_union, "\$1"], > - [$type_param, "\$1"], > - [$type_member, "\$1\$2\$3"], > - [$type_fallback, "\$1"] > - ); > -my $blankline_text = ""; > - > # rst-mode > my @highlights_rst = ( > [$type_constant, "``\$1``"], > @@ -351,21 +258,6 @@ my @highlights_rst = ( > ); > my $blankline_rst = "\n"; > > -# list mode > -my @highlights_list = ( > - [$type_constant, "\$1"], > - [$type_constant2, "\$1"], > - [$type_func, "\$1"], > - [$type_enum, "\$1"], > - [$type_struct, "\$1"], > - [$type_typedef, "\$1"], > - [$type_union, "\$1"], > - [$type_param, "\$1"], > - [$type_member, "\$1"], > - [$type_fallback, "\$1"] > - ); > -my $blankline_list = ""; > - > # read arguments > if ($#ARGV == -1) { > usage(); > @@ -500,38 +392,14 @@ reset_state(); > > while ($ARGV[0] =~ m/^-(.*)/) { > my $cmd = shift @ARGV; > - if ($cmd eq "-html") { > - $output_mode = "html"; > - @highlights = @highlights_html; > - $blankline = $blankline_html; > - } elsif ($cmd eq "-html5") { > - $output_mode = "html5"; > - @highlights = @highlights_html5; > - $blankline = $blankline_html5; > - } elsif ($cmd eq "-man") { > + if ($cmd eq "-man") { > $output_mode = "man"; > @highlights = @highlights_man; > $blankline = $blankline_man; > - } elsif ($cmd eq "-text") { > - $output_mode = "text"; > - @highlights = @highlights_text; > - $blankline = $blankline_text; > } elsif ($cmd eq "-rst") { > $output_mode = "rst"; > @highlights = @highlights_rst; > $blankline = $blankline_rst; > - } elsif ($cmd eq "-docbook") { > - $output_mode = "xml"; > - @highlights = @highlights_xml; > - $blankline = $blankline_xml; > - } elsif ($cmd eq "-list") { > - $output_mode = "list"; > - @highlights = @highlights_list; > - $blankline = $blankline_list; > - } elsif ($cmd eq "-gnome") { > - $output_mode = "gnome"; > - @highlights = @highlights_gnome; > - $blankline = $blankline_gnome; > } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document > $modulename = shift @ARGV; > } elsif ($cmd eq "-function") { # to only output specific functions > @@ -667,22 +535,11 @@ sub output_highlight { > # confess "output_highlight got called with no args?\n"; > # } > > - if ($output_mode eq "html" || $output_mode eq "html5" || > - $output_mode eq "xml") { > - $contents = local_unescape($contents); > - # convert data read & converted thru xml_escape() into &xyz; format: > - $contents =~ s/\\\\\\/\&/g; > - } > # print STDERR "contents b4:$contents\n"; > eval $dohighlight; > die $@ if $@; > # print STDERR "contents af:$contents\n"; > > -# strip whitespaces when generating html5 > - if ($output_mode eq "html5") { > - $contents =~ s/^\s+//; > - $contents =~ s/\s+$//; > - } > foreach $line (split "\n", $contents) { > if (! $output_preformatted) { > $line =~ s/^\s*//; > @@ -703,817 +560,6 @@ sub output_highlight { > } > } > > -# output sections in html > -sub output_section_html(%) { > - my %args = %{$_[0]}; > - my $section; > - > - foreach $section (@{$args{'sectionlist'}}) { > - print "

$section

\n"; > - print "
\n"; > - output_highlight($args{'sections'}{$section}); > - print "
\n"; > - } > -} > - > -# output enum in html > -sub output_enum_html(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - my $count; > - print "

enum " . $args{'enum'} . "

\n"; > - > - print "enum " . $args{'enum'} . " {
\n"; > - $count = 0; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print " " . $parameter . ""; > - if ($count != $#{$args{'parameterlist'}}) { > - $count++; > - print ",\n"; > - } > - print "
"; > - } > - print "};
\n"; > - > - print "

Constants

\n"; > - print "
\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print "
" . $parameter . "\n"; > - print "
"; > - output_highlight($args{'parameterdescs'}{$parameter}); > - } > - print "
\n"; > - output_section_html(@_); > - print "
\n"; > -} > - > -# output typedef in html > -sub output_typedef_html(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - my $count; > - print "

typedef " . $args{'typedef'} . "

\n"; > - > - print "typedef " . $args{'typedef'} . "\n"; > - output_section_html(@_); > - print "
\n"; > -} > - > -# output struct in html > -sub output_struct_html(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - > - print "

" . $args{'type'} . " " . $args{'struct'} . " - " . $args{'purpose'} . "

\n"; > - print "" . $args{'type'} . " " . $args{'struct'} . " {
\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - if ($parameter =~ /^#/) { > - print "$parameter
\n"; > - next; > - } > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print "    $1$parameter) ($2);
\n"; > - } elsif ($type =~ m/^(.*?)\s*(:.*)/) { > - # bitfield > - print "    $1 $parameter$2;
\n"; > - } else { > - print "    $type $parameter;
\n"; > - } > - } > - print "};
\n"; > - > - print "

Members

\n"; > - print "
\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - ($parameter =~ /^#/) && next; > - > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - print "
" . $parameter . "\n"; > - print "
"; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - } > - print "
\n"; > - output_section_html(@_); > - print "
\n"; > -} > - > -# output function in html > -sub output_function_html(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - > - print "

" . $args{'function'} . " - " . $args{'purpose'} . "

\n"; > - print "" . $args{'functiontype'} . "\n"; > - print "" . $args{'function'} . "\n"; > - print "("; > - $count = 0; > - foreach $parameter (@{$args{'parameterlist'}}) { > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print "$1$parameter) ($2)"; > - } else { > - print "" . $type . " " . $parameter . ""; > - } > - if ($count != $#{$args{'parameterlist'}}) { > - $count++; > - print ",\n"; > - } > - } > - print ")\n"; > - > - print "

Arguments

\n"; > - print "
\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - print "
" . $parameter . "\n"; > - print "
"; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - } > - print "
\n"; > - output_section_html(@_); > - print "
\n"; > -} > - > -# output DOC: block header in html > -sub output_blockhead_html(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - > - foreach $section (@{$args{'sectionlist'}}) { > - print "

$section

\n"; > - print "
    \n"; > - output_highlight($args{'sections'}{$section}); > - print "
\n"; > - } > - print "
\n"; > -} > - > -# output sections in html5 > -sub output_section_html5(%) { > - my %args = %{$_[0]}; > - my $section; > - > - foreach $section (@{$args{'sectionlist'}}) { > - print "
\n"; > - print "

$section

\n"; > - print "

\n"; > - output_highlight($args{'sections'}{$section}); > - print "

\n"; > - print "
\n"; > - } > -} > - > -# output enum in html5 > -sub output_enum_html5(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - my $count; > - my $html5id; > - > - $html5id = $args{'enum'}; > - $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; > - print "
"; > - print "

enum " . $args{'enum'} . "

\n"; > - print "
    \n"; > - print "
  1. "; > - print "enum "; > - print "" . $args{'enum'} . " {"; > - print "
  2. \n"; > - $count = 0; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print "
  3. "; > - print "" . $parameter . ""; > - if ($count != $#{$args{'parameterlist'}}) { > - $count++; > - print ","; > - } > - print "
  4. \n"; > - } > - print "
  5. };
  6. \n"; > - print "
\n"; > - > - print "
\n"; > - print "

Constants

\n"; > - print "
\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print "
" . $parameter . "
\n"; > - print "
"; > - output_highlight($args{'parameterdescs'}{$parameter}); > - print "
\n"; > - } > - print "
\n"; > - print "
\n"; > - output_section_html5(@_); > - print "
\n"; > -} > - > -# output typedef in html5 > -sub output_typedef_html5(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - my $count; > - my $html5id; > - > - $html5id = $args{'typedef'}; > - $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; > - print "
\n"; > - print "

typedef " . $args{'typedef'} . "

\n"; > - > - print "
    \n"; > - print "
  1. "; > - print "typedef "; > - print "" . $args{'typedef'} . ""; > - print "
  2. \n"; > - print "
\n"; > - output_section_html5(@_); > - print "
\n"; > -} > - > -# output struct in html5 > -sub output_struct_html5(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - my $html5id; > - > - $html5id = $args{'struct'}; > - $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; > - print "
\n"; > - print "
\n"; > - print "

" . $args{'type'} . " " . $args{'struct'} . "

"; > - print "

". $args{'purpose'} . "

\n"; > - print "
\n"; > - print "
    \n"; > - print "
  1. "; > - print "" . $args{'type'} . " "; > - print "" . $args{'struct'} . " {"; > - print "
  2. \n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print "
  3. "; > - if ($parameter =~ /^#/) { > - print "" . $parameter ."\n"; > - print "
  4. \n"; > - next; > - } > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print "$1 "; > - print "$parameter"; > - print ") "; > - print "($2);"; > - } elsif ($type =~ m/^(.*?)\s*(:.*)/) { > - # bitfield > - print "$1 "; > - print "$parameter"; > - print "$2;"; > - } else { > - print "$type "; > - print "$parameter;"; > - } > - print "\n"; > - } > - print "
  5. };
  6. \n"; > - print "
\n"; > - > - print "
\n"; > - print "

Members

\n"; > - print "
\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - ($parameter =~ /^#/) && next; > - > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - print "
" . $parameter . "
\n"; > - print "
"; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - print "
\n"; > - } > - print "
\n"; > - print "
\n"; > - output_section_html5(@_); > - print "
\n"; > -} > - > -# output function in html5 > -sub output_function_html5(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - my $html5id; > - > - $html5id = $args{'function'}; > - $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; > - print "
\n"; > - print "
\n"; > - print "

" . $args{'function'} . "

"; > - print "

" . $args{'purpose'} . "

\n"; > - print "
\n"; > - print "
    \n"; > - print "
  1. "; > - print "" . $args{'functiontype'} . " "; > - print "" . $args{'function'} . " ("; > - print "
  2. "; > - $count = 0; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print "
  3. "; > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print "$1 "; > - print "$parameter"; > - print ") "; > - print "($2)"; > - } else { > - print "$type "; > - print "$parameter"; > - } > - if ($count != $#{$args{'parameterlist'}}) { > - $count++; > - print ","; > - } > - print "
  4. \n"; > - } > - print "
  5. )
  6. \n"; > - print "
\n"; > - > - print "
\n"; > - print "

Arguments

\n"; > - print "

\n"; > - print "

\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - print "
" . $parameter . "
\n"; > - print "
"; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - print "
\n"; > - } > - print "
\n"; > - print "
\n"; > - output_section_html5(@_); > - print "
\n"; > -} > - > -# output DOC: block header in html5 > -sub output_blockhead_html5(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - my $html5id; > - > - foreach $section (@{$args{'sectionlist'}}) { > - $html5id = $section; > - $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; > - print "
\n"; > - print "

$section

\n"; > - print "

\n"; > - output_highlight($args{'sections'}{$section}); > - print "

\n"; > - } > - print "
\n"; > -} > - > -sub output_section_xml(%) { > - my %args = %{$_[0]}; > - my $section; > - # print out each section > - $lineprefix=" "; > - foreach $section (@{$args{'sectionlist'}}) { > - print "\n"; > - print "$section\n"; > - if ($section =~ m/EXAMPLE/i) { > - print "\n"; > - $output_preformatted = 1; > - } else { > - print "\n"; > - } > - output_highlight($args{'sections'}{$section}); > - $output_preformatted = 0; > - if ($section =~ m/EXAMPLE/i) { > - print "\n"; > - } else { > - print "\n"; > - } > - print "\n"; > - } > -} > - > -# output function in XML DocBook > -sub output_function_xml(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - my $id; > - > - $id = "API-" . $args{'function'}; > - $id =~ s/[^A-Za-z0-9]/-/g; > - > - print "\n"; > - print "\n"; > - print " LINUX\n"; > - print " Kernel Hackers Manual\n"; > - print " $man_date\n"; > - print "\n"; > - print "\n"; > - print " " . $args{'function'} . "\n"; > - print " 9\n"; > - print " " . $kernelversion . "\n"; > - print "\n"; > - print "\n"; > - print " " . $args{'function'} . "\n"; > - print " \n"; > - print " "; > - output_highlight ($args{'purpose'}); > - print " \n"; > - print "\n"; > - > - print "\n"; > - print " Synopsis\n"; > - print " \n"; > - print " " . $args{'functiontype'} . " "; > - print "" . $args{'function'} . " \n"; > - > - $count = 0; > - if ($#{$args{'parameterlist'}} >= 0) { > - foreach $parameter (@{$args{'parameterlist'}}) { > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print " $1$parameter)\n"; > - print " $2\n"; > - } else { > - print " " . $type; > - print " $parameter\n"; > - } > - } > - } else { > - print " \n"; > - } > - print " \n"; > - print "\n"; > - > - # print parameters > - print "\n Arguments\n"; > - if ($#{$args{'parameterlist'}} >= 0) { > - print " \n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - $type = $args{'parametertypes'}{$parameter}; > - > - print " \n $type $parameter\n"; > - print " \n \n"; > - $lineprefix=" "; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - print " \n \n \n"; > - } > - print " \n"; > - } else { > - print " \n None\n \n"; > - } > - print "\n"; > - > - output_section_xml(@_); > - print "\n\n"; > -} > - > -# output struct in XML DocBook > -sub output_struct_xml(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $id; > - > - $id = "API-struct-" . $args{'struct'}; > - $id =~ s/[^A-Za-z0-9]/-/g; > - > - print "\n"; > - print "\n"; > - print " LINUX\n"; > - print " Kernel Hackers Manual\n"; > - print " $man_date\n"; > - print "\n"; > - print "\n"; > - print " " . $args{'type'} . " " . $args{'struct'} . "\n"; > - print " 9\n"; > - print " " . $kernelversion . "\n"; > - print "\n"; > - print "\n"; > - print " " . $args{'type'} . " " . $args{'struct'} . "\n"; > - print " \n"; > - print " "; > - output_highlight ($args{'purpose'}); > - print " \n"; > - print "\n"; > - > - print "\n"; > - print " Synopsis\n"; > - print " \n"; > - print $args{'type'} . " " . $args{'struct'} . " {\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - if ($parameter =~ /^#/) { > - my $prm = $parameter; > - # convert data read & converted thru xml_escape() into &xyz; format: > - # This allows us to have #define macros interspersed in a struct. > - $prm =~ s/\\\\\\/\&/g; > - print "$prm\n"; > - next; > - } > - > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - defined($args{'parameterdescs'}{$parameter_name}) || next; > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print " $1 $parameter) ($2);\n"; > - } elsif ($type =~ m/^(.*?)\s*(:.*)/) { > - # bitfield > - print " $1 $parameter$2;\n"; > - } else { > - print " " . $type . " " . $parameter . ";\n"; > - } > - } > - print "};"; > - print " \n"; > - print "\n"; > - > - print " \n"; > - print " Members\n"; > - > - if ($#{$args{'parameterlist'}} >= 0) { > - print " \n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - ($parameter =~ /^#/) && next; > - > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - defined($args{'parameterdescs'}{$parameter_name}) || next; > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - $type = $args{'parametertypes'}{$parameter}; > - print " "; > - print " $type $parameter\n"; > - print " \n"; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - print " \n"; > - print " \n"; > - } > - print " \n"; > - } else { > - print " \n None\n \n"; > - } > - print " \n"; > - > - output_section_xml(@_); > - > - print "\n\n"; > -} > - > -# output enum in XML DocBook > -sub output_enum_xml(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - my $id; > - > - $id = "API-enum-" . $args{'enum'}; > - $id =~ s/[^A-Za-z0-9]/-/g; > - > - print "\n"; > - print "\n"; > - print " LINUX\n"; > - print " Kernel Hackers Manual\n"; > - print " $man_date\n"; > - print "\n"; > - print "\n"; > - print " enum " . $args{'enum'} . "\n"; > - print " 9\n"; > - print " " . $kernelversion . "\n"; > - print "\n"; > - print "\n"; > - print " enum " . $args{'enum'} . "\n"; > - print " \n"; > - print " "; > - output_highlight ($args{'purpose'}); > - print " \n"; > - print "\n"; > - > - print "\n"; > - print " Synopsis\n"; > - print " \n"; > - print "enum " . $args{'enum'} . " {\n"; > - $count = 0; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print " $parameter"; > - if ($count != $#{$args{'parameterlist'}}) { > - $count++; > - print ","; > - } > - print "\n"; > - } > - print "};"; > - print " \n"; > - print "\n"; > - > - print "\n"; > - print " Constants\n"; > - print " \n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - print " "; > - print " $parameter\n"; > - print " \n"; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - print " \n"; > - print " \n"; > - } > - print " \n"; > - print "\n"; > - > - output_section_xml(@_); > - > - print "\n\n"; > -} > - > -# output typedef in XML DocBook > -sub output_typedef_xml(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $id; > - > - $id = "API-typedef-" . $args{'typedef'}; > - $id =~ s/[^A-Za-z0-9]/-/g; > - > - print "\n"; > - print "\n"; > - print " LINUX\n"; > - print " Kernel Hackers Manual\n"; > - print " $man_date\n"; > - print "\n"; > - print "\n"; > - print " typedef " . $args{'typedef'} . "\n"; > - print " 9\n"; > - print "\n"; > - print "\n"; > - print " typedef " . $args{'typedef'} . "\n"; > - print " \n"; > - print " "; > - output_highlight ($args{'purpose'}); > - print " \n"; > - print "\n"; > - > - print "\n"; > - print " Synopsis\n"; > - print " typedef " . $args{'typedef'} . ";\n"; > - print "\n"; > - > - output_section_xml(@_); > - > - print "\n\n"; > -} > - > -# output in XML DocBook > -sub output_blockhead_xml(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - > - my $id = $args{'module'}; > - $id =~ s/[^A-Za-z0-9]/-/g; > - > - # print out each section > - $lineprefix=" "; > - foreach $section (@{$args{'sectionlist'}}) { > - if (!$args{'content-only'}) { > - print "\n $section\n"; > - } > - if ($section =~ m/EXAMPLE/i) { > - print "\n"; > - $output_preformatted = 1; > - } else { > - print "\n"; > - } > - output_highlight($args{'sections'}{$section}); > - $output_preformatted = 0; > - if ($section =~ m/EXAMPLE/i) { > - print "\n"; > - } else { > - print ""; > - } > - if (!$args{'content-only'}) { > - print "\n\n"; > - } > - } > - > - print "\n\n"; > -} > - > -# output in XML DocBook > -sub output_function_gnome { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $count; > - my $id; > - > - $id = $args{'module'} . "-" . $args{'function'}; > - $id =~ s/[^A-Za-z0-9]/-/g; > - > - print "\n"; > - print " " . $args{'function'} . "\n"; > - > - print " \n"; > - print " " . $args{'functiontype'} . " "; > - print "" . $args{'function'} . " "; > - print "\n"; > - > - $count = 0; > - if ($#{$args{'parameterlist'}} >= 0) { > - foreach $parameter (@{$args{'parameterlist'}}) { > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print " $1 $parameter)\n"; > - print " $2\n"; > - } else { > - print " " . $type; > - print " $parameter\n"; > - } > - } > - } else { > - print " \n"; > - } > - print " \n"; > - if ($#{$args{'parameterlist'}} >= 0) { > - print " \n"; > - print "\n"; > - print "\n"; > - print "\n"; > - print "\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - print " $parameter\n"; > - print " \n"; > - $lineprefix=" "; > - output_highlight($args{'parameterdescs'}{$parameter_name}); > - print " \n"; > - } > - print " \n"; > - } else { > - print " \n None\n \n"; > - } > - > - # print out each section > - $lineprefix=" "; > - foreach $section (@{$args{'sectionlist'}}) { > - print "\n $section\n"; > - if ($section =~ m/EXAMPLE/i) { > - print "\n"; > - $output_preformatted = 1; > - } else { > - } > - print "\n"; > - output_highlight($args{'sections'}{$section}); > - $output_preformatted = 0; > - print "\n"; > - if ($section =~ m/EXAMPLE/i) { > - print "\n"; > - } else { > - } > - print " \n"; > - } > - > - print "\n\n"; > -} > - > ## > # output function in man > sub output_function_man(%) { > @@ -1692,161 +738,6 @@ sub output_blockhead_man(%) { > } > > ## > -# output in text > -sub output_function_text(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - my $start; > - > - print "Name:\n\n"; > - print $args{'function'} . " - " . $args{'purpose'} . "\n"; > - > - print "\nSynopsis:\n\n"; > - if ($args{'functiontype'} ne "") { > - $start = $args{'functiontype'} . " " . $args{'function'} . " ("; > - } else { > - $start = $args{'function'} . " ("; > - } > - print $start; > - > - my $count = 0; > - foreach my $parameter (@{$args{'parameterlist'}}) { > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print $1 . $parameter . ") (" . $2; > - } else { > - print $type . " " . $parameter; > - } > - if ($count != $#{$args{'parameterlist'}}) { > - $count++; > - print ",\n"; > - print " " x length($start); > - } else { > - print ");\n\n"; > - } > - } > - > - print "Arguments:\n\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - print $parameter . "\n\t" . $args{'parameterdescs'}{$parameter_name} . "\n"; > - } > - output_section_text(@_); > -} > - > -#output sections in text > -sub output_section_text(%) { > - my %args = %{$_[0]}; > - my $section; > - > - print "\n"; > - foreach $section (@{$args{'sectionlist'}}) { > - print "$section:\n\n"; > - output_highlight($args{'sections'}{$section}); > - } > - print "\n\n"; > -} > - > -# output enum in text > -sub output_enum_text(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - my $count; > - print "Enum:\n\n"; > - > - print "enum " . $args{'enum'} . " - " . $args{'purpose'} . "\n\n"; > - print "enum " . $args{'enum'} . " {\n"; > - $count = 0; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print "\t$parameter"; > - if ($count != $#{$args{'parameterlist'}}) { > - $count++; > - print ","; > - } > - print "\n"; > - } > - print "};\n\n"; > - > - print "Constants:\n\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - print "$parameter\n\t"; > - print $args{'parameterdescs'}{$parameter} . "\n"; > - } > - > - output_section_text(@_); > -} > - > -# output typedef in text > -sub output_typedef_text(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - my $count; > - print "Typedef:\n\n"; > - > - print "typedef " . $args{'typedef'} . " - " . $args{'purpose'} . "\n"; > - output_section_text(@_); > -} > - > -# output struct as text > -sub output_struct_text(%) { > - my %args = %{$_[0]}; > - my ($parameter); > - > - print $args{'type'} . " " . $args{'struct'} . " - " . $args{'purpose'} . "\n\n"; > - print $args{'type'} . " " . $args{'struct'} . " {\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - if ($parameter =~ /^#/) { > - print "$parameter\n"; > - next; > - } > - > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - $type = $args{'parametertypes'}{$parameter}; > - if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { > - # pointer-to-function > - print "\t$1 $parameter) ($2);\n"; > - } elsif ($type =~ m/^(.*?)\s*(:.*)/) { > - # bitfield > - print "\t$1 $parameter$2;\n"; > - } else { > - print "\t" . $type . " " . $parameter . ";\n"; > - } > - } > - print "};\n\n"; > - > - print "Members:\n\n"; > - foreach $parameter (@{$args{'parameterlist'}}) { > - ($parameter =~ /^#/) && next; > - > - my $parameter_name = $parameter; > - $parameter_name =~ s/\[.*//; > - > - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; > - print "$parameter\n\t"; > - print $args{'parameterdescs'}{$parameter_name} . "\n"; > - } > - print "\n"; > - output_section_text(@_); > -} > - > -sub output_blockhead_text(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - > - foreach $section (@{$args{'sectionlist'}}) { > - print " $section:\n"; > - print " -> "; > - output_highlight($args{'sections'}{$section}); > - } > -} > - > -## > # output in restructured text > # > > @@ -2080,43 +971,6 @@ sub output_struct_rst(%) { > output_section_rst(@_); > } > > - > -## list mode output functions > - > -sub output_function_list(%) { > - my %args = %{$_[0]}; > - > - print $args{'function'} . "\n"; > -} > - > -# output enum in list > -sub output_enum_list(%) { > - my %args = %{$_[0]}; > - print $args{'enum'} . "\n"; > -} > - > -# output typedef in list > -sub output_typedef_list(%) { > - my %args = %{$_[0]}; > - print $args{'typedef'} . "\n"; > -} > - > -# output struct as list > -sub output_struct_list(%) { > - my %args = %{$_[0]}; > - > - print $args{'struct'} . "\n"; > -} > - > -sub output_blockhead_list(%) { > - my %args = %{$_[0]}; > - my ($parameter, $section); > - > - foreach $section (@{$args{'sectionlist'}}) { > - print "DOC: $section\n"; > - } > -} > - > ## > # generic output function for all types (function, struct/union, typedef, enum); > # calls the generated, variable output_ function name based on > @@ -2795,7 +1649,7 @@ sub process_proto_type($$) { > # just before actual output; (this is done by local_unescape()) > sub xml_escape($) { > my $text = shift; > - if (($output_mode eq "text") || ($output_mode eq "man")) { > + if ($output_mode eq "man") { > return $text; > } > $text =~ s/\&/\\\\\\amp;/g; > @@ -2807,7 +1661,7 @@ sub xml_escape($) { > # xml_unescape: reverse the effects of xml_escape > sub xml_unescape($) { > my $text = shift; > - if (($output_mode eq "text") || ($output_mode eq "man")) { > + if ($output_mode eq "man") { > return $text; > } > $text =~ s/\\\\\\amp;/\&/g; > @@ -2820,7 +1674,7 @@ sub xml_unescape($) { > # local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) > sub local_unescape($) { > my $text = shift; > - if (($output_mode eq "text") || ($output_mode eq "man")) { > + if ($output_mode eq "man") { > return $text; > } > $text =~ s/\\\\\\\\lt:/ @@ -3140,34 +1994,6 @@ sub process_file($) { > if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) { > print STDERR " Was looking for '$_'.\n" for keys %function_table; > } > - if ($output_mode eq "xml") { > - # The template wants at least one RefEntry here; make one. > - print "\n"; > - print " \n"; > - print " \n"; > - print " ${orig_file}\n"; > - print " \n"; > - print " \n"; > - print " Document generation inconsistency\n"; > - print " \n"; > - print " \n"; > - print " \n"; > - print " \n"; > - print " Oops\n"; > - print " \n"; > - print " \n"; > - print " \n"; > - print " The template for this document tried to insert\n"; > - print " the structured comment from the file\n"; > - print " ${orig_file} at this point,\n"; > - print " but none was found.\n"; > - print " This dummy section is inserted to allow\n"; > - print " generation to continue.\n"; > - print " \n"; > - print " \n"; > - print " \n"; > - print "\n"; > - } > } > } -- Jani Nikula, Intel Open Source Technology Center