[Python-checkins] r61335 - doctools/trunk/sphinx/roles.py
georg.brandl
python-checkins at python.org
Sun Mar 9 22:31:43 CET 2008
Author: georg.brandl
Date: Sun Mar 9 22:31:42 2008
New Revision: 61335
Modified:
doctools/trunk/sphinx/roles.py
Log:
A leading '~' in a object cross-reference hides the module part.
Modified: doctools/trunk/sphinx/roles.py
==============================================================================
--- doctools/trunk/sphinx/roles.py (original)
+++ doctools/trunk/sphinx/roles.py Sun Mar 9 22:31:42 2008
@@ -120,12 +120,21 @@
rawtext, text, classes=['xref'])], []
pnode = addnodes.pending_xref(rawtext)
pnode['reftype'] = typ
- # if the first character is a dot, search more specific namespaces first
- # else search builtins first
- if text[0:1] == '.' and \
- typ in ('data', 'exc', 'func', 'class', 'const', 'attr', 'meth'):
- text = text[1:]
- pnode['refspecific'] = True
+ innertext = text
+ # special actions for Python object cross-references
+ if typ in ('data', 'exc', 'func', 'class', 'const', 'attr', 'meth'):
+ # if the first character is a dot, search more specific namespaces first
+ # else search builtins first
+ if text[0:1] == '.':
+ text = text[1:]
+ pnode['refspecific'] = True
+ # if the first character is a tilde, don't display the module/class parts
+ # of the contents
+ if text[0:1] == '~':
+ text = text[1:]
+ dot = text.rfind('.')
+ if dot != -1:
+ innertext = text[dot+1:]
if typ == 'term':
pnode['reftarget'] = ws_re.sub(' ', text).lower()
elif typ == 'ref':
@@ -152,7 +161,7 @@
pnode['reftarget'] = ws_re.sub('', text)
pnode['modname'] = env.currmodule
pnode['classname'] = env.currclass
- pnode += innernodetypes.get(typ, nodes.literal)(rawtext, text, classes=['xref'])
+ pnode += innernodetypes.get(typ, nodes.literal)(rawtext, innertext, classes=['xref'])
return [pnode], []
More information about the Python-checkins
mailing list