* Allow the ~ prefix on module xrefs.

* The parse function for custom descitems must return the full name for x-refing.
This commit is contained in:
Georg Brandl 2008-03-21 14:00:34 +00:00
parent dd14145ed5
commit d8c601b4cd
2 changed files with 8 additions and 6 deletions

View File

@ -321,18 +321,20 @@ def desc_directive(desctype, arguments, options, content, lineno,
# another registered generic x-ref directive # another registered generic x-ref directive
rolename, indextext, parse_node = additional_xref_types[desctype] rolename, indextext, parse_node = additional_xref_types[desctype]
if parse_node: if parse_node:
parse_node(sig, signode) fullname = parse_node(sig, signode)
else: else:
signode.clear() signode.clear()
signode += addnodes.desc_name(sig, sig) signode += addnodes.desc_name(sig, sig)
fullname = sig
if not noindex: if not noindex:
targetname = '%s-%s' % (rolename, sig) targetname = '%s-%s' % (rolename, fullname)
signode['ids'].append(targetname) signode['ids'].append(targetname)
state.document.note_explicit_target(signode) state.document.note_explicit_target(signode)
if indextext: if indextext:
env.note_index_entry('pair', '%s; %s' % (indextext, sig), env.note_index_entry('pair',
'%s; %s' % (indextext, fullname),
targetname, targetname) targetname, targetname)
env.note_reftarget(rolename, sig, targetname) env.note_reftarget(rolename, fullname, targetname)
# don't use object indexing below # don't use object indexing below
continue continue
except ValueError, err: except ValueError, err:

View File

@ -120,8 +120,9 @@ def xfileref_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
# we want a cross-reference, create the reference node # we want a cross-reference, create the reference node
pnode = addnodes.pending_xref(rawtext, reftype=typ, refcaption=False, pnode = addnodes.pending_xref(rawtext, reftype=typ, refcaption=False,
modname=env.currmodule, classname=env.currclass) modname=env.currmodule, classname=env.currclass)
innertext = text
# special actions for Python object cross-references # special actions for Python object cross-references
if typ in ('data', 'exc', 'func', 'class', 'const', 'attr', 'meth'): if typ in ('data', 'exc', 'func', 'class', 'const', 'attr', 'meth', 'mod'):
# if the first character is a dot, search more specific namespaces first # if the first character is a dot, search more specific namespaces first
# else search builtins first # else search builtins first
if text[0:1] == '.': if text[0:1] == '.':
@ -134,7 +135,6 @@ def xfileref_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
dot = text.rfind('.') dot = text.rfind('.')
if dot != -1: if dot != -1:
innertext = text[dot+1:] innertext = text[dot+1:]
innertext = text
# look if explicit title and target are given # look if explicit title and target are given
brace = text.find('<') brace = text.find('<')
if brace != -1: if brace != -1: