当前位置: 首页>>代码示例>>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;未经允许,请勿转载。