Skip to content

Commit d3c55a7

Browse files
vegardJonathan Corbet
authored andcommitted
scripts/kernel-doc: separate out function signature
Format the entire function signature and place it in a separate variable; this both makes it easier to understand what these lines of code are doing and will allow us to simplify the code further in the following patch. No functional change. Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/20240215134828.1277109-4-vegard.nossum@oracle.com
1 parent e8ebb85 commit d3c55a7

1 file changed

Lines changed: 28 additions & 21 deletions

File tree

scripts/kernel-doc

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,31 @@ sub output_function_rst(%) {
822822
my $oldprefix = $lineprefix;
823823
my $is_macro = 0;
824824

825+
my $signature = "";
826+
if ($args{'functiontype'} ne "") {
827+
$signature = $args{'functiontype'} . " " . $args{'function'} . " (";
828+
} else {
829+
$signature = $args{'function'} . " (";
830+
}
831+
832+
my $count = 0;
833+
foreach my $parameter (@{$args{'parameterlist'}}) {
834+
if ($count ne 0) {
835+
$signature .= ", ";
836+
}
837+
$count++;
838+
$type = $args{'parametertypes'}{$parameter};
839+
840+
if ($type =~ m/$function_pointer/) {
841+
# pointer-to-function
842+
$signature .= $1 . $parameter . ") (" . $2 . ")";
843+
} else {
844+
$signature .= $type;
845+
}
846+
}
847+
848+
$signature .= ")";
849+
825850
if ($sphinx_major < 3) {
826851
if ($args{'typedef'}) {
827852
print ".. c:type:: ". $args{'function'} . "\n\n";
@@ -852,31 +877,13 @@ sub output_function_rst(%) {
852877
print "``" if ($is_macro);
853878
}
854879
}
855-
if ($args{'functiontype'} ne "") {
856-
print $args{'functiontype'} . " " . $args{'function'} . " (";
857-
} else {
858-
print $args{'function'} . " (";
859-
}
860880

861-
my $count = 0;
862-
foreach my $parameter (@{$args{'parameterlist'}}) {
863-
if ($count ne 0) {
864-
print ", ";
865-
}
866-
$count++;
867-
$type = $args{'parametertypes'}{$parameter};
881+
print $signature;
868882

869-
if ($type =~ m/$function_pointer/) {
870-
# pointer-to-function
871-
print $1 . $parameter . ") (" . $2 . ")";
872-
} else {
873-
print $type;
874-
}
875-
}
876883
if ($is_macro) {
877-
print ")``\n\n";
884+
print "``\n\n";
878885
} else {
879-
print ")\n\n";
886+
print "\n\n";
880887
}
881888
if (!$args{'typedef'}) {
882889
print_lineno($declaration_start_line);

0 commit comments

Comments
 (0)