#571: Implement `~` cross-reference prefix for the C domain.

This commit is contained in:
Georg Brandl 2011-01-06 20:48:52 +01:00
parent 8a3598ff8e
commit 7ef806ffb0
2 changed files with 21 additions and 5 deletions

View File

@ -1,6 +1,8 @@
Release 1.0.7 (in development) Release 1.0.7 (in development)
============================== ==============================
* #571: Implement ``~`` cross-reference prefix for the C domain.
* Fix regression of LaTeX output with the fix of #556. * Fix regression of LaTeX output with the fix of #556.
* #568: Fix lookup of class attribute documentation on descriptors * #568: Fix lookup of class attribute documentation on descriptors

View File

@ -164,6 +164,20 @@ class CObject(ObjectDescription):
self.indexnode['entries'].append(('single', indextext, name, name)) self.indexnode['entries'].append(('single', indextext, name, name))
class CXRefRole(XRefRole):
def process_link(self, env, refnode, has_explicit_title, title, target):
if not has_explicit_title:
target = target.lstrip('~') # only has a meaning for the title
# if the first character is a tilde, don't display the module/class
# parts of the contents
if title[0:1] == '~':
title = title[1:]
dot = title.rfind('.')
if dot != -1:
title = title[dot+1:]
return title, target
class CDomain(Domain): class CDomain(Domain):
"""C language domain.""" """C language domain."""
name = 'c' name = 'c'
@ -184,11 +198,11 @@ class CDomain(Domain):
'var': CObject, 'var': CObject,
} }
roles = { roles = {
'func' : XRefRole(fix_parens=True), 'func' : CXRefRole(fix_parens=True),
'member': XRefRole(), 'member': CXRefRole(),
'macro': XRefRole(), 'macro': CXRefRole(),
'data': XRefRole(), 'data': CXRefRole(),
'type': XRefRole(), 'type': CXRefRole(),
} }
initial_data = { initial_data = {
'objects': {}, # fullname -> docname, objtype 'objects': {}, # fullname -> docname, objtype