linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] docs-rst: ignore arguments on macro definitions
@ 2016-08-29 13:13 Mauro Carvalho Chehab
  2016-08-29 14:12 ` Markus Heiser
  0 siblings, 1 reply; 11+ messages in thread
From: Mauro Carvalho Chehab @ 2016-08-29 13:13 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Jonathan Corbet,
	linux-doc

A macro definition is mapped via .. c:function:: at the
ReST markup when using the following kernel-doc tag:

	/**
	 * DMX_FE_ENTRY - Casts elements in the list of registered
	 *               front-ends from the generic type struct list_head
	 *               to the type * struct dmx_frontend
	 *
	 * @list: list of struct dmx_frontend
	 */
	 #define DMX_FE_ENTRY(list) \
	        list_entry(list, struct dmx_frontend, connectivity_list)

However, unlike a function description, the arguments of a macro
doesn't contain the data type.

This causes warnings when enabling Sphinx on nitkpick mode,
like this one:
	./drivers/media/dvb-core/demux.h:358: WARNING: c:type reference target not found: list

That happens because kernel-doc output for the above is:

	.. c:function:: DMX_FE_ENTRY ( list)

	   Casts elements in the list of registered front-ends from the generic type struct list_head to the type * struct dmx_frontend

	**Parameters**

	``list``
	  list of struct dmx_frontend

As the type is blank, Sphinx would think that ``list`` is a type,
and will try to add a cross reference for it, using their internal
representation for c:type:`list`.

However, ``list`` is not a type. So, that would cause either the
above warning, or if a ``list`` type exists, it would create
a reference to the wrong place at the doc.

To avoid that, let's ommit macro arguments from c:function::
declaration. As each argument will appear below the Parameters,
the type of the argument can be described there, if needed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---

v3: version 2 patch caused a regression when handling function arguments,
because the counter were not incremented on all cases. Fix it.

 scripts/kernel-doc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index d225e178aa1b..bac0af4fc659 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1846,14 +1846,15 @@ sub output_function_rst(%) {
 	if ($count ne 0) {
 	    print ", ";
 	}
-	$count++;
 	$type = $args{'parametertypes'}{$parameter};
 
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
 	    print $1 . $parameter . ") (" . $2;
-	} else {
+	    $count++;
+	} elsif ($type ne "") {
 	    print $type . " " . $parameter;
+	    $count++;
 	}
     }
     print ")\n\n";
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-09-08 13:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-29 13:13 [PATCH v3] docs-rst: ignore arguments on macro definitions Mauro Carvalho Chehab
2016-08-29 14:12 ` Markus Heiser
2016-08-29 15:13   ` Mauro Carvalho Chehab
2016-08-29 15:36     ` Jani Nikula
2016-08-31  8:15       ` Markus Heiser
2016-08-31  9:02         ` Jani Nikula
2016-08-31 10:09           ` Markus Heiser
2016-08-31 10:26             ` Mauro Carvalho Chehab
2016-08-31 10:37               ` Markus Heiser
2016-09-08 11:40   ` Mauro Carvalho Chehab
2016-09-08 13:58     ` Markus Heiser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).