當前位置: 首頁>>代碼示例>>Python>>正文


Python nodes.Admonition方法代碼示例

本文整理匯總了Python中docutils.nodes.Admonition方法的典型用法代碼示例。如果您正苦於以下問題:Python nodes.Admonition方法的具體用法?Python nodes.Admonition怎麽用?Python nodes.Admonition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在docutils.nodes的用法示例。


在下文中一共展示了nodes.Admonition方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def run(self):
        env = self.state.document.settings.env
        targetid = "tag-%d" % env.new_serialno('tag')
        targetnode = nodes.target('', '', ids=[targetid])

        # The tags fetched from the custom directive are one piece of text
        # sitting in self.content[0]
        taggs = self.content[0].split(", ")
        links = []

        for tagg in taggs:
            # Create Sphinx doc refs of format :ref:`Tagname<Tagname>`
            link = ":ref:`" + tagg + "<" + tagg + ">`"
            links.append(link)
        # Put links back in a single comma-separated string together
        linkjoin = ", ".join(links)

        # Replace content[0] with hyperlinks to display in admonition
        self.content[0] = linkjoin

        ad = Admonition(self.name, [_('Tags')], self.options,
                        self.content, self.lineno, self.content_offset,
                        self.block_text, self.state, self.state_machine)

        return [targetnode] + ad.run() 
開發者ID:mdolab,項目名稱:openconcept,代碼行數:27,代碼來源:tags.py

示例2: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def run(self):
        return [Todolist('')]




# Admonition classes are like notes or warnings 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:9,代碼來源:qt_doc.py

示例3: visit_title

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def visit_title(self, node):
        if isinstance(node.parent, nodes.Admonition):
            self.add_text(node.astext()+': ')
            raise nodes.SkipNode
        self.new_state(0) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:7,代碼來源:textwriter.py

示例4: apply

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def apply(self):
        language = languages.get_language(self.document.settings.language_code,
                                          self.document.reporter)
        for node in self.document.traverse(nodes.Admonition):
            node_name = node.__class__.__name__
            # Set class, so that we know what node this admonition came from.
            node['classes'].append(node_name)
            if not isinstance(node, nodes.admonition):
                # Specific admonition.  Transform into a generic admonition.
                admonition = nodes.admonition(node.rawsource, *node.children,
                                              **node.attributes)
                title = nodes.title('', language.labels[node_name])
                admonition.insert(0, title)
                node.replace_self(admonition) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:16,代碼來源:writer_aux.py

示例5: visit_title

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def visit_title(self, node):
        """Only 6 section levels are supported by HTML."""
        check_id = 0  # TODO: is this a bool (False) or a counter?
        close_tag = '</p>\n'
        if isinstance(node.parent, nodes.topic):
            self.body.append(
                  self.starttag(node, 'p', '', CLASS='topic-title first'))
        elif isinstance(node.parent, nodes.sidebar):
            self.body.append(
                  self.starttag(node, 'p', '', CLASS='sidebar-title'))
        elif isinstance(node.parent, nodes.Admonition):
            self.body.append(
                  self.starttag(node, 'p', '', CLASS='admonition-title'))
        elif isinstance(node.parent, nodes.table):
            self.body.append(
                  self.starttag(node, 'caption', ''))
            close_tag = '</caption>\n'
        elif isinstance(node.parent, nodes.document):
            self.body.append(self.starttag(node, 'h1', '', CLASS='title'))
            close_tag = '</h1>\n'
            self.in_document_title = len(self.body)
        else:
            assert isinstance(node.parent, nodes.section)
            h_level = self.section_level + self.initial_header_level - 1
            atts = {}
            if (len(node.parent) >= 2 and
                isinstance(node.parent[1], nodes.subtitle)):
                atts['CLASS'] = 'with-subtitle'
            self.body.append(
                  self.starttag(node, 'h%s' % h_level, '', **atts))
            atts = {}
            if node.hasattr('refid'):
                atts['class'] = 'toc-backref'
                atts['href'] = '#' + node['refid']
            if atts:
                self.body.append(self.starttag({}, 'a', '', **atts))
                close_tag = '</a></h%s>\n' % (h_level)
            else:
                close_tag = '</h%s>\n' % (h_level)
        self.context.append(close_tag) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:42,代碼來源:_html_base.py

示例6: visit_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def visit_paragraph(self, node):
        if not isinstance(node.parent, nodes.Admonition) or \
               isinstance(node.parent, addnodes.seealso):
            self.new_state(0) 
開發者ID:sphinx-contrib,項目名稱:restbuilder,代碼行數:6,代碼來源:rst.py

示例7: depart_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def depart_paragraph(self, node):
        if not isinstance(node.parent, nodes.Admonition) or \
               isinstance(node.parent, addnodes.seealso):
            self.end_state() 
開發者ID:sphinx-contrib,項目名稱:restbuilder,代碼行數:6,代碼來源:rst.py

示例8: visit_title

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def visit_title(self, node):
        if isinstance(node.parent, nodes.Admonition):
            self.add_text(node.astext() + ': ')
            raise nodes.SkipNode
        self.new_state(0) 
開發者ID:openstack,項目名稱:releases,代碼行數:7,代碼來源:rst2txt.py

示例9: visit_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Admonition [as 別名]
def visit_paragraph(self, node):
        if not isinstance(node.parent, nodes.Admonition) or \
           isinstance(node.parent, addnodes.seealso):
            self.new_state(0) 
開發者ID:openstack,項目名稱:releases,代碼行數:6,代碼來源:rst2txt.py


注:本文中的docutils.nodes.Admonition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。