本文整理匯總了Python中sphinx.addnodes.literal_strong方法的典型用法代碼示例。如果您正苦於以下問題:Python addnodes.literal_strong方法的具體用法?Python addnodes.literal_strong怎麽用?Python addnodes.literal_strong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sphinx.addnodes
的用法示例。
在下文中一共展示了addnodes.literal_strong方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setup
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def setup(app):
def parse_node(env, text, node):
args = text.split("^")
name = args[0].strip()
node += addnodes.literal_strong(name, name)
if len(args) > 2:
default = "={}".format(args[2].strip())
node += nodes.literal(text=default)
if len(args) > 1:
content = "({})".format(args[1].strip())
node += addnodes.compact_paragraph(text=content)
return name # this will be the link
app.add_object_type(
directivename="conf",
rolename="conf",
objname="configuration value",
indextemplate="pair: %s; configuration value",
parse_node=parse_node,
)
示例2: create_option_reference
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [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
示例3: make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def make_field(self, types, domain, items, env=None):
fieldname = nodes.field_name('', self.label)
listnode = self.list_type()
for fieldarg, content in items:
par = nodes.paragraph()
par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
addnodes.literal_strong, env=env))
if content and content[0].astext():
par += nodes.Text(' ')
par += content
listnode += nodes.list_item('', par)
source = env.ref_context['conda:package']
backrefs = env.domains['conda'].data['backrefs'].setdefault(fieldarg, set())
backrefs.add((env.docname, source))
fieldbody = nodes.field_body('', listnode)
fieldbody.set_class('field-list-wrapped')
return nodes.field('', fieldname, fieldbody)
示例4: resolve_required_by_xrefs
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [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
示例5: make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def make_field(self, types, domain, item, env=None):
fieldarg, fieldtype = item
body = d_nodes.paragraph()
if fieldarg:
body.extend(self.make_xrefs(self.rolename, domain, fieldarg,
s_nodes.literal_strong, env=env))
body += d_nodes.Text('--')
typename = u''.join(n.astext() for n in fieldtype)
body.extend(
self.make_xrefs(self.typerolename, domain, typename,
s_nodes.literal_emphasis, env=env))
fieldname = d_nodes.field_name('', self.label)
fieldbody = d_nodes.field_body('', body)
node = d_nodes.field('', fieldname, fieldbody)
node['eql-name'] = self.name
node['eql-opname'] = fieldarg
if typename:
node['eql-optype'] = typename
return node
示例6: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, **kw):
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!
# type: (List, unicode, Tuple) -> nodes.field
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(' (')
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
typename = typename.replace('int', 'python:int')
typename = typename.replace('long', 'python:long')
typename = typename.replace('float', 'python:float')
typename = typename.replace('type', 'python:type')
par.extend(self.make_xrefs(self.typerolename, domain, typename,
addnodes.literal_emphasis, **kw))
else:
par += fieldtype
par += nodes.Text(')')
par += nodes.Text(' -- ')
par += content
return par
fieldname = nodes.field_name('', self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item('', handle_item(fieldarg, content))
fieldbody = nodes.field_body('', bodynode)
return nodes.field('', fieldname, fieldbody)
示例7: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, env):
# type: (list, str, tuple) -> nodes.field
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong("", fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(" (")
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = "".join(n.astext() for n in fieldtype)
par.extend(
self.make_xrefs(
self.typerolename, domain, typename, addnodes.literal_emphasis
)
)
else:
par += fieldtype
par += nodes.Text(")")
par += nodes.Text(" -- ")
par += content
return par
fieldname = nodes.field_name("", self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item("", handle_item(fieldarg, content))
fieldbody = nodes.field_body("", bodynode)
return nodes.field("", fieldname, fieldbody)
示例8: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, **kw):
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!
# type: (list, unicode, tuple) -> nodes.field
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(' (')
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
typename = typename.replace('int', 'python:int')
typename = typename.replace('long', 'python:long')
typename = typename.replace('float', 'python:float')
typename = typename.replace('type', 'python:type')
par.extend(self.make_xrefs(self.typerolename, domain, typename,
addnodes.literal_emphasis, **kw))
else:
par += fieldtype
par += nodes.Text(')')
par += nodes.Text(' -- ')
par += content
return par
fieldname = nodes.field_name('', self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item('', handle_item(fieldarg, content))
fieldbody = nodes.field_body('', bodynode)
return nodes.field('', fieldname, fieldbody)
示例9: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, env=None):
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(' (')
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
par.extend(self.make_xrefs(self.typerolename, domain, typename,
addnodes.literal_emphasis))
else:
par += fieldtype
par += nodes.Text(')')
par += nodes.Text(' -- ')
par += content
return par
fieldname = nodes.field_name('', self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item('', handle_item(fieldarg, content))
fieldbody = nodes.field_body('', bodynode)
return nodes.field('', fieldname, fieldbody)
示例10: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, env):
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong("", fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(" (")
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = "".join(n.astext() for n in fieldtype)
par.extend(
self.make_xrefs(
self.typerolename, domain, typename, addnodes.literal_emphasis
)
)
else:
par += fieldtype
par += nodes.Text(")")
par += nodes.Text(" -- ")
par += content
return par
fieldname = nodes.field_name("", self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item("", handle_item(fieldarg, content))
fieldbody = nodes.field_body("", bodynode)
return nodes.field("", fieldname, fieldbody)
示例11: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, **kw):
# `kw` catches `env=None` needed for newer sphinx while maingaining
# backwards compatibility when passed along further down!
# type: (List, unicode, Tuple) -> nodes.field
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(' (')
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
typename = typename.replace('int', 'python:int')
typename = typename.replace('long', 'python:long')
typename = typename.replace('float', 'python:float')
typename = typename.replace('type', 'python:type')
par.extend(self.make_xrefs(self.typerolename, domain, typename,
addnodes.literal_emphasis, **kw))
else:
par += fieldtype
par += nodes.Text(')')
par += nodes.Text(' -- ')
par += content
return par
fieldname = nodes.field_name('', self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item('', handle_item(fieldarg, content))
fieldbody = nodes.field_body('', bodynode)
return nodes.field('', fieldname, fieldbody)
示例12: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, **kw):
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!
# type: (List, unicode, Tuple) -> nodes.field
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(' (')
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
typename = typename.replace('int', 'python:int')
typename = typename.replace('long', 'python:long')
typename = typename.replace('float', 'python:float')
typename = typename.replace('type', 'python:type')
par.extend(
self.make_xrefs(self.typerolename, domain, typename, addnodes.literal_emphasis,
**kw))
else:
par += fieldtype
par += nodes.Text(')')
par += nodes.Text(' -- ')
par += content
return par
fieldname = nodes.field_name('', self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item('', handle_item(fieldarg, content))
fieldbody = nodes.field_body('', bodynode)
return nodes.field('', fieldname, fieldbody)
示例13: make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def make_field(
self,
types: Dict[str, List[nodes.Node]],
domain: str,
items: Tuple[str, List[nodes.inline]],
env: BuildEnvironment = None,
) -> nodes.field:
def makerefs(rolename, name, node):
return self.make_xrefs(rolename, domain, name, node, env=env)
def handle_item(
fieldarg: str, content: List[nodes.inline]
) -> nodes.definition_list_item:
head = nodes.term()
head += makerefs(self.rolename, fieldarg, addnodes.literal_strong)
fieldtype = types.pop(fieldarg, None)
if fieldtype is not None:
head += nodes.Text(" : ")
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
(text_node,) = fieldtype # type: nodes.Text
head += makerefs(
self.typerolename, text_node.astext(), addnodes.literal_emphasis
)
else:
head += fieldtype
body_content = nodes.paragraph("", "", *content)
body = nodes.definition("", body_content)
return nodes.definition_list_item("", head, body)
fieldname = nodes.field_name("", self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += handle_item(fieldarg, content)
fieldbody = nodes.field_body("", bodynode)
return nodes.field("", fieldname, fieldbody)
# replace matching field types with ours
示例14: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(self, types, domain, items, **kw):
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong("", fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(" (")
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = "".join(n.astext() for n in fieldtype)
typename = typename.replace("int", "python:int")
typename = typename.replace("long", "python:long")
typename = typename.replace("float", "python:float")
typename = typename.replace("type", "python:type")
par.extend(
self.make_xrefs(
self.typerolename,
domain,
typename,
addnodes.literal_emphasis,
**kw,
)
)
else:
par += fieldtype
par += nodes.Text(")")
par += nodes.Text(" -- ")
par += content
return par
fieldname = nodes.field_name("", self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item("", handle_item(fieldarg, content))
fieldbody = nodes.field_body("", bodynode)
return nodes.field("", fieldname, fieldbody)
示例15: patched_make_field
# 需要導入模塊: from sphinx import addnodes [as 別名]
# 或者: from sphinx.addnodes import literal_strong [as 別名]
def patched_make_field(
self, # type: TypedField
types, # type: typing.Dict[str, typing.List[nodes.Node]]
domain, # type: str
items, # type: typing.Tuple
env=None, # type: typing.Any
):
# type: (...) -> nodes.field
def handle_item(fieldarg, content):
# type: (str, str) -> nodes.paragraph
par = nodes.paragraph()
par += addnodes.literal_strong("", fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong, env=env))
if fieldarg in types:
par += nodes.Text(" (")
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u"".join(n.astext() for n in fieldtype)
par.extend(
self.make_xrefs(
self.typerolename,
domain,
typename,
addnodes.literal_emphasis,
env=env,
)
)
else:
par += fieldtype
par += nodes.Text(")")
par += nodes.Text(" -- ")
par += content
return par
fieldname = nodes.field_name("", self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item("", handle_item(fieldarg, content))
fieldbody = nodes.field_body("", bodynode)
return nodes.field("", fieldname, fieldbody)