本文整理汇总了Python中sphinx.util.nodes.make_refnode方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.make_refnode方法的具体用法?Python nodes.make_refnode怎么用?Python nodes.make_refnode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.util.nodes
的用法示例。
在下文中一共展示了nodes.make_refnode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_option_reference
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def create_option_reference(self, option, config, context):
par = nodes.paragraph()
innernode = addnodes.literal_strong(option.dispname, option.dispname)
par += self.make_refnode(option.docname, option.anchor, innernode)
if option.config != config:
par += nodes.Text(" (from ")
par += self._make_config_xref(option.config)
par += nodes.Text(")")
if option.context is not None:
opt_context = option.context
if opt_context.startswith(context):
opt_context = opt_context[len(context):]
if opt_context:
par += nodes.Text(" in ")
par += addnodes.literal_emphasis(option.context, option.context)
return par
示例2: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if not target:
return None
if typ == "config":
config = self.master_configs.get(target, None)
if config is None:
return None
return make_refnode(builder, fromdocname, config.docname, config.anchor, contnode,
config.dispname)
elif typ == "option":
config_options = self.config_options
split = target.split('.')
if len(split) < 2:
return None
for i in range(1, len(split)):
config, entry_name = '.'.join(split[:i]), '.'.join(split[i:])
for option_entry in config_options.get(config, []):
if option_entry.dispname == entry_name: # match!
return make_refnode(builder, fromdocname, option_entry.docname,
option_entry.anchor, contnode, option_entry.dispname)
return None
return None
示例3: resolve_required_by_xrefs
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_required_by_xrefs(app, env, node, contnode):
"""Now that all recipes and packages have been parsed, we are called here
for each ``pending_xref`` node that sphinx has not been able to resolve.
We handle specifically the ``requiredby`` reftype created by the
`RequiredByField` fieldtype allowed in ``conda:package::``
directives, where we replace the ``pending_ref`` node with a bullet
list of reference nodes pointing to the package pages that
"depended" on the package.
"""
if node['reftype'] == 'requiredby' and node['refdomain'] == 'conda':
target = node['reftarget']
docname = node['refdoc']
backrefs = env.domains['conda'].data['backrefs'].get(target, set())
listnode = nodes.bullet_list()
for back_docname, back_target in backrefs:
par = nodes.paragraph()
name_node = addnodes.literal_strong(back_target, back_target,
classes=['xref', 'backref'])
refnode = make_refnode(app.builder, docname,
back_docname, back_target, name_node)
refnode.set_class('conda-package')
par += refnode
listnode += nodes.list_item('', par)
return listnode
示例4: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, env: BuildEnvironment, fromdocname: str,
builder, role, target, node, contnode):
"""Resolve the ``pending_xref`` **node** with the given **role** and **target**."""
for objtype in self.objtypes_for_role(role) or []:
if (objtype, target) in self.data['objects']:
node = make_refnode(
builder, fromdocname,
self.data['objects'][objtype, target][0],
self.data['objects'][objtype, target][1],
contnode, target + ' ' + objtype)
node.set_class('conda-package')
return node
if objtype == "package":
for channel, urlformat in env.app.config.bioconda_other_channels.items():
if RepoData().get_package_data(channels=channel, name=target):
uri = urlformat.format(target)
node = nodes.reference('', '', internal=False,
refuri=uri, classes=[channel])
node += contnode
return node
return None # triggers missing-reference
示例5: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, env, fromdocname, builder, typ, target,
node, contnode):
try:
info = self.data[str(typ)][target]
except KeyError:
text = contnode.rawsource
role = self.roles.get(typ)
if role is None:
return nodes.emphasis(text, text)
resnode = role.result_nodes(env.get_doctree(fromdocname),
env, node, None)[0][0]
if isinstance(resnode, addnodes.pending_xref):
text = node[0][0]
reporter = env.get_doctree(fromdocname).reporter
reporter.error('Cannot resolve reference to %r' % text,
line=node.line)
return nodes.problematic(text, text)
return resnode
else:
anchor = http_resource_anchor(typ, target)
title = typ.upper() + ' ' + target
return make_refnode(builder, fromdocname, info[0], anchor,
contnode, title)
示例6: meta_id
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def meta_id(self):
"""
Returns the current need id as clickable and linked reference.
Usage::
<<meta_id()>>
:return: docutils node
"""
from sphinx.util.nodes import make_refnode
id_container = nodes.inline(classes=["needs-id"])
nodes_id_text = nodes.Text(self.need['id'], self.need['id'])
id_ref = make_refnode(self.app.builder,
# fromdocname=self.need['docname'],
fromdocname=self.fromdocname,
todocname=self.need['docname'],
targetid=self.need['id'],
child=nodes_id_text.deepcopy(),
title=self.need['id'])
id_container += id_ref
return id_container
示例7: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, _, fromdocname, builder,
typ, target, node, contnode):
targets = [target]
if node['csharp:parent'] is not None:
parts = node['csharp:parent'].split('.')
while parts:
targets.append('.'.join(parts)+'.'+target)
parts = parts[:-1]
objects = self.data['objects']
objtypes = self.objtypes_for_role(typ)
for tgt in targets:
for objtype in objtypes:
if (objtype, tgt) in objects:
return make_refnode(builder, fromdocname,
objects[objtype, tgt],
objtype + '-' + tgt,
contnode, tgt + ' ' + objtype)
for tgt in targets:
ref = get_msdn_ref(tgt)
if ref is not None:
return ref
return None
示例8: create_option_reference_table_row
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def create_option_reference_table_row(self, option, config, context):
row = nodes.row("")
par = self.create_option_reference(option, config, context)
row += nodes.entry("", par)
if self.builder.config.cfg_options_default_in_summary_table:
par = nodes.paragraph()
if option.default:
par += nodes.literal(option.default, option.default)
row += nodes.entry("", par)
par = nodes.paragraph()
par += nodes.Text(option.summary)
if option.summarycropped:
par += self.make_refnode(option.docname, option.anchor, nodes.Text(" [...]"))
row += nodes.entry("", par)
return row
示例9: make_refnode
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def make_refnode(self, docname, anchor, innernode):
try:
refnode = make_refnode(self.builder, self.docname, docname, anchor, innernode)
except NoUri: # ignore if no URI can be determined, e.g. for LaTeX output
refnode = innernode
return refnode
示例10: _make_config_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def _make_config_xref(self, config):
node = nodes.Text(config, config)
match = [(obj_entry.docname, obj_entry.anchor) for obj_entry in self.domain.get_objects()
if obj_entry.name == config and obj_entry.typ == 'config']
if len(match) > 0:
docname, anchor = match[0]
node = self.make_refnode(docname, anchor, node)
return node
示例11: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
objtypes = self.objtypes_for_role(typ) or []
for objtype in objtypes:
if (objtype, target) in self.data['objects']:
docname, labelid = self.data['objects'][objtype, target]
break
else:
docname, labelid = '', ''
if not docname:
return None
return make_refnode(builder, fromdocname, docname, labelid, contnode)
示例12: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if target not in self.data['objects']:
return None
obj = self.data['objects'][target]
return make_refnode(builder, fromdocname, obj[0], 'protobuf.' + target, contnode, target)
示例13: missing_reference
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def missing_reference(app, env, node, contnode):
# resolve our "viewcode" reference nodes -- they need special treatment
if node['reftype'] == 'viewcode':
return make_refnode(app.builder, node['refdoc'], node['reftarget'],
node['refid'], contnode)
示例14: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
try:
info = self.data[str(typ)][target]
except KeyError:
text = contnode.rawsource
if typ == "statuscode":
return http_statuscode_role(None, text, text, None, None)[0][0]
elif typ == "mailheader":
return http_header_role(None, text, text, None, None)[0][0]
else:
return nodes.emphasis(text, text)
else:
anchor = http_resource_anchor(typ, target)
title = typ.upper() + " " + target
return make_refnode(builder, fromdocname, info[0], anchor, contnode, title)
示例15: resolve_xref
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import make_refnode [as 别名]
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if typ == "section":
info = self.data[typ][target]
title = "[%s]" % target
elif typ == "option":
assert "/" in target, "option without section: %r" % target
section, option = target.split("/", 1)
info = self.data[typ][target]
title = option
else:
assert "unknown role %r for target %r" % (typ, target)
return make_refnode(builder, fromdocname, info[0], target, contnode, title)