mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#571: Implement `~
` cross-reference prefix for the C domain.
This commit is contained in:
parent
8a3598ff8e
commit
7ef806ffb0
2
CHANGES
2
CHANGES
@ -1,6 +1,8 @@
|
||||
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.
|
||||
|
||||
* #568: Fix lookup of class attribute documentation on descriptors
|
||||
|
@ -164,6 +164,20 @@ class CObject(ObjectDescription):
|
||||
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):
|
||||
"""C language domain."""
|
||||
name = 'c'
|
||||
@ -184,11 +198,11 @@ class CDomain(Domain):
|
||||
'var': CObject,
|
||||
}
|
||||
roles = {
|
||||
'func' : XRefRole(fix_parens=True),
|
||||
'member': XRefRole(),
|
||||
'macro': XRefRole(),
|
||||
'data': XRefRole(),
|
||||
'type': XRefRole(),
|
||||
'func' : CXRefRole(fix_parens=True),
|
||||
'member': CXRefRole(),
|
||||
'macro': CXRefRole(),
|
||||
'data': CXRefRole(),
|
||||
'type': CXRefRole(),
|
||||
}
|
||||
initial_data = {
|
||||
'objects': {}, # fullname -> docname, objtype
|
||||
|
Loading…
Reference in New Issue
Block a user