mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kernel-doc: Print preprocessor directives correctly.
@ 2004-11-03  0:09 Alexey Dobriyan
  2004-11-05 23:15 ` Sam Ravnborg
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2004-11-03  0:09 UTC (permalink / raw)
  To: sam; +Cc: linux-kernel

Against http://linux-sam.bkbits.net:8080/kbuild/

Print preprocessor directives (usually "#ifdef CONFIG_SOMETHING" and "#endif")
in structs definitions correctly (-text, -html, sgmldocs, htmldocs, pdfdocs,
mandocs).

Correctly means:
 - on the separate line
 - starting from column 0
 - not glued to the type of the next member
 - not breeding if members are separated by comma
 - not imitating pointers to functions ("#if defined(CONFIG_X)...")
 - not giving bogus warnings because of this imitation

Signed-off-by: Alexey Dobriyan <adobriyan@mail.ru>

--- a/scripts/kernel-doc	2004-11-02 00:31:13.000000000 +0000
+++ b/scripts/kernel-doc	2004-11-03 01:00:38.627241464 +0000
@@ -452,6 +452,10 @@ sub output_struct_html(%) {
     print "<h2>".$args{'type'}." ".$args{'struct'}."</h2>\n";
     print "<b>".$args{'type'}." ".$args{'struct'}."</b> {<br>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+	if ($parameter =~ /^#/) {
+		print "$parameter<br>\n";
+		next;
+	}
 	my $parameter_name = $parameter;
 	$parameter_name =~ s/\[.*//;
 
@@ -471,6 +475,8 @@ sub output_struct_html(%) {
     print "<h3>Members</h3>\n";
     print "<dl>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+	($parameter =~ /^#/) && next;
+
 	my $parameter_name = $parameter;
 	$parameter_name =~ s/\[.*//;
 
@@ -656,6 +662,11 @@ sub output_struct_sgml(%) {
     print "  <programlisting>\n";
     print $args{'type'}." ".$args{'struct'}." {\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+	if ($parameter =~ /^#/) {
+	    print "$parameter\n";
+	    next;
+	}
+
 	my $parameter_name = $parameter;
 	$parameter_name =~ s/\[.*//;
 
@@ -680,6 +691,8 @@ sub output_struct_sgml(%) {
 
     print "  <variablelist>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+      ($parameter =~ /^#/) && next;
+
       my $parameter_name = $parameter;
       $parameter_name =~ s/\[.*//;
 
@@ -995,14 +1008,17 @@ sub output_struct_man(%) {
     print $args{'type'}." ".$args{'struct'}." \\- ".$args{'purpose'}."\n";
 
     print ".SH SYNOPSIS\n";
-    print $args{'type'}." ".$args{'struct'}." {\n";
+    print $args{'type'}." ".$args{'struct'}." {\n.br\n";
 
     foreach my $parameter (@{$args{'parameterlist'}}) {
+	if ($parameter =~ /^#/) {
+	    print ".BI \"$parameter\"\n.br\n";
+	    next;
+	}
 	my $parameter_name = $parameter;
 	$parameter_name =~ s/\[.*//;
 
         ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
-	print "\n.br\n";
 	$type = $args{'parametertypes'}{$parameter};
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
@@ -1019,6 +1035,8 @@ sub output_struct_man(%) {
 
     print ".SH Arguments\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+	($parameter =~ /^#/) && next;
+
 	my $parameter_name = $parameter;
 	$parameter_name =~ s/\[.*//;
 
@@ -1159,6 +1177,11 @@ sub output_struct_text(%) {
     print $args{'type'}." ".$args{'struct'}.":\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/\[.*//;
 
@@ -1177,6 +1200,8 @@ sub output_struct_text(%) {
 
     print "Members:\n\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+	($parameter =~ /^#/) && next;
+
 	my $parameter_name = $parameter;
 	$parameter_name =~ s/\[.*//;
 
@@ -1353,7 +1378,12 @@ sub create_parameterlist($$$) {
 	$arg =~ s/\s*$//;
 	$arg =~ s/\s+/ /;
 
-	if ($arg =~ m/\(/) {
+	if ($arg =~ /^#/) {
+	    # Treat preprocessor directive as a typeless variable just to fill
+	    # corresponding data structures "correctly". Catch it later in
+	    # output_* subs.
+	    push_parameter($arg, "", $file);
+	} elsif ($arg =~ m/\(/) {
 	    # pointer-to-function
 	    $arg =~ tr/#/,/;
 	    $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
@@ -1571,6 +1601,10 @@ sub process_state3_type($$) { 
     $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
     $x =~ s@^\s+@@gos; # strip leading spaces
     $x =~ s@\s+$@@gos; # strip trailing spaces
+    if ($x =~ /^#/) {
+	# To distinguish preprocessor directive from regular declaration later.
+	$x .= ";";
+    }
 
     while (1) {
         if ( $x =~ /([^{};]*)([{};])(.*)/ ) {


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] kernel-doc: Print preprocessor directives correctly.
  2004-11-03  0:09 [PATCH] kernel-doc: Print preprocessor directives correctly Alexey Dobriyan
@ 2004-11-05 23:15 ` Sam Ravnborg
  0 siblings, 0 replies; 2+ messages in thread
From: Sam Ravnborg @ 2004-11-05 23:15 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: sam, linux-kernel

On Wed, Nov 03, 2004 at 03:09:21AM +0300, Alexey Dobriyan wrote:
> Against http://linux-sam.bkbits.net:8080/kbuild/
> 
> Print preprocessor directives (usually "#ifdef CONFIG_SOMETHING" and "#endif")
> in structs definitions correctly (-text, -html, sgmldocs, htmldocs, pdfdocs,
> mandocs).

Applied.
PS. You need to re-clone my tree for futher changes - but usually on top
of Linus' latest is fine.

	Sam

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-05 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-03  0:09 [PATCH] kernel-doc: Print preprocessor directives correctly Alexey Dobriyan
2004-11-05 23:15 ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®