Commit 9f6f4c11 authored by Vegard Nossum's avatar Vegard Nossum Committed by Jonathan Corbet

scripts/kernel-doc: simplify signature printing

Untangle some of the $is_macro logic and the nested conditionals.

This makes it easier to see where and how the signature is actually
printed.

No functional change.
Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20240215134828.1277109-5-vegard.nossum@oracle.com
parent d3c55a71
...@@ -820,7 +820,6 @@ sub output_function_rst(%) { ...@@ -820,7 +820,6 @@ sub output_function_rst(%) {
my %args = %{$_[0]}; my %args = %{$_[0]};
my ($parameter, $section); my ($parameter, $section);
my $oldprefix = $lineprefix; my $oldprefix = $lineprefix;
my $is_macro = 0;
my $signature = ""; my $signature = "";
if ($args{'functiontype'} ne "") { if ($args{'functiontype'} ne "") {
...@@ -854,37 +853,30 @@ sub output_function_rst(%) { ...@@ -854,37 +853,30 @@ sub output_function_rst(%) {
print " **Typedef**: "; print " **Typedef**: ";
$lineprefix = ""; $lineprefix = "";
output_highlight_rst($args{'purpose'}); output_highlight_rst($args{'purpose'});
print "\n\n**Syntax**\n\n ``"; print "\n\n**Syntax**\n\n";
$is_macro = 1; print " ``$signature``\n\n";
} else { } else {
print ".. c:function:: "; print ".. c:function:: $signature\n\n";
} }
} else { } else {
if ($args{'typedef'} || $args{'functiontype'} eq "") { if ($args{'typedef'} || $args{'functiontype'} eq "") {
$is_macro = 1;
print ".. c:macro:: ". $args{'function'} . "\n\n"; print ".. c:macro:: ". $args{'function'} . "\n\n";
} else {
print ".. c:function:: ";
}
if ($args{'typedef'}) { if ($args{'typedef'}) {
print_lineno($declaration_start_line); print_lineno($declaration_start_line);
print " **Typedef**: "; print " **Typedef**: ";
$lineprefix = ""; $lineprefix = "";
output_highlight_rst($args{'purpose'}); output_highlight_rst($args{'purpose'});
print "\n\n**Syntax**\n\n ``"; print "\n\n**Syntax**\n\n";
print " ``$signature``\n\n";
} else {
print "``$signature``\n\n";
}
} else { } else {
print "``" if ($is_macro); print ".. c:function:: $signature\n\n";
} }
} }
print $signature;
if ($is_macro) {
print "``\n\n";
} else {
print "\n\n";
}
if (!$args{'typedef'}) { if (!$args{'typedef'}) {
print_lineno($declaration_start_line); print_lineno($declaration_start_line);
$lineprefix = " "; $lineprefix = " ";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment