[3/3] doc-rst:c-domain: function-like macros index entry
Commit Message
From: Markus Heiser <markus.heiser@darmarIT.de>
For function-like macros, sphinx creates 'FOO (C function)' entries.
With this patch 'FOO (C macro)' are created for function-like macros,
which is the same for object-like macros.
Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
---
Documentation/sphinx/cdomain.py | 10 ++++++++++
1 file changed, 10 insertions(+)
Comments
On Wed, 31 Aug 2016 17:29:32 +0200
Markus Heiser <markus.heiser@darmarit.de> wrote:
> For function-like macros, sphinx creates 'FOO (C function)' entries.
> With this patch 'FOO (C macro)' are created for function-like macros,
> which is the same for object-like macros.
As others have pointed out, we generally want to hide the difference
between functions and macros, so this is probably one change we don't
want.
Thanks,
jon
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
@@ -37,6 +37,7 @@ from docutils.parsers.rst import directives
import sphinx
from sphinx import addnodes
+from sphinx.locale import _
from sphinx.domains.c import c_funcptr_sig_re, c_sig_re
from sphinx.domains.c import CObject as Base_CObject
from sphinx.domains.c import CDomain as Base_CDomain
@@ -66,6 +67,8 @@ class CObject(Base_CObject):
"name" : directives.unchanged
}
+ is_function_like_macro = False
+
def handle_func_like_macro(self, sig, signode):
u"""Handles signatures of function-like macros.
@@ -104,6 +107,7 @@ class CObject(Base_CObject):
param += nodes.emphasis(argname, argname)
paramlist += param
+ self.is_function_like_macro = True
return fullname
def handle_signature(self, sig, signode):
@@ -151,6 +155,12 @@ class CObject(Base_CObject):
self.indexnode['entries'].append(
('single', indextext, targetname, '', None))
+ def get_index_text(self, name):
+ if self.is_function_like_macro:
+ return _('%s (C macro)') % name
+ else:
+ return super(CObject, self).get_index_text(name)
+
class CDomain(Base_CDomain):
"""C language domain."""