当前位置: 首页>>代码示例>>Python>>正文


Python nodes.caption方法代码示例

本文整理汇总了Python中docutils.nodes.caption方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.caption方法的具体用法?Python nodes.caption怎么用?Python nodes.caption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docutils.nodes的用法示例。


在下文中一共展示了nodes.caption方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _container_wrapper

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [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 
开发者ID:NextThought,项目名称:sphinxcontrib-programoutput,代码行数:21,代码来源:__init__.py

示例2: assert_output

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [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')) 
开发者ID:NextThought,项目名称:sphinxcontrib-programoutput,代码行数:20,代码来源:test_directive.py

示例3: test_caption_option

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [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]) 
开发者ID:blockdiag,项目名称:nwdiag,代码行数:18,代码来源:test_rst_directives.py

示例4: test_caption_option_and_align_option

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [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]) 
开发者ID:blockdiag,项目名称:nwdiag,代码行数:21,代码来源:test_rst_directives.py

示例5: test_caption_option_and_align_option

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [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]) 
开发者ID:blockdiag,项目名称:nwdiag,代码行数:21,代码来源:test_rst_directives.py

示例6: figure_wrapper

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [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 
开发者ID:kevinpt,项目名称:symbolator,代码行数:17,代码来源:symbolator_sphinx.py

示例7: open

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [as 别名]
def open(self):
        self._open = True
        self._col_specs = []
        self.caption = []
        self._attrs = {}
        self._in_head = False # maybe context with search 
开发者ID:skarlekar,项目名称:faces,代码行数:8,代码来源:__init__.py

示例8: close

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [as 别名]
def close(self):
        self._open = False
        self._col_specs = None
        self.caption = []
        self._attrs = {}
        self.stubs = []
        self.colwidths_auto = False 
开发者ID:skarlekar,项目名称:faces,代码行数:9,代码来源:__init__.py

示例9: get_latex_type

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [as 别名]
def get_latex_type(self):
        if self._latex_type == 'longtable' and not self.caption:
            # do not advance the "table" counter (requires "ltcaption" package)
            return('longtable*')
        return self._latex_type 
开发者ID:skarlekar,项目名称:faces,代码行数:7,代码来源:__init__.py

示例10: get_caption

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [as 别名]
def get_caption(self):
        if not self.caption:
            return ''
        caption = ''.join(self.caption)
        if 1 == self._translator.thead_depth():
            return r'\caption{%s}\\' '\n' % caption
        return r'\caption[]{%s (... continued)}\\' '\n' % caption 
开发者ID:skarlekar,项目名称:faces,代码行数:9,代码来源:__init__.py

示例11: depart_table

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [as 别名]
def depart_table(self, node):
        # wrap content in the right environment:
        content = self.out
        self.pop_output_collector()
        self.out.append('\n' + self.active_table.get_opening())
        self.out += content
        self.out.append(self.active_table.get_closing() + '\n')
        self.active_table.close()
        if len(self.table_stack)>0:
            self.active_table = self.table_stack.pop()
        # Insert hyperlabel after (long)table, as
        # other places (beginning, caption) result in LaTeX errors.
        if node.get('ids'):
            self.out += self.ids_to_labels(node, set_anchor=False) + ['\n'] 
开发者ID:skarlekar,项目名称:faces,代码行数:16,代码来源:__init__.py

示例12: visit_target

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import caption [as 别名]
def visit_target(self, node):
        # Skip indirect targets:
        if ('refuri' in node       # external hyperlink
            or 'refid' in node     # resolved internal link
            or 'refname' in node): # unresolved internal link
            ## self.out.append('%% %s\n' % node)   # for debugging
            return
        self.out.append('%\n')
        # do we need an anchor (\phantomsection)?
        set_anchor = not(isinstance(node.parent, nodes.caption) or
                         isinstance(node.parent, nodes.title))
        # TODO: where else can/must we omit the \phantomsection?
        self.out += self.ids_to_labels(node, set_anchor) 
开发者ID:skarlekar,项目名称:faces,代码行数:15,代码来源:__init__.py


注:本文中的docutils.nodes.caption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。