History

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: https://github.com/jakobandersen/linux_docs/commit/6fd2076ec001cca7466857493cd678df4dfe4a65 Although I did a different implementation.

Mauro Carvalho Chehab committed 6 years ago

Commit 6e9e4151 parent 5ef09c91 file · +14 −9Browse files

Unified · Split

scripts/kernel-doc+14−9
@@ -917,6 +917,7 @@ sub output_function_rst(%) { · 916 unmodified lines
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(%) { · 3 unmodified lines
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(%) { · 2 unmodified lines
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(%) { · 18 unmodified lines
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'});