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


Python nodes.title方法代碼示例

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


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

示例1: ensureUniqueIDs

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [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: new_subsection

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [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

示例3: line

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [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

示例4: visit_system_message

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def visit_system_message(self, node):
        self.requirements['color'] = PreambleCmds.color
        self.fallbacks['title'] = PreambleCmds.title
        node['classes'] = ['system-message']
        self.visit_admonition(node)
        self.out.append('\\DUtitle[system-message]{system-message}\n')
        self.append_hypertargets(node)
        try:
            line = ', line~%s' % node['line']
        except KeyError:
            line = ''
        self.out.append('\n\n{\color{red}%s/%s} in \\texttt{%s}%s\n' %
                         (node['type'], node['level'],
                          self.encode(node['source']), line))
        if len(node['backrefs']) == 1:
            self.out.append('\n\\hyperlink{%s}{' % node['backrefs'][0])
            self.context.append('}')
        else:
            backrefs = ['\\hyperlink{%s}{%d}' % (href, i+1)
                        for (i, href) in enumerate(node['backrefs'])]
            self.context.append('backrefs: ' + ' '.join(backrefs)) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:23,代碼來源:__init__.py

示例5: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def run(self):
        set_classes(self.options)
        self.assert_has_content()
        text = '\n'.join(self.content)
        admonition_node = self.node_class(text, **self.options)
        self.add_name(admonition_node)
        if self.node_class is nodes.admonition:
            title_text = self.arguments[0]
            textnodes, messages = self.state.inline_text(title_text,
                                                         self.lineno)
            title = nodes.title(title_text, '', *textnodes)
            title.source, title.line = (
                    self.state_machine.get_source_and_line(self.lineno))
            admonition_node += title
            admonition_node += messages
            if not 'classes' in self.options:
                admonition_node['classes'] += ['admonition-' +
                                               nodes.make_id(title_text)]
        self.state.nested_parse(self.content, self.content_offset,
                                admonition_node)
        return [admonition_node] 
開發者ID:skarlekar,項目名稱:faces,代碼行數:23,代碼來源:admonitions.py

示例6: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def run(self):
        if not self.content:
            error = self.state_machine.reporter.error(
                'The "%s" directive is empty; content required.' % self.name,
                nodes.literal_block(self.block_text, self.block_text),
                line=self.lineno)
            return [error]
        title, messages = self.make_title()
        node = nodes.Element()          # anonymous container for parsing
        self.state.nested_parse(self.content, self.content_offset, node)
        try:
            num_cols, widths, col_widths = self.check_list_content(node)
            table_data = [[item.children for item in row_list[0]]
                          for row_list in node[0]]
            header_rows = self.options.get('header-rows', 0)
            stub_columns = self.options.get('stub-columns', 0)
            self.check_table_dimensions(table_data, header_rows, stub_columns)
        except SystemMessagePropagation, detail:
            return [detail.args[0]] 
開發者ID:skarlekar,項目名稱:faces,代碼行數:21,代碼來源:tables.py

示例7: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def run(self):
        if not (self.state_machine.match_titles
                or isinstance(self.state_machine.node, nodes.sidebar)):
            raise self.error('The "%s" directive may not be used within '
                             'topics or body elements.' % self.name)
        self.assert_has_content()
        title_text = self.arguments[0]
        textnodes, messages = self.state.inline_text(title_text, self.lineno)
        titles = [nodes.title(title_text, '', *textnodes)]
        # Sidebar uses this code.
        if 'subtitle' in self.options:
            textnodes, more_messages = self.state.inline_text(
                self.options['subtitle'], self.lineno)
            titles.append(nodes.subtitle(self.options['subtitle'], '',
                                         *textnodes))
            messages.extend(more_messages)
        text = '\n'.join(self.content)
        node = self.node_class(text, *(titles + messages))
        node['classes'] += self.options.get('class', [])
        self.add_name(node)
        if text:
            self.state.nested_parse(self.content, self.content_offset, node)
        return [node] 
開發者ID:skarlekar,項目名稱:faces,代碼行數:25,代碼來源:body.py

示例8: make_xref

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def make_xref(self, rolename, domain, target,
                  innernode=d_nodes.emphasis, contnode=None, env=None):

        if not rolename:
            return contnode or innernode(target, target)

        title = target
        if domain == 'eql' and rolename == 'type':
            target = EQLTypeXRef.filter_target(target)
            if target in EQLTypedField.ignored_types:
                return d_nodes.Text(title)

        refnode = s_nodes.pending_xref('', refdomain=domain,
                                       refexplicit=title != target,
                                       reftype=rolename, reftarget=target)
        refnode += contnode or innernode(title, title)
        if env:
            env.domains[domain].process_field_xref(refnode)

        refnode['eql-auto-link'] = True
        return refnode 
開發者ID:edgedb,項目名稱:edgedb,代碼行數:23,代碼來源:eql.py

示例9: genetic_map_section

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [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 title [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 title [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: get_identifier

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def get_identifier(self):
        """Validate and returns disqus_identifier option value.

        :returns: disqus_identifier config value.
        :rtype: str
        """
        if 'disqus_identifier' in self.options:
            return self.options['disqus_identifier']

        title_nodes = self.state.document.traverse(nodes.title)
        if not title_nodes:
            raise DisqusError('No title nodes found in document, cannot derive disqus_identifier config value.')
        return title_nodes[0].astext() 
開發者ID:Robpol86,項目名稱:sphinxcontrib-disqus,代碼行數:15,代碼來源:disqus.py

示例13: apply

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def apply(self):
        language = languages.get_language(self.document.settings.language_code,
                                          self.document.reporter)
        name = language.labels['contents']
        title = nodes.title('', name)
        topic = nodes.topic('', title, classes=['contents'])
        name = nodes.fully_normalize_name(name)
        if not self.document.has_name(name):
            topic['names'].append(name)
        self.document.note_implicit_target(topic)
        pending = nodes.pending(parts.Contents)
        topic += pending
        self.document.insert(1, topic)
        self.document.note_pending(pending) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:16,代碼來源:peps.py

示例14: cleanup_callback

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [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

示例15: set_metadata

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import title [as 別名]
def set_metadata(self):
        """
        Set document['title'] metadata title from the following
        sources, listed in order of priority:

        * Existing document['title'] attribute.
        * "title" setting.
        * Document title node (as promoted by promote_title).
        """
        if not self.document.hasattr('title'):
            if self.document.settings.title is not None:
                self.document['title'] = self.document.settings.title
            elif len(self.document) and isinstance(self.document[0], nodes.title):
                self.document['title'] = self.document[0].astext() 
開發者ID:skarlekar,項目名稱:faces,代碼行數:16,代碼來源:frontmatter.py


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