Skip to content

Commit

Permalink
scripts/kernel-doc: simplify signature printing
Browse files Browse the repository at this point in the history
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: Vegard Nossum <[email protected]>
Signed-off-by: Jonathan Corbet <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
vegard authored and Jonathan Corbet committed Feb 21, 2024
1 parent d3c55a7 commit 9f6f4c1
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions scripts/kernel-doc
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ sub output_function_rst(%) {
my %args = %{$_[0]};
my ($parameter, $section);
my $oldprefix = $lineprefix;
my $is_macro = 0;

my $signature = "";
if ($args{'functiontype'} ne "") {
Expand Down Expand Up @@ -854,37 +853,30 @@ sub output_function_rst(%) {
print " **Typedef**: ";
$lineprefix = "";
output_highlight_rst($args{'purpose'});
print "\n\n**Syntax**\n\n ``";
$is_macro = 1;
print "\n\n**Syntax**\n\n";
print " ``$signature``\n\n";
} else {
print ".. c:function:: ";
print ".. c:function:: $signature\n\n";
}
} else {
if ($args{'typedef'} || $args{'functiontype'} eq "") {
$is_macro = 1;
print ".. c:macro:: ". $args{'function'} . "\n\n";
} else {
print ".. c:function:: ";
}

if ($args{'typedef'}) {
print_lineno($declaration_start_line);
print " **Typedef**: ";
$lineprefix = "";
output_highlight_rst($args{'purpose'});
print "\n\n**Syntax**\n\n ``";
if ($args{'typedef'}) {
print_lineno($declaration_start_line);
print " **Typedef**: ";
$lineprefix = "";
output_highlight_rst($args{'purpose'});
print "\n\n**Syntax**\n\n";
print " ``$signature``\n\n";
} else {
print "``$signature``\n\n";
}
} 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'}) {
print_lineno($declaration_start_line);
$lineprefix = " ";
Expand Down

0 comments on commit 9f6f4c1

Please sign in to comment.