Python docutils.nodes.list_item() Examples

The following are 30 code examples of docutils.nodes.list_item(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module docutils.nodes , or try the search function .
Example #1
Source File: __init__.py    From aws-extender with MIT License 6 votes vote down vote up
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) 
Example #2
Source File: states.py    From faces with GNU General Public License v2.0 6 votes vote down vote up
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, [] 
Example #3
Source File: states.py    From faces with GNU General Public License v2.0 6 votes vote down vote up
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, [] 
Example #4
Source File: __init__.py    From faces with GNU General Public License v2.0 6 votes vote down vote up
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) 
Example #5
Source File: sphinx_cfg_options.py    From tenpy with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #6
Source File: states.py    From faces with GNU General Public License v2.0 6 votes vote down vote up
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, [] 
Example #7
Source File: sphinxext.py    From bioconda-utils with MIT License 6 votes vote down vote up
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) 
Example #8
Source File: sphinxext.py    From bioconda-utils with MIT License 6 votes vote down vote up
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 
Example #9
Source File: states.py    From deepWordBug with Apache License 2.0 6 votes vote down vote up
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, [] 
Example #10
Source File: __init__.py    From deepWordBug with Apache License 2.0 6 votes vote down vote up
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) 
Example #11
Source File: sphinx_directives.py    From emva1288 with GNU General Public License v3.0 6 votes vote down vote up
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] 
Example #12
Source File: clicklist.py    From crocoite with MIT License 6 votes vote down vote up
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] 
Example #13
Source File: states.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 6 votes vote down vote up
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, [] 
Example #14
Source File: __init__.py    From bash-lambda-layer with MIT License 6 votes vote down vote up
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) 
Example #15
Source File: states.py    From aws-extender with MIT License 6 votes vote down vote up
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, [] 
Example #16
Source File: __init__.py    From blackmamba with MIT License 6 votes vote down vote up
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) 
Example #17
Source File: states.py    From blackmamba with MIT License 6 votes vote down vote up
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, [] 
Example #18
Source File: __init__.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 6 votes vote down vote up
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) 
Example #19
Source File: states.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 6 votes vote down vote up
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, [] 
Example #20
Source File: states.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 6 votes vote down vote up
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, [] 
Example #21
Source File: __init__.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 6 votes vote down vote up
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) 
Example #22
Source File: states.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 6 votes vote down vote up
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, [] 
Example #23
Source File: __init__.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 6 votes vote down vote up
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) 
Example #24
Source File: states.py    From bash-lambda-layer with MIT License 6 votes vote down vote up
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, [] 
Example #25
Source File: _html_base.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def depart_paragraph(self, node):
        self.body.append('</p>')
        if not (isinstance(node.parent, (nodes.list_item, nodes.entry)) and
                (len(node.parent) == 1)):
            self.body.append('\n') 
Example #26
Source File: states.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def list_item(self, indent):
        if self.state_machine.line[indent:]:
            indented, line_offset, blank_finish = (
                self.state_machine.get_known_indented(indent))
        else:
            indented, indent, line_offset, blank_finish = (
                self.state_machine.get_first_known_indented(indent))
        listitem = nodes.list_item('\n'.join(indented))
        if indented:
            self.nested_parse(indented, input_offset=line_offset,
                              node=listitem)
        return listitem, blank_finish 
Example #27
Source File: states.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def bullet(self, match, context, next_state):
        """Bullet list item."""
        if match.string[0] != self.parent['bullet']:
            # different bullet: new list
            self.invalid_input()
        listitem, blank_finish = self.list_item(match.end())
        self.parent += listitem
        self.blank_finish = blank_finish
        return [], next_state, [] 
Example #28
Source File: autoprocess.py    From resolwe with Apache License 2.0 5 votes vote down vote up
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] 
Example #29
Source File: conf.py    From Jacinle with MIT License 5 votes vote down vote up
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) 
Example #30
Source File: states.py    From blackmamba with MIT License 5 votes vote down vote up
def list_item(self, indent):
        if self.state_machine.line[indent:]:
            indented, line_offset, blank_finish = (
                self.state_machine.get_known_indented(indent))
        else:
            indented, indent, line_offset, blank_finish = (
                self.state_machine.get_first_known_indented(indent))
        listitem = nodes.list_item('\n'.join(indented))
        if indented:
            self.nested_parse(indented, input_offset=line_offset,
                              node=listitem)
        return listitem, blank_finish