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


Python nodes.list_item方法代码示例

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


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

示例1: process

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def process(self, doctree):
        for node in doctree.traverse(cfgconfig):
            config = node.config
            context = node.context
            options = self.domain.config_options[config]

            if self.builder.config.cfg_options_summary is None:
                new_content = []
            elif len(options) == 0:
                new_content = [nodes.Text("[No options defined for this config]")]
            elif self.builder.config.cfg_options_summary == "table":
                new_content = self.create_summary_table(config, context, options)
            elif self.builder.config.cfg_options_summary == "list":
                new_content = [self.create_option_reference(o, config, context) for o in options]
                if len(new_content) > 1:
                    listnode = nodes.bullet_list()
                    for entry in new_content:
                        listnode += nodes.list_item('', entry)
                    new_content = [listnode]
            else:
                raise ValueError("unknown value for config option `cfg_options_summary`.")
            node.replace_self(new_content) 
开发者ID:tenpy,项目名称:tenpy,代码行数:24,代码来源:sphinx_cfg_options.py

示例2: bullet

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def bullet(self, match, context, next_state):
        """Bullet list item."""
        bulletlist = nodes.bullet_list()
        (bulletlist.source,
         bulletlist.line) = self.state_machine.get_source_and_line()
        self.parent += bulletlist
        bulletlist['bullet'] = match.string[0]
        i, blank_finish = self.list_item(match.end())
        bulletlist += i
        offset = self.state_machine.line_offset + 1   # next line
        new_line_offset, blank_finish = self.nested_list_parse(
              self.state_machine.input_lines[offset:],
              input_offset=self.state_machine.abs_line_offset() + 1,
              node=bulletlist, initial_state='BulletList',
              blank_finish=blank_finish)
        self.goto_line(new_line_offset)
        if not blank_finish:
            self.parent += self.unindent_warning('Bullet list')
        return [], next_state, [] 
开发者ID:skarlekar,项目名称:faces,代码行数:21,代码来源:states.py

示例3: visit_paragraph

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def visit_paragraph(self, node):
        # insert blank line, unless
        # * the paragraph is first in a list item,
        # * follows a non-paragraph node in a compound,
        # * is in a table with auto-width columns
        index = node.parent.index(node)
        if (index == 0 and (isinstance(node.parent, nodes.list_item) or
                            isinstance(node.parent, nodes.description))):
            pass
        elif (index > 0 and isinstance(node.parent, nodes.compound) and
              not isinstance(node.parent[index - 1], nodes.paragraph) and
              not isinstance(node.parent[index - 1], nodes.compound)):
            pass
        elif self.active_table.colwidths_auto:
            if index == 1: # second paragraph
                self.warn('LaTeX merges paragraphs in tables '
                          'with auto-sized columns!', base_node=node)
            if index > 0:
                self.out.append('\n')
        else:
            self.out.append('\n')
        if node.get('ids'):
            self.out += self.ids_to_labels(node) + ['\n']
        if node['classes']:
            self.visit_inline(node) 
开发者ID:skarlekar,项目名称:faces,代码行数:27,代码来源:__init__.py

示例4: enumerator

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def enumerator(self, match, context, next_state):
        """Enumerated list item."""
        format, sequence, text, ordinal = self.parse_enumerator(
              match, self.parent['enumtype'])
        if ( format != self.format
             or (sequence != '#' and (sequence != self.parent['enumtype']
                                      or self.auto
                                      or ordinal != (self.lastordinal + 1)))
             or not self.is_enumerated_list_item(ordinal, sequence, format)):
            # different enumeration: new list
            self.invalid_input()
        if sequence == '#':
            self.auto = 1
        listitem, blank_finish = self.list_item(match.end())
        self.parent += listitem
        self.blank_finish = blank_finish
        self.lastordinal = ordinal
        return [], next_state, [] 
开发者ID:skarlekar,项目名称:faces,代码行数:20,代码来源:states.py

示例5: make_field

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def make_field(self, types, domain, items, env=None):
        fieldname = nodes.field_name('', self.label)
        listnode = self.list_type()
        for fieldarg, content in items:
            par = nodes.paragraph()
            par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
                                       addnodes.literal_strong, env=env))
            if content and content[0].astext():
                par += nodes.Text(' ')
                par += content
            listnode += nodes.list_item('', par)

            source = env.ref_context['conda:package']
            backrefs = env.domains['conda'].data['backrefs'].setdefault(fieldarg, set())
            backrefs.add((env.docname, source))

        fieldbody = nodes.field_body('', listnode)
        fieldbody.set_class('field-list-wrapped')
        return nodes.field('', fieldname, fieldbody) 
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:21,代码来源:sphinxext.py

示例6: resolve_required_by_xrefs

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def resolve_required_by_xrefs(app, env, node, contnode):
    """Now that all recipes and packages have been parsed, we are called here
    for each ``pending_xref`` node that sphinx has not been able to resolve.

    We handle specifically the ``requiredby`` reftype created by the
    `RequiredByField` fieldtype allowed in ``conda:package::``
    directives, where we replace the ``pending_ref`` node with a bullet
    list of reference nodes pointing to the package pages that
    "depended" on the package.
    """
    if node['reftype'] == 'requiredby' and node['refdomain'] == 'conda':
        target = node['reftarget']
        docname = node['refdoc']
        backrefs = env.domains['conda'].data['backrefs'].get(target, set())
        listnode = nodes.bullet_list()
        for back_docname, back_target in backrefs:
            par = nodes.paragraph()
            name_node = addnodes.literal_strong(back_target, back_target,
                                      classes=['xref', 'backref'])
            refnode = make_refnode(app.builder, docname,
                                   back_docname, back_target, name_node)
            refnode.set_class('conda-package')
            par += refnode
            listnode += nodes.list_item('', par)
        return listnode 
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:27,代码来源:sphinxext.py

示例7: visit_paragraph

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def visit_paragraph(self, node):
        # insert blank line, unless
        # * the paragraph is first in a list item or compound,
        # * follows a non-paragraph node in a compound,
        # * is in a table with auto-width columns
        index = node.parent.index(node)
        if index == 0 and isinstance(node.parent,
                (nodes.list_item, nodes.description, nodes.compound)):
            pass
        elif (index > 0 and isinstance(node.parent, nodes.compound) and
              not isinstance(node.parent[index - 1], nodes.paragraph) and
              not isinstance(node.parent[index - 1], nodes.compound)):
            pass
        elif self.active_table.colwidths_auto:
            if index == 1: # second paragraph
                self.warn('LaTeX merges paragraphs in tables '
                          'with auto-sized columns!', base_node=node)
            if index > 0:
                self.out.append('\n')
        else:
            self.out.append('\n')
        if node.get('ids'):
            self.out += self.ids_to_labels(node) + ['\n']
        if node['classes']:
            self.visit_inline(node) 
开发者ID:QData,项目名称:deepWordBug,代码行数:27,代码来源:__init__.py

示例8: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def run(self):
        idb = nodes.make_id("emva1288-" + self.options['section'])
        section = nodes.section(ids=[idb])
        section += nodes.rubric(text='Emva1288')
        lst = nodes.bullet_list()

        for k in self.option_spec.keys():
            if k not in self.options:
                continue

            item = nodes.list_item()
            item += nodes.strong(text=k + ':')
            item += nodes.inline(text=' ' + self.options[k])
            lst += item
        section += lst
        return [section] 
开发者ID:EMVA1288,项目名称:emva1288,代码行数:18,代码来源:sphinx_directives.py

示例9: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def run(self):
        # XXX: do this once only
        fd = pkg_resources.resource_stream ('crocoite', 'data/click.yaml')
        config = list (yaml.safe_load_all (fd))

        l = nodes.definition_list ()
        for site in config:
            urls = set ()
            v = nodes.definition ()
            vl = nodes.bullet_list ()
            v += vl
            for s in site['selector']:
                i = nodes.list_item ()
                i += nodes.paragraph (text=s['description'])
                vl += i
                urls.update (map (lambda x: URL(x).with_path ('/'), s.get ('urls', [])))

            item = nodes.definition_list_item ()
            term = ', '.join (map (lambda x: x.host, urls)) if urls else site['match']
            k = nodes.term (text=term)
            item += k

            item += v
            l += item
        return [l] 
开发者ID:PromyLOPh,项目名称:crocoite,代码行数:27,代码来源:clicklist.py

示例10: patched_make_field

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def patched_make_field(self, types, domain, items, **kw):
    # `kw` catches `env=None` needed for newer sphinx while maintaining
    #  backwards compatibility when passed along further down!

    # type: (List, unicode, Tuple) -> nodes.field
    def handle_item(fieldarg, content):
        par = nodes.paragraph()
        par += addnodes.literal_strong('', fieldarg)  # Patch: this line added
        # par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
        #                           addnodes.literal_strong))
        if fieldarg in types:
            par += nodes.Text(' (')
            # NOTE: using .pop() here to prevent a single type node to be
            # inserted twice into the doctree, which leads to
            # inconsistencies later when references are resolved
            fieldtype = types.pop(fieldarg)
            if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
                typename = u''.join(n.astext() for n in fieldtype)
                typename = typename.replace('int', 'python:int')
                typename = typename.replace('long', 'python:long')
                typename = typename.replace('float', 'python:float')
                typename = typename.replace('type', 'python:type')
                par.extend(self.make_xrefs(self.typerolename, domain, typename,
                                           addnodes.literal_emphasis, **kw))
            else:
                par += fieldtype
            par += nodes.Text(')')
        par += nodes.Text(' -- ')
        par += content
        return par

    fieldname = nodes.field_name('', self.label)
    if len(items) == 1 and self.can_collapse:
        fieldarg, content = items[0]
        bodynode = handle_item(fieldarg, content)
    else:
        bodynode = self.list_type()
        for fieldarg, content in items:
            bodynode += nodes.list_item('', handle_item(fieldarg, content))
    fieldbody = nodes.field_body('', bodynode)
    return nodes.field('', fieldname, fieldbody) 
开发者ID:pytorch,项目名称:audio,代码行数:43,代码来源:conf.py

示例11: citation_list

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def citation_list(self, citable):
        bullet_list = nodes.bullet_list()
        for citation in citable.citations:
            list_item = nodes.list_item()

            para = nodes.paragraph(text=f"{citation.author}, {citation.year}. ")
            para += nodes.reference(
                internal=False, refuri=citation.doi, text=citation.doi)
            list_item += para
            bullet_list += list_item
        return bullet_list 
开发者ID:popsim-consortium,项目名称:stdpopsim,代码行数:13,代码来源:speciescatalog.py

示例12: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def run(self):
        """Create a type list."""
        config = self.state.document.settings.env.config

        # Group processes by category
        processes = get_processes(
            config.autoprocess_process_dir, config.autoprocess_source_base_url
        )
        processes.sort(key=itemgetter("type"))
        processes_by_types = {
            k: list(g) for k, g in groupby(processes, itemgetter("type"))
        }

        listnode = nodes.bullet_list()

        for typ in sorted(processes_by_types.keys()):
            par = nodes.paragraph()
            par += nodes.literal(typ, typ)
            par += nodes.Text(" - ")

            processes = sorted(processes_by_types[typ], key=itemgetter("name"))
            last_process = processes[-1]
            for process in processes:
                node = nodes.reference("", process["name"], internal=True)
                node["refuri"] = (
                    config.autoprocess_definitions_uri + "#process-" + process["slug"]
                )
                node["reftitle"] = process["name"]
                par += node
                if process != last_process:
                    par += nodes.Text(", ")

            listnode += nodes.list_item("", par)

        return [listnode] 
开发者ID:genialis,项目名称:resolwe,代码行数:37,代码来源:autoprocess.py

示例13: build_contents

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import list_item [as 别名]
def build_contents(self, node, level=0):
        level += 1
        sections = [sect for sect in node if isinstance(sect, nodes.section)]
        entries = []
        autonum = 0
        depth = self.startnode.details.get('depth', sys.maxsize)
        for section in sections:
            title = section[0]
            auto = title.get('auto')    # May be set by SectNum.
            entrytext = self.copy_and_filter(title)
            reference = nodes.reference('', '', refid=section['ids'][0],
                                        *entrytext)
            ref_id = self.document.set_id(reference)
            entry = nodes.paragraph('', '', reference)
            item = nodes.list_item('', entry)
            if ( self.backlinks in ('entry', 'top')
                 and title.next_node(nodes.reference) is None):
                if self.backlinks == 'entry':
                    title['refid'] = ref_id
                elif self.backlinks == 'top':
                    title['refid'] = self.toc_id
            if level < depth:
                subsects = self.build_contents(section, level)
                item += subsects
            entries.append(item)
        if entries:
            contents = nodes.bullet_list('', *entries)
            if auto:
                contents['classes'].append('auto-toc')
            return contents
        else:
            return [] 
开发者ID:skarlekar,项目名称:faces,代码行数:34,代码来源:parts.py


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