Skip to content

Commit 9f6f4c1

Browse files
vegardJonathan Corbet
authored andcommitted
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: Vegard Nossum <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d3c55a7 commit 9f6f4c1

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

scripts/kernel-doc

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ sub output_function_rst(%) {
820820
my %args = %{$_[0]};
821821
my ($parameter, $section);
822822
my $oldprefix = $lineprefix;
823-
my $is_macro = 0;
824823

825824
my $signature = "";
826825
if ($args{'functiontype'} ne "") {
@@ -854,37 +853,30 @@ sub output_function_rst(%) {
854853
print " **Typedef**: ";
855854
$lineprefix = "";
856855
output_highlight_rst($args{'purpose'});
857-
print "\n\n**Syntax**\n\n ``";
858-
$is_macro = 1;
856+
print "\n\n**Syntax**\n\n";
857+
print " ``$signature``\n\n";
859858
} else {
860-
print ".. c:function:: ";
859+
print ".. c:function:: $signature\n\n";
861860
}
862861
} else {
863862
if ($args{'typedef'} || $args{'functiontype'} eq "") {
864-
$is_macro = 1;
865863
print ".. c:macro:: ". $args{'function'} . "\n\n";
866-
} else {
867-
print ".. c:function:: ";
868-
}
869864

870-
if ($args{'typedef'}) {
871-
print_lineno($declaration_start_line);
872-
print " **Typedef**: ";
873-
$lineprefix = "";
874-
output_highlight_rst($args{'purpose'});
875-
print "\n\n**Syntax**\n\n ``";
865+
if ($args{'typedef'}) {
866+
print_lineno($declaration_start_line);
867+
print " **Typedef**: ";
868+
$lineprefix = "";
869+
output_highlight_rst($args{'purpose'});
870+
print "\n\n**Syntax**\n\n";
871+
print " ``$signature``\n\n";
872+
} else {
873+
print "``$signature``\n\n";
874+
}
876875
} else {
877-
print "``" if ($is_macro);
876+
print ".. c:function:: $signature\n\n";
878877
}
879878
}
880879

881-
print $signature;
882-
883-
if ($is_macro) {
884-
print "``\n\n";
885-
} else {
886-
print "\n\n";
887-
}
888880
if (!$args{'typedef'}) {
889881
print_lineno($declaration_start_line);
890882
$lineprefix = " ";

0 commit comments

Comments
 (0)