本文整理汇总了Python中docutils.nodes.figure方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.figure方法的具体用法?Python nodes.figure怎么用?Python nodes.figure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.figure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_caption_option
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def test_caption_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir)
text = (".. rackdiag::\n"
" :caption: hello world\n"
"\n"
" 1: server\n"
" 2: database\n")
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(1, len(doctree[0][1]))
self.assertEqual(nodes.Text, type(doctree[0][1][0]))
self.assertEqual('hello world', doctree[0][1][0])
示例2: test_caption_option_and_align_option
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def test_caption_option_and_align_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir)
text = (".. rackdiag::\n"
" :align: left\n"
" :caption: hello world\n"
"\n"
" 1: server\n"
" 2: database\n")
doctree = publish_doctree(text)
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.figure, type(doctree[0]))
self.assertEqual('left', doctree[0]['align'])
self.assertEqual(2, len(doctree[0]))
self.assertEqual(nodes.image, type(doctree[0][0]))
self.assertNotIn('align', doctree[0][0])
self.assertEqual(nodes.caption, type(doctree[0][1]))
self.assertEqual(1, len(doctree[0][1]))
self.assertEqual(nodes.Text, type(doctree[0][1][0]))
self.assertEqual('hello world', doctree[0][1][0])
示例3: test_caption_option_and_align_option
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def test_caption_option_and_align_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir)
text = (".. packetdiag::\n"
" :align: left\n"
" :caption: hello world\n"
"\n"
" 1: server\n"
" 2: database\n")
doctree = publish_doctree(text)
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.figure, type(doctree[0]))
self.assertEqual('left', doctree[0]['align'])
self.assertEqual(2, len(doctree[0]))
self.assertEqual(nodes.image, type(doctree[0][0]))
self.assertNotIn('align', doctree[0][0])
self.assertEqual(nodes.caption, type(doctree[0][1]))
self.assertEqual(1, len(doctree[0][1]))
self.assertEqual(nodes.Text, type(doctree[0][1][0]))
self.assertEqual('hello world', doctree[0][1][0])
示例4: test_caption_option
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def test_caption_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir)
text = (".. nwdiag::\n"
" :caption: hello world\n"
"\n"
" network {"
" 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(1, len(doctree[0][1]))
self.assertEqual(nodes.Text, type(doctree[0][1][0]))
self.assertEqual('hello world', doctree[0][1][0])
示例5: test_caption_option2
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [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])
示例6: test_caption_option_and_align_option
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def test_caption_option_and_align_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir)
text = (".. blockdiag::\n"
" :align: left\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('left', doctree[0]['align'])
self.assertEqual(2, len(doctree[0]))
self.assertEqual(nodes.image, type(doctree[0][0]))
self.assertNotIn('align', doctree[0][0])
self.assertEqual(nodes.caption, type(doctree[0][1]))
self.assertEqual(1, len(doctree[0][1]))
self.assertEqual(nodes.Text, type(doctree[0][1][0]))
self.assertEqual('hello world', doctree[0][1][0])
示例7: test_caption_option_and_align_option
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def test_caption_option_and_align_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir)
text = (".. seqdiag::\n"
" :align: left\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('left', doctree[0]['align'])
self.assertEqual(2, len(doctree[0]))
self.assertEqual(nodes.image, type(doctree[0][0]))
self.assertNotIn('align', doctree[0][0])
self.assertEqual(nodes.caption, type(doctree[0][1]))
self.assertEqual(1, len(doctree[0][1]))
self.assertEqual(nodes.Text, type(doctree[0][1][0]))
self.assertEqual('hello world', doctree[0][1][0])
示例8: figure_wrapper
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def figure_wrapper(directive, node, caption):
# type: (Directive, nodes.Node, unicode) -> nodes.figure
figure_node = nodes.figure('', node)
if 'align' in node:
figure_node['align'] = node.attributes.pop('align')
parsed = nodes.Element()
directive.state.nested_parse(ViewList([caption], source=''),
directive.content_offset, parsed)
caption_node = nodes.caption(parsed[0].rawsource, '',
*parsed[0].children)
caption_node.source = parsed[0].source
caption_node.line = parsed[0].line
figure_node += caption_node
return figure_node
示例9: visit_citation
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def visit_citation(self, node):
# TODO maybe use cite bibitems
if self._use_latex_citations:
self.push_output_collector([])
else:
# TODO: do we need these?
## self.requirements['~fnt_floats'] = PreambleCmds.footnote_floats
self.out.append(r'\begin{figure}[b]')
self.append_hypertargets(node)
示例10: depart_citation
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def depart_citation(self, node):
if self._use_latex_citations:
label = self.out[0]
text = ''.join(self.out[1:])
self._bibitems.append([label, text])
self.pop_output_collector()
else:
self.out.append('\\end{figure}\n')
示例11: visit_figure
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def visit_figure(self, node):
self.requirements['float_settings'] = PreambleCmds.float_settings
# The 'align' attribute sets the "outer alignment",
# for "inner alignment" use LaTeX default alignment (similar to HTML)
alignment = node.attributes.get('align', 'center')
if alignment != 'center':
# The LaTeX "figure" environment always uses the full linewidth,
# so "outer alignment" is ignored. Just write a comment.
# TODO: use the wrapfigure environment?
self.out.append('\n\\begin{figure} %% align = "%s"\n' % alignment)
else:
self.out.append('\n\\begin{figure}\n')
if node.get('ids'):
self.out += self.ids_to_labels(node) + ['\n']
示例12: depart_figure
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def depart_figure(self, node):
self.out.append('\\end{figure}\n')
示例13: visit_figure
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def visit_figure(self, node):
self.requirements['float_settings'] = PreambleCmds.float_settings
self.duclass_open(node)
# The 'align' attribute sets the "outer alignment",
# for "inner alignment" use LaTeX default alignment (similar to HTML)
alignment = node.attributes.get('align', 'center')
if alignment != 'center':
# The LaTeX "figure" environment always uses the full linewidth,
# so "outer alignment" is ignored. Just write a comment.
# TODO: use the wrapfigure environment?
self.out.append('\\begin{figure} %% align = "%s"\n' % alignment)
else:
self.out.append('\\begin{figure}\n')
if node.get('ids'):
self.out += self.ids_to_labels(node) + ['\n']
示例14: depart_figure
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [as 别名]
def depart_figure(self, node):
self.out.append('\\end{figure}\n')
self.duclass_close(node)
示例15: get_debug_containter
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import figure [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