本文整理汇总了Python中docutils.nodes.emphasis方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.emphasis方法的具体用法?Python nodes.emphasis怎么用?Python nodes.emphasis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.emphasis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: autolink_role
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def autolink_role(typ, rawtext, etext, lineno, inliner,
options={}, content=[]):
"""Smart linking role.
Expands to ':obj:`text`' if `text` is an object that can be imported;
otherwise expands to '*text*'.
"""
env = inliner.document.settings.env
r = env.get_domain('py').role('obj')(
'obj', rawtext, etext, lineno, inliner, options, content)
pnode = r[0][0]
prefixes = get_import_prefixes_from_env(env)
try:
name, obj, parent, modname = import_by_name(pnode['reftarget'], prefixes)
except ImportError:
content = pnode[0]
r[0][0] = nodes.emphasis(rawtext, content[0].astext(),
classes=content['classes'])
return r
示例2: handle_signature
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def handle_signature(self,sig,signode):
sig = sig.strip()
type_name, name, arglist = protobuf_sig_regex.match(sig).groups()
if self.prefix:
signode += addnodes.desc_annotation(self.prefix+' ', self.prefix+' ')
if type_name:
signode += addnodes.desc_type(type_name, type_name)
if name:
signode += addnodes.desc_name(name,name)
if arglist:
paramlist = addnodes.desc_parameterlist()
for arg in arglist.split(','):
argtype, argname = arg.split(None,1)
param = addnodes.desc_parameter(noemph=True)
param += nodes.Text(argtype,argtype)
param += nodes.emphasis(' '+argname,' '+argname)
paramlist += param
signode += paramlist
return name
示例3: make_xref
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def make_xref(self, rolename, domain, target,
innernode=d_nodes.emphasis, contnode=None, env=None):
if not rolename:
return contnode or innernode(target, target)
title = target
if domain == 'eql' and rolename == 'type':
target = EQLTypeXRef.filter_target(target)
if target in EQLTypedField.ignored_types:
return d_nodes.Text(title)
refnode = s_nodes.pending_xref('', refdomain=domain,
refexplicit=title != target,
reftype=rolename, reftarget=target)
refnode += contnode or innernode(title, title)
if env:
env.domains[domain].process_field_xref(refnode)
refnode['eql-auto-link'] = True
return refnode
示例4: result_nodes
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def result_nodes(self, document, env, node, is_ref):
method = node[0][0].lower()
rawsource = node[0].rawsource
config = env.domains['http'].env.config
if method not in METHOD_REFS:
if not config['http_strict_mode']:
return [nodes.emphasis(method, method)], []
reporter = document.reporter
msg = reporter.error('%s is not valid HTTP method' % method,
line=node.line)
prb = nodes.problematic(method, method)
return [prb], [msg]
url = str(METHOD_REFS[method])
if not url:
return [nodes.emphasis(method, method)], []
node = nodes.reference(rawsource, method.upper(), refuri=url)
return [node], []
示例5: resolve_xref
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [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: used_filter_paragraph
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def used_filter_paragraph(current_needfilter):
para = nodes.paragraph()
filter_text = "Used filter:"
filter_text += " status(%s)" % " OR ".join(current_needfilter["status"]) if len(
current_needfilter["status"]) > 0 else ""
if len(current_needfilter["status"]) > 0 and len(current_needfilter["tags"]) > 0:
filter_text += " AND "
filter_text += " tags(%s)" % " OR ".join(current_needfilter["tags"]) if len(
current_needfilter["tags"]) > 0 else ""
if (len(current_needfilter["status"]) > 0 or len(current_needfilter["tags"]) > 0) and len(
current_needfilter["types"]) > 0:
filter_text += " AND "
filter_text += " types(%s)" % " OR ".join(current_needfilter["types"]) if len(
current_needfilter["types"]) > 0 else ""
filter_node = nodes.emphasis(filter_text, filter_text)
para += filter_node
return para
示例7: get_filter_para
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def get_filter_para(node_element):
"""Return paragraph containing the used filter description"""
para = nodes.paragraph()
filter_text = "Used filter:"
filter_text += " status(%s)" % " OR ".join(node_element["status"]) if len(
node_element["status"]) > 0 else ""
if len(node_element["status"]) > 0 and len(node_element["tags"]) > 0:
filter_text += " AND "
filter_text += " tags(%s)" % " OR ".join(node_element["tags"]) if len(
node_element["tags"]) > 0 else ""
if (len(node_element["status"]) > 0 or len(node_element["tags"]) > 0) and len(
node_element["types"]) > 0:
filter_text += " AND "
filter_text += " types(%s)" % " OR ".join(node_element["types"]) if len(
node_element["types"]) > 0 else ""
filter_node = nodes.emphasis(filter_text, filter_text)
para += filter_node
return para
示例8: autolink_role
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def autolink_role(typ, rawtext, etext, lineno, inliner,
options={}, content=[]):
"""Smart linking role.
Expands to ':obj:`text`' if `text` is an object that can be imported;
otherwise expands to '*text*'.
"""
env = inliner.document.settings.env
r = env.get_domain('py').role('obj')(
'obj', rawtext, etext, lineno, inliner, options, content)
pnode = r[0][0]
prefixes = get_import_prefixes_from_env(env)
try:
name, obj, parent = import_by_name(pnode['reftarget'], prefixes)
except ImportError:
content = pnode[0]
r[0][0] = nodes.emphasis(rawtext, content[0].astext(),
classes=content['classes'])
return r
示例9: test_caption_option2
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def test_caption_option2(self):
directives.setup(format='SVG', outputdir=self.tmpdir)
text = (".. blockdiag::\n"
" :caption: **hello** *world*\n"
"\n"
" A -> B")
doctree = publish_doctree(text)
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.figure, type(doctree[0]))
self.assertEqual(2, len(doctree[0]))
self.assertEqual(nodes.image, type(doctree[0][0]))
self.assertEqual(nodes.caption, type(doctree[0][1]))
self.assertEqual(3, len(doctree[0][1]))
self.assertEqual(nodes.strong, type(doctree[0][1][0]))
self.assertEqual('hello', doctree[0][1][0][0])
self.assertEqual(nodes.Text, type(doctree[0][1][1]))
self.assertEqual(' ', doctree[0][1][1][0])
self.assertEqual(nodes.emphasis, type(doctree[0][1][2]))
self.assertEqual('world', doctree[0][1][2][0])
示例10: doctree_read
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def doctree_read(app, doctree):
env = app.builder.env
for node in doctree.traverse(addnodes.productionlist):
for production in node:
if not isinstance(production, addnodes.production):
continue
if not isinstance(production[-1], nodes.Text):
continue
parts = comment_re.split(production.pop().astext())
new_nodes = []
for s in parts:
if comment_re.match(s):
new_nodes.append(nodes.emphasis(s, s))
elif s:
new_nodes.append(nodes.Text(s))
production += new_nodes
示例11: process_todo_nodes
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def process_todo_nodes(app, doctree, fromdocname):
if not app.config.todo_include_todos:
for node in doctree.traverse(Todo):
node.parent.remove(node)
# Replace all todolist nodes with a list of the collected todos.
# Augment each todo with a backlink to the original location.
env = app.builder.env
for node in doctree.traverse(Todolist):
if not app.config.todo_include_todos:
node.replace_self([])
continue
content = []
for todo_info in env.todo_all_todos:
para = nodes.paragraph()
filename = env.doc2path(todo_info['docname'], base=None)
description = (
('(The original entry is located in %s, line %d and can be found ') %
(filename, todo_info['lineno']))
para += nodes.Text(description, description)
# Create a reference
newnode = nodes.reference('', '')
innernode = nodes.emphasis(('here'), ('here'))
newnode['refdocname'] = todo_info['docname']
newnode['refuri'] = app.builder.get_relative_uri(
fromdocname, todo_info['docname'])
newnode['refuri'] += '#' + todo_info['target']['refid']
newnode.append(innernode)
para += newnode
para += nodes.Text('.)', '.)')
# Insert into the todolist
content.append(todo_info['todo'])
content.append(para)
node.replace_self(content)
示例12: emphasis
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def emphasis(self, match, lineno):
before, inlines, remaining, sysmessages, endstring = self.inline_obj(
match, lineno, self.patterns.emphasis, nodes.emphasis)
return before, inlines, remaining, sysmessages
示例13: make_xref
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def make_xref(self, rolename, domain, target,
innernode=d_nodes.emphasis, contnode=None, env=None):
if rolename:
return d_nodes.literal(target, target)
return super().make_xref(
rolename, domain, target, innernode, contnode, env)
示例14: make_xrefs
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def make_xrefs(self, rolename, domain, target, innernode=d_nodes.emphasis,
contnode=None, env=None):
delims = r'''(?x)
(
\s* [\[\]\(\)<>,] \s* | \s+or\s+ |
\s*\bSET\s+OF\s+ |
\s*\bOPTIONAL\s+
)
'''
delims_re = re.compile(delims)
sub_targets = re.split(delims, target)
split_contnode = bool(contnode and contnode.astext() == target)
results = []
for sub_target in filter(None, sub_targets):
if split_contnode:
contnode = d_nodes.Text(sub_target)
if delims_re.match(sub_target):
results.append(contnode or innernode(sub_target, sub_target))
else:
results.append(self.make_xref(rolename, domain, sub_target,
innernode, contnode, env))
return results
示例15: fa_global
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import emphasis [as 别名]
def fa_global(key=''):
def fa(role, rawtext, text, lineno, inliner, options={}, content=[]):
options.update({'classes': []})
options['classes'].append('fa')
if key:
options['classes'].append('fa-%s' % key)
else:
for x in text.split(","):
options['classes'].append('fa-%s' % x)
set_classes(options)
node = emphasis(**options)
return [node], []
return fa
#add directive