Skip to content

Commit e3ad05f

Browse files
committed
scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx 3.x
Unfortunately, Sphinx 3.x parser for c functions is too pedantic: sphinx-doc/sphinx#8241 While it could be relaxed with some configurations, there are several corner cases that it would make it hard to maintain, and will require teaching conf.py about several macros. So, let's instead use the :c:macro notation. This will produce an output that it is not as nice as currently, but it should still be acceptable, and will provide cross-references, removing thousands of warnings when building with newer versions of Sphinx. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent efa4447 commit e3ad05f

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

‎scripts/kernel-doc‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -886,19 +886,29 @@ sub output_function_rst(%) {
886886
my $oldprefix = $lineprefix;
887887
my $start = "";
888888

889-
if ($args{'typedef'}) {
890-
if ($sphinx_major < 3) {
889+
if ($sphinx_major < 3) {
890+
if ($args{'typedef'}) {
891891
print ".. c:type:: ". $args{'function'} . "\n\n";
892+
print_lineno($declaration_start_line);
893+
print " **Typedef**: ";
894+
$lineprefix = "";
895+
output_highlight_rst($args{'purpose'});
896+
$start = "\n\n**Syntax**\n\n ``";
892897
} else {
893-
print ".. c:function:: ". $args{'function'} . "\n\n";
898+
print ".. c:function:: ";
894899
}
895-
print_lineno($declaration_start_line);
896-
print " **Typedef**: ";
897-
$lineprefix = "";
898-
output_highlight_rst($args{'purpose'});
899-
$start = "\n\n**Syntax**\n\n ``";
900900
} else {
901-
print ".. c:function:: ";
901+
print ".. c:macro:: ". $args{'function'} . "\n\n";
902+
903+
if ($args{'typedef'}) {
904+
print_lineno($declaration_start_line);
905+
print " **Typedef**: ";
906+
$lineprefix = "";
907+
output_highlight_rst($args{'purpose'});
908+
$start = "\n\n**Syntax**\n\n ``";
909+
} else {
910+
print "``";
911+
}
902912
}
903913
if ($args{'functiontype'} ne "") {
904914
$start .= $args{'functiontype'} . " " . $args{'function'} . " (";
@@ -925,7 +935,11 @@ sub output_function_rst(%) {
925935
if ($args{'typedef'}) {
926936
print ");``\n\n";
927937
} else {
928-
print ")\n\n";
938+
if ($sphinx_major < 3) {
939+
print ")\n\n";
940+
} else {
941+
print ")``\n";
942+
}
929943
print_lineno($declaration_start_line);
930944
$lineprefix = " ";
931945
output_highlight_rst($args{'purpose'});

0 commit comments

Comments
 (0)