Skip to content

Commit 6e9e415

Browse files
committed
scripts: kernel-doc: try to use c:function if possible
There are a few namespace clashes by using c:macro everywhere: basically, when using it, we can't have something like: .. c:struct:: pwm_capture .. c:macro:: pwm_capture So, we need to use, instead: .. c:function:: int pwm_capture (struct pwm_device * pwm, struct pwm_capture * result, unsigned long timeout) for the function declaration. The kernel-doc change was proposed by Jakob Lykke Andersen here: jakobandersen/linux_docs@6fd2076 Although I did a different implementation. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 5ef09c9 commit 6e9e415

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

‎scripts/kernel-doc‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ sub output_function_rst(%) {
917917
my ($parameter, $section);
918918
my $oldprefix = $lineprefix;
919919
my $start = "";
920+
my $is_macro = 0;
920921

921922
if ($sphinx_major < 3) {
922923
if ($args{'typedef'}) {
@@ -926,11 +927,17 @@ sub output_function_rst(%) {
926927
$lineprefix = "";
927928
output_highlight_rst($args{'purpose'});
928929
$start = "\n\n**Syntax**\n\n ``";
930+
$is_macro = 1;
929931
} else {
930932
print ".. c:function:: ";
931933
}
932934
} else {
933-
print ".. c:macro:: ". $args{'function'} . "\n\n";
935+
if ($args{'typedef'} || $args{'functiontype'} eq "") {
936+
$is_macro = 1;
937+
print ".. c:macro:: ". $args{'function'} . "\n\n";
938+
} else {
939+
print ".. c:function:: ";
940+
}
934941

935942
if ($args{'typedef'}) {
936943
print_lineno($declaration_start_line);
@@ -939,7 +946,7 @@ sub output_function_rst(%) {
939946
output_highlight_rst($args{'purpose'});
940947
$start = "\n\n**Syntax**\n\n ``";
941948
} else {
942-
print "``";
949+
print "``" if ($is_macro);
943950
}
944951
}
945952
if ($args{'functiontype'} ne "") {
@@ -964,14 +971,12 @@ sub output_function_rst(%) {
964971
print $type;
965972
}
966973
}
967-
if ($args{'typedef'}) {
968-
print ");``\n\n";
974+
if ($is_macro) {
975+
print ")``\n\n";
969976
} else {
970-
if ($sphinx_major < 3) {
971-
print ")\n\n";
972-
} else {
973-
print ")``\n";
974-
}
977+
print ")\n\n";
978+
}
979+
if (!$args{'typedef'}) {
975980
print_lineno($declaration_start_line);
976981
$lineprefix = " ";
977982
output_highlight_rst($args{'purpose'});

0 commit comments

Comments
 (0)