當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。