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


Python nodes.Invisible方法代碼示例

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


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

示例1: apply

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def apply(self):
        pending = self.startnode
        parent = pending.parent
        child = pending
        while parent:
            # Check for appropriate following siblings:
            for index in range(parent.index(child) + 1, len(parent)):
                element = parent[index]
                if (isinstance(element, nodes.Invisible) or
                    isinstance(element, nodes.system_message)):
                    continue
                element['classes'] += pending.details['class']
                pending.parent.remove(pending)
                return
            else:
                # At end of section or container; apply to sibling
                child = parent
                parent = parent.parent
        error = self.document.reporter.error(
            'No suitable element following "%s" directive'
            % pending.details['directive'],
            nodes.literal_block(pending.rawsource, pending.rawsource),
            line=pending.line)
        pending.replace_self(error) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:26,代碼來源:misc.py

示例2: visit_list_item

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def visit_list_item(self, node):
        # print "visiting list item", node.__class__
        children = [child for child in node.children
                    if not isinstance(child, nodes.Invisible)]
        # print "has %s visible children" % len(children)
        if (children and isinstance(children[0], nodes.paragraph)
            and (isinstance(children[-1], nodes.bullet_list) or
                 isinstance(children[-1], nodes.enumerated_list) or
                 isinstance(children[-1], nodes.field_list))):
            children.pop()
        # print "%s children remain" % len(children)
        if len(children) <= 1:
            return
        else:
            # print "found", child.__class__, "in", node.__class__
            raise nodes.NodeFound 
開發者ID:skarlekar,項目名稱:faces,代碼行數:18,代碼來源:_html_base.py

示例3: visit_list_item

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def visit_list_item(self, node):
        children = []
        for child in node.children:
            if not isinstance(child, nodes.Invisible):
                children.append(child)
        if (children and isinstance(children[0], nodes.paragraph)
            and (isinstance(children[-1], nodes.bullet_list)
                 or isinstance(children[-1], nodes.enumerated_list))):
            children.pop()
        if len(children) <= 1:
            return
        else:
            raise nodes.NodeFound

    # def visit_bullet_list(self, node):
    #     pass

    # def visit_enumerated_list(self, node):
    #     pass

    # def visit_paragraph(self, node):
    #     raise nodes.SkipNode 
開發者ID:MattTunny,項目名稱:AWS-Transit-Gateway-Demo-MultiAccount,代碼行數:24,代碼來源:__init__.py

示例4: apply

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def apply(self):
        for compound in self.document.traverse(nodes.compound):
            first_child = True
            for child in compound:
                if first_child:
                    if not isinstance(child, nodes.Invisible):
                        first_child = False
                else:
                    child['classes'].append('continued')
            # Substitute children for compound.
            compound.replace_self(compound[:]) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:13,代碼來源:writer_aux.py

示例5: visit_field_list

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def visit_field_list(self, node):
        self.context.append((self.compact_field_list, self.compact_p))
        self.compact_p = None
        if 'compact' in node['classes']:
            self.compact_field_list = True
        elif (self.settings.compact_field_lists
              and 'open' not in node['classes']):
            self.compact_field_list = True
        if self.compact_field_list:
            for field in node:
                field_body = field[-1]
                assert isinstance(field_body, nodes.field_body)
                children = [n for n in field_body
                            if not isinstance(n, nodes.Invisible)]
                if not (len(children) == 0 or
                        len(children) == 1 and
                        isinstance(children[0],
                                   (nodes.paragraph, nodes.line_block))):
                    self.compact_field_list = False
                    break
        self.body.append(self.starttag(node, 'table', frame='void',
                                       rules='none',
                                       CLASS='docutils field-list'))
        self.body.append('<col class="field-name" />\n'
                         '<col class="field-body" />\n'
                         '<tbody valign="top">\n') 
開發者ID:skarlekar,項目名稱:faces,代碼行數:28,代碼來源:__init__.py

示例6: should_be_compact_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def should_be_compact_paragraph(self, node):
        """
        Determine if the <p> tags around paragraph ``node`` can be omitted.
        """
        if (isinstance(node.parent, nodes.document) or
            isinstance(node.parent, nodes.compound)):
            # Never compact paragraphs in document or compound.
            return False
        for key, value in node.attlist():
            if (node.is_not_default(key) and
                not (key == 'classes' and value in
                     ([], ['first'], ['last'], ['first', 'last']))):
                # Attribute which needs to survive.
                return False
        first = isinstance(node.parent[0], nodes.label) # skip label
        for child in node.parent.children[first:]:
            # only first paragraph can be compact
            if isinstance(child, nodes.Invisible):
                continue
            if child is node:
                break
            return False
        parent_length = len([n for n in node.parent if not isinstance(
            n, (nodes.Invisible, nodes.label))])
        if ( self.compact_simple
             or self.compact_field_list
             or self.compact_p and parent_length == 1):
            return True
        return False 
開發者ID:skarlekar,項目名稱:faces,代碼行數:31,代碼來源:__init__.py

示例7: first_child

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def first_child(self, node):
        first = isinstance(node.parent[0], nodes.label) # skip label
        for child in node.parent.children[first:]:
            if isinstance(child, nodes.Invisible):
                continue
            if child is node:
                return 1
            break
        return 0 
開發者ID:skarlekar,項目名稱:faces,代碼行數:11,代碼來源:manpage.py

示例8: set_class_on_child

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import Invisible [as 別名]
def set_class_on_child(self, node, class_, index=0):
        """
        Set class `class_` on the visible child no. index of `node`.
        Do nothing if node has fewer children than `index`.
        """
        children = [n for n in node if not isinstance(n, nodes.Invisible)]
        try:
            child = children[index]
        except IndexError:
            return
        child['classes'].append(class_) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:13,代碼來源:_html_base.py


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