Python docutils.nodes.figure() Examples
The following are 30
code examples of docutils.nodes.figure().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
docutils.nodes
, or try the search function
.
Example #1
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 6 votes |
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])
Example #2
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 6 votes |
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])
Example #3
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 6 votes |
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])
Example #4
Source File: test_blockdiag_directives.py From blockdiag with Apache License 2.0 | 6 votes |
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])
Example #5
Source File: test_blockdiag_directives.py From blockdiag with Apache License 2.0 | 6 votes |
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])
Example #6
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 6 votes |
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])
Example #7
Source File: test_rst_directives.py From seqdiag with Apache License 2.0 | 6 votes |
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])
Example #8
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 5 votes |
def test_figclass_option(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. nwdiag::\n" " :caption: hello world\n" " :figclass: baz\n" "\n" " network {" " A" " B" " }") doctree = publish_doctree(text) self.assertEqual(1, len(doctree)) self.assertEqual(nodes.figure, type(doctree[0])) self.assertEqual(['baz'], doctree[0]['classes'])
Example #9
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 5 votes |
def test_figclass_option(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. rackdiag::\n" " :caption: hello world\n" " :figclass: baz\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(['baz'], doctree[0]['classes'])
Example #10
Source File: numfig.py From factor with GNU General Public License v2.0 | 5 votes |
def doctree_resolved(app, doctree, docname): i = 1 figids = {} for figure_info in doctree.traverse(figure): if app.builder.name != 'latex' and app.config.number_figures: for cap in figure_info.traverse(caption): cap[0] = Text("%s %d: %s" % (app.config.figure_caption_prefix, i, cap[0])) for id in figure_info['ids']: figids[id] = i i += 1 # replace numfig nodes with links if app.builder.name != 'latex': for ref_info in doctree.traverse(num_ref): if '#' in ref_info['reftarget']: label, target = ref_info['reftarget'].split('#') labelfmt = label + " %d" else: labelfmt = '%d' target = ref_info['reftarget'] if target not in figids: continue if app.builder.name == 'html': target_doc = app.builder.env.figid_docname_map[target] link = "%s#%s" % (app.builder.get_relative_uri(docname, target_doc), target) html = '<a class="pageref" href="%s">%s</a>' % (link, labelfmt %(figids[target])) ref_info.replace_self(raw(html, html, format='html')) else: ref_info.replace_self(Text(labelfmt % (figids[target])))
Example #11
Source File: numfig.py From factor with GNU General Public License v2.0 | 5 votes |
def doctree_read(app, doctree): # first generate figure numbers for each figure env = app.builder.env figid_docname_map = getattr(env, 'figid_docname_map', {}) for figure_info in doctree.traverse(figure): for id in figure_info['ids']: figid_docname_map[id] = env.docname env.figid_docname_map = figid_docname_map
Example #12
Source File: test_blockdiag_directives.py From blockdiag with Apache License 2.0 | 5 votes |
def test_figclass_option(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. blockdiag::\n" " :caption: hello world\n" " :figclass: baz\n" "\n" " A -> B") doctree = publish_doctree(text) self.assertEqual(1, len(doctree)) self.assertEqual(nodes.figure, type(doctree[0])) self.assertEqual(['baz'], doctree[0]['classes'])
Example #13
Source File: test_blockdiag_directives.py From blockdiag with Apache License 2.0 | 5 votes |
def test_figwidth_option1(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. blockdiag::\n" " :caption: hello world\n" " :figwidth: 100\n" "\n" " A -> B") doctree = publish_doctree(text) self.assertEqual(1, len(doctree)) self.assertEqual(nodes.figure, type(doctree[0])) self.assertEqual('100px', doctree[0]['width'])
Example #14
Source File: test_blockdiag_directives.py From blockdiag with Apache License 2.0 | 5 votes |
def test_caption_option(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(1, len(doctree[0][1])) self.assertEqual(nodes.Text, type(doctree[0][1][0])) self.assertEqual('hello world', doctree[0][1][0])
Example #15
Source File: test_rst_directives.py From seqdiag with Apache License 2.0 | 5 votes |
def test_caption_option(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. seqdiag::\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(1, len(doctree[0][1])) self.assertEqual(nodes.Text, type(doctree[0][1][0])) self.assertEqual('hello world', doctree[0][1][0])
Example #16
Source File: test_rst_directives.py From seqdiag with Apache License 2.0 | 5 votes |
def test_figwidth_option1(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. seqdiag::\n" " :caption: hello world\n" " :figwidth: 100\n" "\n" " A -> B") doctree = publish_doctree(text) self.assertEqual(1, len(doctree)) self.assertEqual(nodes.figure, type(doctree[0])) self.assertEqual('100px', doctree[0]['width'])
Example #17
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 5 votes |
def test_figwidth_option2(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. packetdiag::\n" " :caption: hello world\n" " :figwidth: image\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('200px', doctree[0]['width'])
Example #18
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 5 votes |
def test_figclass_option(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. packetdiag::\n" " :caption: hello world\n" " :figclass: baz\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(['baz'], doctree[0]['classes'])
Example #19
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 5 votes |
def test_figwidth_option1(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. packetdiag::\n" " :caption: hello world\n" " :figwidth: 100\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('100px', doctree[0]['width'])
Example #20
Source File: test_rst_directives.py From nwdiag with Apache License 2.0 | 5 votes |
def test_figwidth_option1(self): directives.setup(format='SVG', outputdir=self.tmpdir) text = (".. rackdiag::\n" " :caption: hello world\n" " :figwidth: 100\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('100px', doctree[0]['width'])
Example #21
Source File: ansi.py From python-rst2ansi with MIT License | 5 votes |
def depart_image(self, node): if type(node.parent) == nodes.figure: self.visit_reference(node) self.append('[' + node.attributes.get('alt', 'Image') + ']') self.depart_reference(node) self.newline() else: self.append('[' + node.attributes.get('alt', 'Image') + ']')
Example #22
Source File: __init__.py From aws-extender with MIT License | 5 votes |
def depart_figure(self, node): self.out.append('\\end{figure}\n') self.duclass_close(node)
Example #23
Source File: __init__.py From aws-extender with MIT License | 5 votes |
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']
Example #24
Source File: __init__.py From aws-extender with MIT License | 5 votes |
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')
Example #25
Source File: __init__.py From aws-extender with MIT License | 5 votes |
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)
Example #26
Source File: symbolator_sphinx.py From symbolator with MIT License | 5 votes |
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
Example #27
Source File: __init__.py From blackmamba with MIT License | 5 votes |
def depart_figure(self, node): self.out.append('\\end{figure}\n') self.duclass_close(node)
Example #28
Source File: __init__.py From blackmamba with MIT License | 5 votes |
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']
Example #29
Source File: __init__.py From blackmamba with MIT License | 5 votes |
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')
Example #30
Source File: __init__.py From blackmamba with MIT License | 5 votes |
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)