本文整理汇总了Python中docutils.nodes.container方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.container方法的具体用法?Python nodes.container怎么用?Python nodes.container使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.container方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
self.assert_has_content()
text = '\n'.join(self.content)
try:
if self.arguments:
classes = directives.class_option(self.arguments[0])
else:
classes = []
except ValueError:
raise self.error(
'Invalid class attribute value for "%s" directive: "%s".'
% (self.name, self.arguments[0]))
node = nodes.container(text)
node['classes'].extend(classes)
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
示例2: _container_wrapper
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def _container_wrapper(directive, literal_node, caption):
container_node = nodes.container('', literal_block=True,
classes=['literal-block-wrapper'])
parsed = nodes.Element()
directive.state.nested_parse(StringList([caption], source=''),
directive.content_offset, parsed)
if isinstance(parsed[0], nodes.system_message): # pragma: no cover
# TODO: Figure out if this is really possible and how to produce
# it in a test case.
msg = 'Invalid caption: %s' % parsed[0].astext()
raise ValueError(msg)
assert isinstance(parsed[0], nodes.Element)
caption_node = nodes.caption(parsed[0].rawsource, '',
*parsed[0].children)
caption_node.source = literal_node.source
caption_node.line = literal_node.line
container_node += caption_node
container_node += literal_node
return container_node
示例3: assert_output
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def assert_output(self, doctree, output, **kwargs):
__tracebackhide__ = True
literal = doctree.next_node(literal_block)
self.assertTrue(literal)
self.assertEqual(literal.astext(), output)
if 'caption' in kwargs:
caption_node = doctree.next_node(caption)
self.assertTrue(caption_node)
self.assertEqual(caption_node.astext(), kwargs.get('caption'))
if 'name' in kwargs:
if 'caption' in kwargs:
container_node = doctree.next_node(container)
self.assertTrue(container_node)
self.assertIn(kwargs.get('name'), container_node.get('ids'))
else:
self.assertIn(kwargs.get('name'), literal.get('ids'))
示例4: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
zenpy_client = Zenpy(subdomain="party", email="face@toe", password="Yer")
node_list = []
doc_sections = self.generate_sections(zenpy_client)
output = '.. py:class:: Zenpy%s\n\n' % inspect.signature(zenpy_client.__class__)
output += ' %s' % zenpy_client.__doc__
node = container()
self.state.nested_parse(StringList(output.split('\n')), 0, node)
node_list.append(node)
for doc_section in doc_sections:
node = paragraph()
self.state.nested_parse(StringList(doc_section.split('\n')), 0, node)
node_list.append(node)
return node_list
示例5: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
self.assert_has_content()
text = '\n'.join(self.content)
try:
if self.arguments:
classes = directives.class_option(self.arguments[0])
else:
classes = []
classes.append('technical-note')
except ValueError:
raise self.error(
'Invalid class attribute value for "%s" directive: "%s".'
% (self.name, self.arguments[0]))
node = nodes.container(text)
node['classes'].extend(classes)
nested_parse_with_titles(self.state, self.content, node)
return [node]
示例6: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
node = d_nodes.container()
node['react-element'] = self.arguments[0]
return [node]
示例7: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
try:
code = inspect.cleandoc(
"""
def usermethod():
{}
"""
).format("\n ".join(self.content))
exec(code)
result = locals()["usermethod"]()
if result is None:
raise Exception(
"Return value needed! The body of your `.. exec::` is used as a "
"function call that must return a value."
)
para = nodes.container()
# tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
lines = statemachine.StringList(result.split("\n"))
self.state.nested_parse(lines, self.content_offset, para)
return [para]
except Exception as e:
docname = self.state.document.settings.env.docname
return [
nodes.error(
None,
nodes.paragraph(
text="Unable to execute python code at {}:{} ... {}".format(
docname, self.lineno, datetime.datetime.now()
)
),
nodes.paragraph(text=str(e)),
nodes.literal_block(text=str(code)),
)
]
示例8: get_debug_containter
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def get_debug_containter(puml_node):
"""Return container containing the raw plantuml code"""
debug_container = nodes.container()
if isinstance(puml_node, nodes.figure):
data = puml_node.children[0]["uml"]
else:
data = puml_node["uml"]
data = '\n'.join([html.escape(line) for line in data.split('\n')])
debug_para = nodes.raw('', '<pre>{}</pre>'.format(data), format='html')
debug_container += debug_para
return debug_container
示例9: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
self.assert_has_content()
text = '\n'.join(self.content)
node = nodes.container(text)
node['classes'].append('rosetta_outer')
if self.arguments and self.arguments[0]:
node['classes'].append(self.arguments[0])
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
示例10: setup
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def setup(app):
"""add custom directive into Sphinx so that it is found during document parsing"""
app.add_directive('content-container', ContentContainerDirective)
app.add_directive('embed-compare', EmbedCompareDirective)
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
示例11: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
self.assert_has_content()
text = '\n'.join(self.content)
node = nodes.container(text)
node['classes'].append('code-section')
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
示例12: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
from sklearn import __version__ as skver
found = missing_ops()
nbconverters = 0
supported = set(build_sklearn_operator_name_map())
rows = [".. list-table::", " :header-rows: 1", " :widths: 10 7 4",
"", " * - Name", " - Package", " - Supported"]
for name, sub, cl in found:
rows.append(" * - " + name)
rows.append(" - " + sub)
if cl in supported:
rows.append(" - Yes")
nbconverters += 1
else:
rows.append(" -")
rows.append("")
rows.append("scikit-learn's version is **{0}**.".format(skver))
rows.append("{0}/{1} models are covered.".format(nbconverters, len(found)))
node = nodes.container()
st = StringList(rows)
nested_parse_with_titles(self.state, st, node)
main = nodes.container()
main += node
return [main]
示例13: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
ret = super(CaptionedCodeBlock, self).run()
caption = self.options.get('caption')
if caption and isinstance(ret[0], nodes.container):
container_node = ret[0]
if isinstance(container_node[0], nodes.caption):
container_node[1]['caption'] = caption
return [container_node[1]]
return ret
示例14: nodes_for_spec
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def nodes_for_spec(self, spec):
"""
Determine nodes for an input_algorithms spec
Taking into account nested specs
"""
tokens = []
if isinstance(spec, sb.create_spec):
container = nodes.container(classes=["option_spec_option shortline blue-back"])
creates = spec.kls
for name, option in sorted(spec.kwargs.items(), key=lambda x: len(x[0])):
para = nodes.paragraph(classes=["option monospaced"])
para += nodes.Text("{0} = ".format(name))
self.nodes_for_signature(option, para)
fields = {}
if creates and hasattr(creates, "fields") and isinstance(creates.fields, dict):
for key, val in creates.fields.items():
if isinstance(key, tuple):
fields[key[0]] = val
else:
fields[key] = val
txt = fields.get(name) or "No description"
viewlist = ViewList()
for line in dedent(txt).split("\n"):
viewlist.append(line, name)
desc = nodes.section(classes=["description monospaced"])
self.state.nested_parse(viewlist, self.content_offset, desc)
container += para
container += desc
container.extend(self.nodes_for_spec(option))
tokens.append(container)
elif isinstance(spec, sb.optional_spec):
tokens.extend(self.nodes_for_spec(spec.spec))
elif isinstance(spec, sb.container_spec):
tokens.extend(self.nodes_for_spec(spec.spec))
elif isinstance(spec, sb.dictof):
tokens.extend(self.nodes_for_spec(spec.value_spec))
return tokens
示例15: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import container [as 别名]
def run(self):
self.assert_has_content()
text = '\n'.join(self.content)
node = nodes.container(text)
node['classes'].append('example-code')
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]