diff options
author | Virgil Dupras <hsoft@hardcoded.net> | 2014-01-04 21:40:52 -0500 |
---|---|---|
committer | Virgil Dupras <hsoft@hardcoded.net> | 2014-01-04 21:40:52 -0500 |
commit | 70e46cc2915f7f277e062536f119dc55d8f2096e (patch) | |
tree | 3b6980562c984ffcca8bb8c597260225f69f5370 /sphinx | |
parent | 1188737c85db040a2c13745dea71ac1e2caae84d (diff) | |
download | sphinx-70e46cc2915f7f277e062536f119dc55d8f2096e.tar.gz |
Allow "." and "~" prefixes in inline :param: typedefs.
Diffstat (limited to 'sphinx')
-rw-r--r-- | sphinx/domains/python.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 0c08b60b..63d388c8 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -81,6 +81,23 @@ def _pseudo_parse_arglist(signode, arglist): signode += paramlist +# This override allows our inline type specifiers to behave like :class: link +# when it comes to handling "." and "~" prefixes. +class PyTypedField(TypedField): + def make_xref(self, rolename, domain, target, innernode=nodes.emphasis): + result = super(PyTypedField, self).make_xref(rolename, domain, target, + innernode) + if target.startswith('.'): + result['reftarget'] = target[1:] + result['refspecific'] = True + result[0][0] = nodes.Text(target[1:]) + if target.startswith('~'): + result['reftarget'] = target[1:] + title = target.split('.')[-1] + result[0][0] = nodes.Text(title) + return result + + class PyObject(ObjectDescription): """ Description of a general Python object. @@ -92,7 +109,7 @@ class PyObject(ObjectDescription): } doc_field_types = [ - TypedField('parameter', label=l_('Parameters'), + PyTypedField('parameter', label=l_('Parameters'), names=('param', 'parameter', 'arg', 'argument', 'keyword', 'kwarg', 'kwparam'), typerolename='obj', typenames=('paramtype', 'type'), |