diff options
| author | Georg Brandl <georg@python.org> | 2014-01-19 17:41:41 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2014-01-19 17:41:41 +0100 |
| commit | a003cdbd2fcf73e24670568facda9bd6c5a73e76 (patch) | |
| tree | b227753b9b0a0bb70b412176a186e0e07c99c26c /sphinx/domains | |
| parent | dbefc55b2fac1e0f531af7d5f4de51aeef65bcf2 (diff) | |
| parent | 647512528f59c24781ed4043bab0d811e97ef3a7 (diff) | |
| download | sphinx-a003cdbd2fcf73e24670568facda9bd6c5a73e76.tar.gz | |
merge with stable
Diffstat (limited to 'sphinx/domains')
| -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 a7ed7557..6714e838 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'), |
