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


Python nodes.section方法代码示例

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


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

示例1: ensureUniqueIDs

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def ensureUniqueIDs(items):
    """
    If action groups are repeated, then links in the table of contents will
    just go to the first of the repeats. This may not be desirable, particularly
    in the case of subcommands where the option groups have different members.
    This function updates the title IDs by adding _repeatX, where X is a number
    so that the links are then unique.
    """
    s = set()
    for item in items:
        for n in item.traverse(descend=True, siblings=True, ascend=False):
            if isinstance(n, nodes.section):
                ids = n['ids']
                for idx, id in enumerate(ids):
                    if id not in s:
                        s.add(id)
                    else:
                        i = 1
                        while "{}_repeat{}".format(id, i) in s:
                            i += 1
                        ids[idx] = "{}_repeat{}".format(id, i)
                        s.add(ids[idx])
                n['ids'] = ids 
开发者ID:rucio,项目名称:rucio,代码行数:25,代码来源:ext.py

示例2: apply

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [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

示例3: new_subsection

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def new_subsection(self, title, lineno, messages):
        """Append new subsection to document tree. On return, check level."""
        memo = self.memo
        mylevel = memo.section_level
        memo.section_level += 1
        section_node = nodes.section()
        self.parent += section_node
        textnodes, title_messages = self.inline_text(title, lineno)
        titlenode = nodes.title(title, '', *textnodes)
        name = normalize_name(titlenode.astext())
        section_node['names'].append(name)
        section_node += titlenode
        section_node += messages
        section_node += title_messages
        self.document.note_implicit_target(section_node, section_node)
        offset = self.state_machine.line_offset + 1
        absoffset = self.state_machine.abs_line_offset() + 1
        newabsoffset = self.nested_parse(
              self.state_machine.input_lines[offset:], input_offset=absoffset,
              node=section_node, match_titles=True)
        self.goto_line(newabsoffset)
        if memo.section_level <= mylevel: # can't handle next section?
            raise EOFError              # bubble up to supersection
        # reset section_level; next pass will detect it properly
        memo.section_level = mylevel 
开发者ID:skarlekar,项目名称:faces,代码行数:27,代码来源:states.py

示例4: update_section_numbers

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def update_section_numbers(self, node, prefix=(), depth=0):
        depth += 1
        if prefix:
            sectnum = 1
        else:
            sectnum = self.startvalue
        for child in node:
            if isinstance(child, nodes.section):
                numbers = prefix + (str(sectnum),)
                title = child[0]
                # Use &nbsp; for spacing:
                generated = nodes.generated(
                    '', (self.prefix + '.'.join(numbers) + self.suffix
                         +  u'\u00a0' * 3),
                    classes=['sectnum'])
                title.insert(0, generated)
                title['auto'] = 1
                if depth < self.maxdepth:
                    self.update_section_numbers(child, numbers, depth)
                sectnum += 1 
开发者ID:skarlekar,项目名称:faces,代码行数:22,代码来源:parts.py

示例5: line

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def line(self, match, context, next_state):
        """Section title overline or transition marker."""
        if self.state_machine.match_titles:
            return [match.string], 'Line', []
        elif match.string.strip() == '::':
            raise statemachine.TransitionCorrection('text')
        elif len(match.string.strip()) < 4:
            msg = self.reporter.info(
                'Unexpected possible title overline or transition.\n'
                "Treating it as ordinary text because it's so short.",
                line=self.state_machine.abs_line_number())
            self.parent += msg
            raise statemachine.TransitionCorrection('text')
        else:
            blocktext = self.state_machine.line
            msg = self.reporter.severe(
                  'Unexpected section title or transition.',
                  nodes.literal_block(blocktext, blocktext),
                  line=self.state_machine.abs_line_number())
            self.parent += msg
            return [], next_state, [] 
开发者ID:skarlekar,项目名称:faces,代码行数:23,代码来源:states.py

示例6: visit_section

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def visit_section(self, node: section):
        """Begin ``section`` node.

        - Find first ``revealjs_section`` node and build attributes string.
        - When enter next section, nest level.
        """
        self.section_level += 1
        meta = find_child_section(node, "revealjs_section")
        if meta is not None:
            attrs = meta.attributes_str()
        else:
            attrs = ""
        if self.section_level == 1:
            self.builder.revealjs_slide = find_child_section(node, "revealjs_slide")
            self._proc_first_on_section = True
            self.body.append("<section>\n")
            return
        if self._proc_first_on_section:
            self._proc_first_on_section = False
            self.body.append("</section>\n")
        self.body.append(f"<section {attrs}>\n")
        if has_child_sections(node, "section"):
            self._proc_first_on_section = True
            self.body.append("<section>\n") 
开发者ID:attakei,项目名称:sphinx-revealjs,代码行数:26,代码来源:writers.py

示例7: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def run(self):
        module = self.options.get("module")
        attr = self.options.get("attr")
        parser = get_parser(module, attr)

        self._available_options = []
        for group in parser.groups:
            for arg in group.arguments:
                self._available_options += arg.args

        node = nodes.section()
        node.document = self.state.document
        result = ViewList()
        for line in self.generate_parser_rst(parser):
            result.append(line, "argparse")

        nested_parse_with_titles(self.state, result, node)
        return node.children 
开发者ID:streamlink,项目名称:streamlink,代码行数:20,代码来源:ext_argparse.py

示例8: process_autosummary_toc

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def process_autosummary_toc(app, doctree):
    """Insert items described in autosummary:: to the TOC tree, but do
    not generate the toctree:: list.
    """
    #print "DEBUG: process_autosummary_toc"
    env = app.builder.env
    crawled = {}

    def crawl_toc(node, depth=1):
        crawled[node] = True
        for j, subnode in enumerate(node):
            #print "DEBUG: processing ",(j,subnode)
            try:
                if (isinstance(subnode, autosummary_toc) and
                        isinstance(subnode[0], addnodes.toctree)):
                    env.note_toctree(env.docname, subnode[0])
                    #print "DEBUG: ADDIND DOC!"
                    continue
            except IndexError:
                #print "DEBUG: indexerror"
                continue
            if not isinstance(subnode, nodes.section):
                #print "DEBUG: not instance"
                continue
            if subnode not in crawled:
                crawl_toc(subnode, depth+1)
    crawl_toc(doctree) 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:29,代码来源:autosummary__init__.py

示例9: genetic_map_section

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def genetic_map_section(self, species, genetic_map):
        map_id = self.get_genetic_map_id(species, genetic_map)
        target = self.get_target(map_id)
        section = nodes.section(ids=[map_id])
        section += nodes.title(text=genetic_map.id)
        section += nodes.paragraph(text=genetic_map.long_description)
        section += nodes.rubric(text="Citations")
        section += self.citation_list(genetic_map)
        return [target, section] 
开发者ID:popsim-consortium,项目名称:stdpopsim,代码行数:11,代码来源:speciescatalog.py

示例10: model_section

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def model_section(self, species, model):
        mid = self.get_demographic_model_id(species, model)
        target = self.get_target(mid)
        section = nodes.section(ids=[mid])
        section += nodes.title(text=model.description)
        section += nodes.paragraph(text=model.long_description)
        section += nodes.rubric(text="Details")
        section += self.model_summary(model)
        section += nodes.rubric(text="Populations")
        section += self.population_table(model)
        section += nodes.rubric(text="Citations")
        section += self.citation_list(model)
        section += nodes.rubric(text="Demographic Model parameters")
        section += self.model_parameter_table(species, model)
        return [target, section] 
开发者ID:popsim-consortium,项目名称:stdpopsim,代码行数:17,代码来源:speciescatalog.py

示例11: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def run(self):
        species = stdpopsim.get_species(self.arguments[0])
        sid = f"sec_catalog_{species.id}"
        species_target = self.get_target(sid)
        section = nodes.section(ids=[sid], names=[sid])
        section += nodes.title(text=species.name)
        section += self.species_summary(species)

        genome_section = nodes.section(ids=[f"sec_catalog_{species.id}_genome"])
        genome_section += nodes.title(text="Genome")
        genome_section += self.chromosomes_table(species)
        section += genome_section
        section += nodes.transition()

        maps_section = nodes.section(ids=[f"sec_catalog_{species.id}_genetic_maps"])
        maps_section += nodes.title(text="Genetic Maps")
        maps_section += self.genetic_maps_table(species)
        for gmap in species.genetic_maps:
            maps_section += self.genetic_map_section(species, gmap)
        section += maps_section
        section += nodes.transition()
        models_section = nodes.section(ids=[f"sec_catalog_{species.id}_models"])
        models_section += nodes.title(text="Models")
        models_section += self.models_table(species)
        for i, model in enumerate(species.demographic_models):
            models_section += self.model_section(species, model)
            if i < len(species.demographic_models) - 1:
                models_section += nodes.transition()
        section += models_section
        return [species_target, section] 
开发者ID:popsim-consortium,项目名称:stdpopsim,代码行数:32,代码来源:speciescatalog.py

示例12: autohelp_directive

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def autohelp_directive(dirname, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
    """produces rst from nose help"""
    config = Config(parserClass=OptBucket,
                    plugins=BuiltinPluginManager())
    parser = config.getParser(TestProgram.usage())
    rst = ViewList()
    for line in parser.format_help().split('\n'):
        rst.append(line, '<autodoc>')

    rst.append('Options', '<autodoc>')
    rst.append('-------', '<autodoc>')
    rst.append('', '<autodoc>')
    for opt in parser:
        rst.append(opt.options(), '<autodoc>')
        rst.append('   \n', '<autodoc>')
        rst.append('   ' + opt.help + '\n', '<autodoc>')
        rst.append('\n', '<autodoc>')    
    node = nodes.section()
    node.document = state.document
    surrounding_title_styles = state.memo.title_styles
    surrounding_section_level = state.memo.section_level
    state.memo.title_styles = []
    state.memo.section_level = 0
    state.nested_parse(rst, 0, node, match_titles=1)
    state.memo.title_styles = surrounding_title_styles
    state.memo.section_level = surrounding_section_level

    return node.children 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:31,代码来源:pluginopts.py

示例13: depart_title

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def depart_title(self, node):
        if isinstance(node.parent, nodes.section):
            char = self._title_char
        else:
            char = '^'
        text = ''.join(x[1] for x in self.states.pop() if x[0] == -1)
        self.stateindent.pop()
        self.states[-1].append((0, ['', text, '%s' % (char * len(text)), ''])) 
开发者ID:skarlekar,项目名称:faces,代码行数:10,代码来源:textwriter.py

示例14: apply

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def apply(self):
        doc = self.document
        i = len(doc) - 1
        refsect = copyright = None
        while i >= 0 and isinstance(doc[i], nodes.section):
            title_words = doc[i][0].astext().lower().split()
            if 'references' in title_words:
                refsect = doc[i]
                break
            elif 'copyright' in title_words:
                copyright = i
            i -= 1
        if not refsect:
            refsect = nodes.section()
            refsect += nodes.title('', 'References')
            doc.set_id(refsect)
            if copyright:
                # Put the new "References" section before "Copyright":
                doc.insert(copyright, refsect)
            else:
                # Put the new "References" section at end of doc:
                doc.append(refsect)
        pending = nodes.pending(references.TargetNotes)
        refsect.append(pending)
        self.document.note_pending(pending, 0)
        pending = nodes.pending(misc.CallBack,
                                details={'callback': self.cleanup_callback})
        refsect.append(pending)
        self.document.note_pending(pending, 1) 
开发者ID:skarlekar,项目名称:faces,代码行数:31,代码来源:peps.py

示例15: cleanup_callback

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import section [as 别名]
def cleanup_callback(self, pending):
        """
        Remove an empty "References" section.

        Called after the `references.TargetNotes` transform is complete.
        """
        if len(pending.parent) == 2:    # <title> and <pending>
            pending.parent.parent.remove(pending.parent) 
开发者ID:skarlekar,项目名称:faces,代码行数:10,代码来源:peps.py


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