本文整理匯總了Python中sphinx.roles.XRefRole.__call__方法的典型用法代碼示例。如果您正苦於以下問題:Python XRefRole.__call__方法的具體用法?Python XRefRole.__call__怎麽用?Python XRefRole.__call__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sphinx.roles.XRefRole
的用法示例。
在下文中一共展示了XRefRole.__call__方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __call__
# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
def __call__(self, *args, **kwargs):
nodes, messages = XRefRole.__call__(self, *args, **kwargs)
for node in nodes:
attrs = node.attributes
target = attrs['reftarget']
parens = ''
if target.endswith('()'):
# Function call, :symbol:`mongoc_init()`
target = target[:-2]
parens = '()'
if ':' in target:
# E.g., 'bson:bson_t' has domain 'bson', target 'bson_t'
attrs['domain'], name = target.split(':', 1)
attrs['reftarget'] = name
old = node.children[0].children[0]
assert isinstance(old, Text)
new = Text(name + parens, name + parens)
# Ensure setup_child is called.
node.children[0].replace(old, new)
else:
attrs['reftarget'] = target
attrs['reftype'] = 'doc'
attrs['classes'].append('symbol')
if sphinx_version_info >= (1, 6):
# https://github.com/sphinx-doc/sphinx/issues/3698
attrs['refdomain'] = 'std'
return nodes, messages
示例2: __call__
# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
def __call__(self, *args, **kwargs):
nodes, messages = XRefRole.__call__(self, *args, **kwargs)
for node in nodes:
attrs = node.attributes
target = attrs['reftarget']
parens = ''
if target.endswith('()'):
# Function call, :symbol:`mongoc_init()`
target = target[:-2]
parens = '()'
if ':' in target:
# E.g., 'bson:bson_t' has domain 'bson', target 'bson_t'
attrs['domain'], name = target.split(':', 1)
attrs['reftarget'] = name
assert isinstance(node.children[0].children[0], Text)
node.children[0].children[0] = Text(name + parens,
name + parens)
else:
attrs['reftarget'] = target
attrs['reftype'] = 'doc'
attrs['classes'].append('symbol')
return nodes, messages
示例3: __call__
# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
def __call__(self, typ, rawtext, text, lineno, inliner,
options={}, content=[]):
typ = 'std:ref'
self._reporter = inliner.document.reporter
self._lineno = lineno
return XRefRole.__call__(self, typ, rawtext, text, lineno,
inliner, options, content)
示例4: __call__
# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
def __call__(self, typ, rawtext, text, *args, **keys):
# CMake cross-reference targets may contain '<' so escape
# any explicit `<target>` with '<' not preceded by whitespace.
while True:
m = ECMXRefRole._re.match(text)
if m and len(m.group(2)) == 0:
text = '%s\x00<%s>' % (m.group(1), m.group(3))
else:
break
return XRefRole.__call__(self, typ, rawtext, text, *args, **keys)
示例5: __call__
# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
def __call__(self, typ, rawtext, text, *args, **keys):
# Translate CMake command cross-references of the form:
# `command_name(SUB_COMMAND)`
# to have an explicit target:
# `command_name(SUB_COMMAND) <command_name>`
if typ == 'cmake:command':
m = CMakeXRefRole._re_sub.match(text)
if m:
text = '%s <%s>' % (text, m.group(1))
# CMake cross-reference targets frequently contain '<' so escape
# any explicit `<target>` with '<' not preceded by whitespace.
while True:
m = CMakeXRefRole._re.match(text)
if m and len(m.group(2)) == 0:
text = '%s\x00<%s>' % (m.group(1), m.group(3))
else:
break
return XRefRole.__call__(self, typ, rawtext, text, *args, **keys)
示例6: __call__
# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
def __call__(self, typ, rawtext, text, lineno, inliner,
options={}, content=[]):
#~ print('20130901',typ, rawtext, text, lineno, inliner,options, content)
typ = 'std:ref'
return XRefRole.__call__(self, typ, rawtext, text, lineno,
inliner, options, content)
示例7: __call__
# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
def __call__(self, *args, **kwargs):
res = XRefRole.__call__(self, *args, **kwargs)
return res