Exemplo n.º 1
0
    def contribute_properties(self, parent):
        if not self.props_schemata:
            return

        props = dict((k, v) for k, v in self.props_schemata.items()
                     if v.support_status.status != support.HIDDEN)

        required_props = dict((k, v) for k, v in props.items()
                              if v.required)
        if required_props:
            section = self._section(
                parent, _('Required Properties'), '%s-props-req')
            definition_list = nodes.definition_list()
            section.append(definition_list)

            for prop_key, prop in sorted(required_props.items(),
                                         key=cmp_to_key(self.cmp_prop)):
                self.contribute_property(definition_list, prop_key, prop)

        optional_props = dict((k, v) for k, v in props.items()
                              if not v.required)
        if optional_props:
            section = self._section(
                parent, _('Optional Properties'), '%s-props-opt')
            definition_list = nodes.definition_list()
            section.append(definition_list)

            for prop_key, prop in sorted(optional_props.items(),
                                         key=cmp_to_key(self.cmp_prop)):
                self.contribute_property(definition_list, prop_key, prop)
Exemplo n.º 2
0
 def _generate_documentation(self, tree):
     unvisited = [tree]
     while len(unvisited) > 0:
         node = unvisited[-1]
         if len(node.children) > 0:
             unvisited.append(node.remove_child())
             continue
         if node.parent is None or node.comment is None:
             unvisited.pop()
             continue
         with switch_source_input(self.state, node.comment):
             definition = nodes.definition()
             if isinstance(node.comment, ViewList):
                 self.state.nested_parse(node.comment, 0, definition)
             else:
                 definition += node.comment
             node.comment = nodes.definition_list_item(
                 "",
                 nodes.term("", node.value.value),
                 definition,
             )
             if node.parent.comment is None:
                 node.parent.comment = nodes.definition_list()
             elif not isinstance(node.parent.comment,
                                 nodes.definition_list):
                 with switch_source_input(self.state, node.parent.comment):
                     dlist = nodes.definition_list()
                     self.state.nested_parse(node.parent.comment, 0, dlist)
                     node.parent.comment = dlist
             node.parent.comment += node.comment
         unvisited.pop()
     return tree.comment
Exemplo n.º 3
0
    def contribute_properties(self, parent):
        if not self.props_schemata:
            return

        props = dict((k, v) for k, v in self.props_schemata.items()
                     if v.support_status.status != support.HIDDEN)

        required_props = dict((k, v) for k, v in props.items()
                              if v.required)
        if required_props:
            section = self._section(
                parent, _('Required Properties'), '%s-props-req')
            definition_list = nodes.definition_list()
            section.append(definition_list)

            for prop_key, prop in sorted(required_props.items(),
                                         key=cmp_to_key(self.cmp_prop)):
                self.contribute_property(definition_list, prop_key, prop)

        optional_props = dict((k, v) for k, v in props.items()
                              if not v.required)
        if optional_props:
            section = self._section(
                parent, _('Optional Properties'), '%s-props-opt')
            definition_list = nodes.definition_list()
            section.append(definition_list)

            for prop_key, prop in sorted(optional_props.items(),
                                         key=cmp_to_key(self.cmp_prop)):
                self.contribute_property(definition_list, prop_key, prop)
Exemplo n.º 4
0
    def contribute_attributes(self, parent):
        if not self.attrs_schemata:
            return
        section = self._section(parent, _('Attributes'), '%s-attrs')
        prop_list = nodes.definition_list()
        section.append(prop_list)
        for prop_key, prop in sorted(self.attrs_schemata.items()):
            description = prop.description
            prop_item = nodes.definition_list_item(
                '', nodes.term('', prop_key))
            prop_list.append(prop_item)

            definition = nodes.definition()
            prop_item.append(definition)

            if prop.support_status.status != support.SUPPORTED:
                sstatus = prop.support_status.to_dict()
                msg = _('%(status)s')
                if sstatus['message'] is not None:
                    msg = _('%(status)s - %(message)s')
                para = nodes.inline('', msg % sstatus)
                warning = nodes.note('', para)
                definition.append(warning)

            if description:
                def_para = nodes.paragraph('', description)
                definition.append(def_para)
Exemplo n.º 5
0
def print_subcommand_list(data, nested_content):

    definitions = map_nested_definitions(nested_content)

    items = []

    if 'children' in data:
        for child in data['children']:

            my_def = [nodes.paragraph(
                text=child['help'])] if child['help'] else []
            name = child['name']
            nested_def = definitions[name] if name in definitions else []

            my_def = apply_definition(definitions, my_def, name)

            if len(my_def) == 0:
                my_def.append(nodes.paragraph(text='Undocumented'))

            my_def.append(nodes.literal_block(text=child['usage']))

            my_def.append(
                print_command_args_and_opts(
                    print_arg_list(child, nested_content),
                    print_opt_list(child, nested_content)))

            items.append(
                nodes.definition_list_item(
                    '', nodes.term('', '', nodes.strong(text=name)),
                    nodes.definition('', *my_def)))

    return nodes.definition_list('', *items)
Exemplo n.º 6
0
 def run(self):
     result = nodes.definition_list()
     for option in sorted(self.options.keys()):
         if option == 'added':
             continue
         term = option.capitalize()
         result += nodes.term(text=term)
         definition = nodes.definition()
         if option in ['kerk', 'predikant', 'tags']:
             taglink = {'kerk': SERMONCHURHLINK,
                        'predikant': SERMONREFERENTLINK,
                        'tags': SERMONTAGLINK}[option]
             value = self.options[option]
             values = [value.strip() for value in value.split(',')]
             paragraph = nodes.paragraph()
             for i, value in enumerate(values):
                 link = taglink % value
                 paragraph += nodes.reference(refuri=link, text=value)
                 if not i == len(values) - 1:
                     paragraph += nodes.inline(text=', ')
             definition += paragraph
         else:
             paragraph = nodes.paragraph()
             paragraph += nodes.inline(text=self.options[option])
             definition += paragraph
         result += definition
     return [result]
    def _build_definition_list(self, defaults):
        from oauth2_provider import settings

        items = []
        for setting, default_value in defaults:
            text_nodes, messages = self.state.inline_text(
                DESCRIPTIONS.get(setting, "TODO").strip(), self.lineno)
            node_name = nodes.literal(text=setting)
            node_default = nodes.paragraph(text="Default value: ")
            node_default += nodes.literal(text=repr(default_value))
            node_description = nodes.paragraph()
            node_description.extend(text_nodes)
            subitems = [node_default, node_description]

            if setting in settings.MANDATORY:
                notice = nodes.paragraph()
                notice += nodes.strong(text="The value cannot be empty.")
                subitems.append(notice)

            term = nodes.term()
            term += node_name
            items.append(
                nodes.definition_list_item('', term,
                                           nodes.definition('', *subitems)))

        deflist = nodes.definition_list('', *items)
        return [deflist]
Exemplo n.º 8
0
    def _build_markup(self, commits):
        list_node = nodes.definition_list()
        for commit in commits:
            date_str = datetime.fromtimestamp(commit.authored_date)
            if '\n' in commit.message:
                message, detailed_message = commit.message.split('\n', 1)
            else:
                message = commit.message
                detailed_message = None

            item = nodes.list_item()
            item += [
                nodes.emphasis(text="Last Updated by "),
                nodes.strong(text=str(commit.author)),
                nodes.inline(text=" at "),
                nodes.emphasis(text=str(date_str)),
                nodes.inline(text=" with message "),
                nodes.strong(text=message),
            ]
            if detailed_message:
                detailed_message = detailed_message.strip()
                if self.options.get('detailed-message-pre', False):
                    item.append(
                        nodes.literal_block(text=detailed_message))
                else:
                    item.append(nodes.paragraph(text=detailed_message))
            list_node.append(item)
        return [list_node]
Exemplo n.º 9
0
    def run(self):

        # import the modules, which will populate the SERVICES variable.

        module = self._get_module(self.options.get('module'))
        klass = getattr(module, self.options.get('document'))

        result = []

        # section_id = self.options.get('id', klass_name)

        result.append(rst2node("**{} " "JSON object**".format(klass.__name__)))

        klass_doc = klass.__doc__
        if klass_doc and len(klass_doc):
            result.append(rst2node(klass_doc))

        if len(klass.__dict__):
            result.append(rst2node("*Members documentation:*"))
            members_list = nodes.definition_list()
            for name, member in klass.__dict__.items():
                if isinstance(member, BaseField):
                    members_list += self._document_member(name, member)
            result.append(members_list)

        return result
Exemplo n.º 10
0
    def add_coqtop_output(self):
        """Add coqtop's responses to a Sphinx AST

        Finds nodes to process using is_coqtop_block."""
        with CoqTop(color=True) as repl:
            for node in self.document.traverse(CoqtopBlocksTransform.is_coqtop_block):
                options = node['coqtop_options']
                opt_undo, opt_reset, opt_input, opt_output = self.parse_options(options)

                if opt_reset:
                    repl.sendone("Reset Initial.")
                pairs = []
                for sentence in self.split_sentences(node.rawsource):
                    pairs.append((sentence, repl.sendone(sentence)))
                if opt_undo:
                    repl.sendone("Undo {}.".format(len(pairs)))

                dli = nodes.definition_list_item()
                for sentence, output in pairs:
                    # Use Coqdoq to highlight input
                    in_chunks = highlight_using_coqdoc(sentence)
                    dli += nodes.term(sentence, '', *in_chunks, classes=self.block_classes(opt_input))
                    # Parse ANSI sequences to highlight output
                    out_chunks = AnsiColorsParser().colorize_str(output)
                    dli += nodes.definition(output, *out_chunks, classes=self.block_classes(opt_output, output))
                node.clear()
                node.rawsource = self.make_rawsource(pairs, opt_input, opt_output)
                node['classes'].extend(self.block_classes(opt_input or opt_output))
                node += nodes.inline('', '', classes=['coqtop-reset'] * opt_reset)
                node += nodes.definition_list(node.rawsource, dli)
Exemplo n.º 11
0
    def extract_non_paragraph_node(self, deflist):
        """Extract non paragraph node (ex. literal_block) to after the list."""
        ALLOWED_NODES = (nodes.paragraph, nodes.image)

        for i, item in reversed(list(enumerate(deflist))):
            found = []
            for node in reversed(item[1]):
                if not isinstance(node, ALLOWED_NODES):
                    logger.warning('In Re:VIEW, definition list can\'t contain %s. '
                                   'Moved it after the list.',
                                   node.tagname, location=node)
                    found.append(node)

            if found:
                pos = deflist.parent.index(deflist)

                # separate definition list if non paragraph nodes found
                if deflist[i + 1:]:
                    new_deflist = nodes.definition_list()
                    for item in deflist[i + 1:]:
                        deflist.remove(item)
                        new_deflist += item
                    deflist.parent.insert(pos + 1, new_deflist)

                # move non paragraph nodes after the definition list
                for node in found:
                    node.parent.remove(node)
                    deflist.parent.insert(pos + 1, node)
Exemplo n.º 12
0
    def document_transitions(self) -> docutils.nodes.section:
        """Document workflow transitions.

        :returns: A section node containing the doctree for transitions description.
        """
        transitions = self.wf_elements.get('transitions')
        wf_name = self.wf_name
        node = nodes.section(
            ids=['workflows-{wf_name}-transitions'.format(wf_name=wf_name)])
        node += nodes.title(text='Transitions')
        dl = nodes.definition_list()
        for transition in transitions:
            transition_id = 'workflows-{wf_name}-transitions-{transition}'.format(
                wf_name=wf_name, transition=transition.name)
            t_node = nodes.definition_list_item()
            title = '{title} ({from_} → {to_})'.format(
                title=transition.title,
                from_=transition.state_from().name,
                to_=transition.state_to().name,
            )
            t_node += nodes.term(text=title, ids=[transition_id])
            dd = nodes.definition()
            dd += self._rst2node(transition.__doc__)
            dd += nodes.paragraph(text='Permission: {permission}'.format(
                permission=transition.permission))
            t_node += dd
            dl += t_node
        node += dl
        return node
Exemplo n.º 13
0
    def document_permissions(self) -> docutils.nodes.section:
        """Document workflow permissions.

        :returns: A section node containing the doctree for permissions description.
        """
        permissions = self.wf_elements.get('permissions')
        wf_name = self.wf_name
        node = nodes.section(
            ids=['workflows-{wf_name}-permissions'.format(wf_name=wf_name)])
        node += nodes.title(text='Permissions')
        dl = nodes.definition_list()
        for permission in permissions:
            permission_id = 'workflows-{wf_name}-permissions-{permission}'.format(
                wf_name=wf_name, permission=permission.name)
            t_node = nodes.definition_list_item()
            t_node += nodes.term(text=permission.name, ids=[permission_id])
            dd = nodes.definition()
            dd += self._rst2node(permission.__doc__)
            if hasattr(permission, 'groups'):
                dd += nodes.paragraph(text='Groups: {groups}'.format(
                    groups=', '.join(permission.groups)))
            t_node += dd
            dl += t_node
        node += dl
        return node
Exemplo n.º 14
0
    def document_states(self) -> docutils.nodes.section:
        """Document workflow states.

        :returns: A section node containing the doctree for states description.
        """
        states = self.wf_elements.get('states')
        wf_name = self.wf_name
        node = nodes.section(
            ids=['workflows-{wf_name}-states'.format(wf_name=wf_name)])
        node += nodes.title(text='States')
        dl = nodes.definition_list()
        for state in states:
            state_id = 'workflows-{wf_name}-states-{state}'.format(
                wf_name=wf_name, state=state.name)
            state_node = nodes.definition_list_item()
            state_node += nodes.term(text=state.title, ids=[state_id])
            dd = nodes.definition()
            dd += self._rst2node(state.description)
            transitions = nodes.bullet_list()
            for t_name in state._transitions:
                t = state._transitions[t_name]
                temp = nodes.list_item()
                temp += nodes.inline(text=t.name)
                temp += nodes.inline(text=' ({state_to})'.format(
                    state_to=t.state_to().name))
                transitions += temp
            dd += transitions
            state_node += dd
            dl += state_node
        node += dl
        return node
Exemplo n.º 15
0
    def contribute_property(self, prop_list, prop_key, prop):
        prop_item = nodes.definition_list_item(
            '', nodes.term('', prop_key))
        prop_list.append(prop_item)

        prop_item.append(nodes.classifier('', prop.type))

        definition = nodes.definition()
        prop_item.append(definition)

        if not prop.implemented:
            para = nodes.inline('', _('Not implemented.'))
            warning = nodes.note('', para)
            definition.append(warning)
            return

        if prop.description:
            para = nodes.paragraph('', prop.description)
            definition.append(para)

        if prop.update_allowed:
            para = nodes.paragraph('',
                                   _('Can be updated without replacement.'))
            definition.append(para)
        else:
            para = nodes.paragraph('', _('Updates cause replacement.'))
            definition.append(para)

        if prop.required:
            para = nodes.paragraph('', _('Required property.'))
        elif prop.default is not None:
            para = nodes.paragraph(
                '',
                _('Optional property, defaults to "%s".') % prop.default)
        else:
            para = nodes.paragraph('', _('Optional property.'))
        definition.append(para)

        for constraint in prop.constraints:
            para = nodes.paragraph('', str(constraint))
            definition.append(para)

        sub_schema = None
        if prop.schema and prop.type == properties.MAP:
            para = nodes.emphasis('', _('Map properties:'))
            definition.append(para)
            sub_schema = prop.schema

        elif prop.schema and prop.type == properties.LIST:
            para = nodes.emphasis(
                '', _('List contents:'))
            definition.append(para)
            sub_schema = prop.schema

        if sub_schema:
            sub_prop_list = nodes.definition_list()
            definition.append(sub_prop_list)
            for sub_prop_key in sorted(sub_schema.keys()):
                sub_prop = sub_schema[sub_prop_key]
                self.contribute_property(sub_prop_list, sub_prop_key, sub_prop)
Exemplo n.º 16
0
    def run(self):

        # import the modules, which will populate the SERVICES variable.

        module = self._get_module(self.options.get('module'))
        klass = getattr(module, self.options.get('document'))

        result = []

        # section_id = self.options.get('id', klass_name)

        result.append(rst2node("**{} "
                               "JSON object**".format(klass.__name__)))

        klass_doc = klass.__doc__
        if klass_doc and len(klass_doc):
            result.append(rst2node(klass_doc))

        if len(klass.__dict__):
            result.append(rst2node("*Members documentation:*"))
            members_list = nodes.definition_list()
            for name, member in klass.__dict__.items():
                if isinstance(member, BaseField):
                    members_list += self._document_member(name, member)
            result.append(members_list)

        return result
Exemplo n.º 17
0
    def render(self, app, doctree):
        rootnode = nodes.bullet_list()
        rootnode = nodes.paragraph()
        rootnode = nodes.definition_list()
        prepend = ""
        append = ""
        if self.scope == "global":
            prepend = "Global "
        if self.scope == "class":
            append = " (class %s)" % self.refname
        elif self.scope == "namespace":
            append = " (namespace %s)" % self.refname

        n = self.render_sub(app, doctree, self.namespaces,
                            prepend + "Namespaces" + append,
                            "namespace ")
        if n : rootnode.append(n)
        n = self.render_sub(app, doctree, self.classes,
                            prepend + "Classes" + append,
                            "class ")
        if n : rootnode.append(n)
        n = self.render_simple(app, doctree, self.functions,
                               prepend + "Functions"  + append,
                               "functions")
        if n : rootnode.append(n)
        n = self.render_simple(app, doctree, self.members,
                               prepend + "Members"  + append,
                               "members")
        if n : rootnode.append(n)
        n = self.render_simple(app, doctree, self.types,
                               prepend + "Types"  + append,
                               "types")
        if n : rootnode.append(n)
        return rootnode
Exemplo n.º 18
0
    def add_coq_output_1(self, repl, node):
        options = self.parse_options(node)

        pairs = []

        if options['restart']:
            repl.sendone("Restart.")
        if options['reset']:
            repl.sendone("Reset Initial.")
            repl.sendone("Set Coqtop Exit On Error.")
        if options['fail']:
            repl.sendone("Unset Coqtop Exit On Error.")
        for sentence in self.split_sentences(node.rawsource):
            pairs.append((sentence, repl.sendone(sentence)))
        if options['abort']:
            repl.sendone("Abort All.")
        if options['fail']:
            repl.sendone("Set Coqtop Exit On Error.")

        dli = nodes.definition_list_item()
        for sentence, output in pairs:
            # Use Coqdoc to highlight input
            in_chunks = highlight_using_coqdoc(sentence)
            dli += nodes.term(sentence, '', *in_chunks, classes=self.block_classes(options['input']))
            # Parse ANSI sequences to highlight output
            out_chunks = AnsiColorsParser().colorize_str(output)
            dli += nodes.definition(output, *out_chunks, classes=self.block_classes(options['output'], output))
        node.clear()
        node.rawsource = self.make_rawsource(pairs, options['input'], options['output'])
        node['classes'].extend(self.block_classes(options['input'] or options['output']))
        node += nodes.inline('', '', classes=['coqtop-reset'] * options['reset'])
        node += nodes.definition_list(node.rawsource, dli)
Exemplo n.º 19
0
    def run(self):
        env = self.state.document.settings.env
        node = addnodes.glossary()
        node.document = self.state.document
        self.state.nested_parse(self.content, self.content_offset, node)

        # the content should be definition lists
        dls = [child for child in node
               if isinstance(child, nodes.definition_list)]
        # now, extract definition terms to enable cross-reference creation
        new_dl = nodes.definition_list()
        new_dl['classes'].append('glossary')
        items = []
        for dl in dls:
            for li in dl.children:
                if not li.children or not isinstance(li[0], nodes.term):
                    continue
                termtext = li.children[0].astext()
                new_id = 'term-' + nodes.make_id(termtext)
                if new_id in env.gloss_entries:
                    new_id = 'term-' + str(len(env.gloss_entries))
                env.gloss_entries.add(new_id)
                li[0]['names'].append(new_id)
                li[0]['ids'].append(new_id)
                env.note_reftarget('term', termtext.lower(), new_id)
                # add an index entry too
                indexnode = addnodes.index()
                indexnode['entries'] = [('single', termtext, new_id, termtext)]
                li.insert(0, indexnode)
                items.append((termtext, li))
        if 'sorted' in self.options:
            items.sort(key=lambda x: x[0].lower())
        new_dl.extend(item[1] for item in items)
        node.children = [new_dl]
        return [node]
Exemplo n.º 20
0
    def run(self):
        # Raise an error if the directive does not have contents.
        self.assert_has_content()
        self.document = self.state_machine.document

        text = '\n'.join(self.content)
        # Create the admonition node, to be populated by `nested_parse`.

        self.name=self.arguments[0].strip()

        term = nodes.term()
        term += nodes.strong(text=self.arguments[0]) 

        targetnode = self.make_targetnode()

        deflist = nodes.definition_list()
        configuration_def = nodes.definition_list_item()
        configuration_def += term
        defn = nodes.definition()
        configuration_def += defn
        deflist += configuration_def

        # Parse the directive contents.
        self.state.nested_parse(self.content, self.content_offset,
                                defn)
        
        option_map = {}
        option_map['features'] = 'Required for features'
        field_list = self.options_to_field_list(option_map)

        if (field_list != None):
            defn += field_list

        self.parsed('configuration').append(self)
        return [targetnode, deflist]
Exemplo n.º 21
0
 def make_binary_properties(self, data):
     x = nodes.definition_list()
     for key, value in data.items():
         if value == 'undefined':
             continue
         add_df_item(x, key.title(), nodes.paragraph(text=yes_no(value)))
     return x
Exemplo n.º 22
0
def print_subcommand_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    items = []
    if 'children' in data:
        for child in data['children']:
            my_def = [nodes.paragraph(
                text=child['help'])] if child['help'] else []
            name = child['name']
            my_def = apply_definition(definitions, my_def, name)
            if len(my_def) == 0:
                my_def.append(nodes.paragraph(text='Undocumented'))
            my_def.append(nodes.literal_block(text=child['usage']))
            my_def.append(print_command_args_and_opts(
                print_arg_list(child, nested_content),
                print_opt_list(child, nested_content),
                text_from_rst(child.get('description', ""), is_rst=True),
                print_subcommand_list(child, nested_content),

            ))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(text=name)),
                    nodes.definition('', *my_def)
                )
            )
    return nodes.definition_list('', *items)
Exemplo n.º 23
0
    def add_coqtop_output(self):
        """Add coqtop's responses to a Sphinx AST

        Finds nodes to process using is_coqtop_block."""
        with CoqTop(color=True) as repl:
            for node in self.document.traverse(CoqtopBlocksTransform.is_coqtop_block):
                options = node['coqtop_options']
                opt_undo, opt_reset, opt_input, opt_output = self.parse_options(options)

                if opt_reset:
                    repl.sendone("Reset Initial.")
                pairs = []
                for sentence in self.split_sentences(node.rawsource):
                    pairs.append((sentence, repl.sendone(sentence)))
                if opt_undo:
                    repl.sendone("Undo {}.".format(len(pairs)))

                dli = nodes.definition_list_item()
                for sentence, output in pairs:
                    # Use Coqdoq to highlight input
                    in_chunks = highlight_using_coqdoc(sentence)
                    dli += nodes.term(sentence, '', *in_chunks, classes=self.block_classes(opt_input))
                    # Parse ANSI sequences to highlight output
                    out_chunks = AnsiColorsParser().colorize_str(output)
                    dli += nodes.definition(output, *out_chunks, classes=self.block_classes(opt_output, output))
                node.clear()
                node.rawsource = self.make_rawsource(pairs, opt_input, opt_output)
                node['classes'].extend(self.block_classes(opt_input or opt_output))
                node += nodes.inline('', '', classes=['coqtop-reset'] * opt_reset)
                node += nodes.definition_list(node.rawsource, dli)
Exemplo n.º 24
0
    def get_table(self, items):
        """Return a definition list rather than a table."""
        # See original implementation:
        # https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autosummary/__init__.py
        source, line = self.state_machine.get_source_and_line()
        src = f"{source}:{line}:<dlistsummary>"

        # We're going to build out a StringList by formatting a definition list and then
        # parsing it at the end.  Definition list syntax:
        #
        # **First Item**
        #     First item description, indented by four spaces.
        # **Second Item**
        #     Second item description, indented by four spaces.
        s_list = StringList()
        for name, signature, summary_string, real_name in items:
            # Add the definition item.
            s_list.append(f"**{name}**\n", src)

            # Add the autosummary description for this demo, including a link to the
            # full demonstration.  This is the definition of the item.
            summary_string += f"  :any:`Go to demo ↱ <{real_name}>`\n"
            s_list.append("    " + summary_string, src)

        # Now that we have a fully populated StringList, let Sphinx handle the dirty
        # work of evaluating the rst as actual nodes.
        node = definition_list("")
        self.state.nested_parse(s_list, 0, node)
        try:
            if isinstance(node[0], definition_list):
                node = node[0]
        except IndexError:
            pass

        return [node]
Exemplo n.º 25
0
    def run(self):
        # Raise an error if the directive does not have contents.
        self.assert_has_content()
        self.document = self.state_machine.document

        text = '\n'.join(self.content)
        # Create the admonition node, to be populated by `nested_parse`.

        self.name = self.arguments[0].strip()

        term = nodes.term()
        term += nodes.strong(text=self.arguments[0])

        targetnode = self.make_targetnode()

        deflist = nodes.definition_list()
        configuration_def = nodes.definition_list_item()
        configuration_def += term
        defn = nodes.definition()
        configuration_def += defn
        deflist += configuration_def

        # Parse the directive contents.
        self.state.nested_parse(self.content, self.content_offset, defn)

        option_map = {}
        option_map['features'] = 'Required for features'
        field_list = self.options_to_field_list(option_map)

        if (field_list != None):
            defn += field_list

        self.parsed('configuration').append(self)
        return [targetnode, deflist]
Exemplo n.º 26
0
    def _build_markup(self, commits):
        list_node = nodes.definition_list()
        for commit in commits:
            date_str = datetime.fromtimestamp(commit.authored_date)
            if '\n' in commit.message:
                message, detailed_message = commit.message.split('\n', 1)
            else:
                message = commit.message
                detailed_message = None

            item = nodes.list_item()
            item += [
                nodes.emphasis(text="Last Updated by "),
                nodes.strong(text=str(commit.author)),
                nodes.inline(text=" at "),
                nodes.emphasis(text=str(date_str)),
                nodes.inline(text=" with message "),
                nodes.strong(text=message),
            ]
            if detailed_message:
                detailed_message = detailed_message.strip()
                if self.options.get('detailed-message-pre', False):
                    item.append(nodes.literal_block(text=detailed_message))
                else:
                    item.append(nodes.paragraph(text=detailed_message))
            list_node.append(item)
        return [list_node]
Exemplo n.º 27
0
    def contribute_attributes(self, parent):
        if not self.attrs_schemata:
            return
        section = self._section(parent, _('Attributes'), '%s-attrs')
        prop_list = nodes.definition_list()
        section.append(prop_list)
        for prop_key, prop in sorted(self.attrs_schemata.items()):
            description = prop.description
            prop_item = nodes.definition_list_item(
                '', nodes.term('', prop_key))
            prop_list.append(prop_item)

            definition = nodes.definition()
            prop_item.append(definition)

            if prop.support_status.status != support.SUPPORTED:
                sstatus = prop.support_status.to_dict()
                msg = _('%(status)s')
                if sstatus['message'] is not None:
                    msg = _('%(status)s - %(message)s')
                para = nodes.inline('', msg % sstatus)
                warning = nodes.note('', para)
                definition.append(warning)

            if description:
                def_para = nodes.paragraph('', description)
                definition.append(def_para)
Exemplo n.º 28
0
    def after_contentnode(self, node):
        # derived_from:
        if (
                self.ent_name not in ROOT_TYPES and
                self.section != 'data_types'
                ):
            deriv = self.data['derived_from']
            xref_node = addnodes.pending_xref(
                    '', refdomain='cfy', reftype=self.kind,
                    reftarget=deriv,
                    modname=None, classname=None,
                    )
            xref_node += nodes.Text(deriv, deriv)
            node.append(nodes.paragraph(
                'Derived from: ', 'Derived from: ',
                xref_node,
                ))

        if 'properties' in self.data:
            node.append(nodes.rubric('', 'Properties:'))

            props = nodes.definition_list()
            node.append(props)

            self.generate_properties(props, self.data['properties'])
Exemplo n.º 29
0
    def run(self):
        # Do not put this at the top-level to avoid nasty circular dependency
        # issues.
        #
        # TODO: this is just a workaround. We should remove this circular
        # dependency instead, but this deserves its own refactoring:
        # compiled_types imports langkit.expressions at import time and
        # conversely. This works only when loading compiled_types first
        # "thanks" to the way the dependencies are used.
        from langkit.expressions import AbstractExpression

        document = self.state.document
        def_list = nodes.definition_list()
        result = [def_list]

        what_str, = self.arguments
        what_list = {
            'attr': AbstractExpression.attrs_dict.values(),
            'cls': AbstractExpression.constructors,
        }
        what = what_list[what_str]

        for doc_expr in sorted(what, key=lambda doc_expr: doc_expr.name):
            def_list.append(self._process_one(doc_expr, document))

        return result
Exemplo n.º 30
0
    def process_form(self, formclass, parent):
        assert issubclass(formclass, Form)
        fields = nodes.definition_list()
        parent.append(nodes.definition('', fields))
        forminstance = formclass()

        for field in forminstance:
            self.process_field_delegate(field, fields)
Exemplo n.º 31
0
    def process_form(self, formclass, parent):
        assert issubclass(formclass, Form)
        fields = nodes.definition_list()
        parent.append(nodes.definition('', fields))
        forminstance = formclass()

        for field in forminstance:
            self.process_field_delegate(field, fields)
Exemplo n.º 32
0
    def contribute_property(self, prop_list, prop_key, prop):
        prop_item = nodes.definition_list_item('', nodes.term('', prop_key))
        prop_list.append(prop_item)

        prop_item.append(nodes.classifier('', prop.type))

        definition = nodes.definition()
        prop_item.append(definition)

        if not prop.implemented:
            para = nodes.inline('', _('Not implemented.'))
            warning = nodes.note('', para)
            definition.append(warning)
            return

        if prop.description:
            para = nodes.paragraph('', prop.description)
            definition.append(para)

        if prop.update_allowed:
            para = nodes.paragraph('',
                                   _('Can be updated without replacement.'))
            definition.append(para)
        else:
            para = nodes.paragraph('', _('Updates cause replacement.'))
            definition.append(para)

        if prop.required:
            para = nodes.paragraph('', _('Required property.'))
        elif prop.default is not None:
            para = nodes.paragraph(
                '',
                _('Optional property, defaults to "%s".') % prop.default)
        else:
            para = nodes.paragraph('', _('Optional property.'))
        definition.append(para)

        for constraint in prop.constraints:
            para = nodes.paragraph('', str(constraint))
            definition.append(para)

        sub_schema = None
        if prop.schema and prop.type == properties.MAP:
            para = nodes.emphasis('', _('Map properties:'))
            definition.append(para)
            sub_schema = prop.schema

        elif prop.schema and prop.type == properties.LIST:
            para = nodes.emphasis('', _('List contents:'))
            definition.append(para)
            sub_schema = prop.schema

        if sub_schema:
            sub_prop_list = nodes.definition_list()
            definition.append(sub_prop_list)
            for sub_prop_key in sorted(sub_schema.keys()):
                sub_prop = sub_schema[sub_prop_key]
                self.contribute_property(sub_prop_list, sub_prop_key, sub_prop)
Exemplo n.º 33
0
 def run(self):
     options = io.get_options_for_format(self.arguments[0])
     field_list_node = nodes.definition_list()
     for name, description, value in options:
         item = nodes.definition_list_item()
         item.append(nodes.term(name + ' ', name + ' '))
         item.append(nodes.definition('', nodes.paragraph('', description)))
         field_list_node.append(item)
     return [field_list_node]
Exemplo n.º 34
0
 def run(self):
     options = io.get_options_for_format(self.arguments[0])
     field_list_node = nodes.definition_list()
     for name, description, value in options:
         item = nodes.definition_list_item()
         item.append(nodes.term(name + ' ',name+ ' '))
         item.append(nodes.definition('', nodes.paragraph('', description)))
         field_list_node.append(item)
     return [field_list_node]
Exemplo n.º 35
0
    def rst_nodes(self):

        nodelist = []
        for entry in self.parameteritem:
            nodelist.extend(entry.rst_nodes())

        def_list = nodes.definition_list("", *nodelist)

        return [def_list]
Exemplo n.º 36
0
 def contribute_properties(self, parent):
     if not self.props_schemata:
         return
     section = self._section(parent, _('Properties'), '%s-props')
     prop_list = nodes.definition_list()
     section.append(prop_list)
     for prop_key in sorted(self.props_schemata.keys()):
         prop = self.props_schemata[prop_key]
         self.contribute_property(prop_list, prop_key, prop)
Exemplo n.º 37
0
 def contribute_properties(self, parent):
     if not self.props_schemata:
         return
     section = self._section(parent, _('Properties'), '%s-props')
     prop_list = nodes.definition_list()
     section.append(prop_list)
     for prop_key in sorted(self.props_schemata.keys()):
         prop = self.props_schemata[prop_key]
         self.contribute_property(prop_list, prop_key, prop)
Exemplo n.º 38
0
 def contribute_update_policy(self, parent):
     if not self.update_policy_schemata:
         return
     section = self._section(parent, _('UpdatePolicy'), '%s-updpolicy')
     prop_list = nodes.definition_list()
     section.append(prop_list)
     for prop_key, prop in sorted(self.update_policy_schemata.items(),
                                  self.cmp_prop):
         self.contribute_property(prop_list, prop_key, prop)
Exemplo n.º 39
0
    def run(self):
        # Raise an error if the directive does not have contents.
        self.assert_has_content()
        self.document = self.state_machine.document

        text = '\n'.join(self.content)
        # Create the admonition node, to be populated by `nested_parse`.

        self.name = self.arguments[0]
        
        term = nodes.term()
        term += nodes.strong(text=self.arguments[0]) 
        
        targetnode = self.make_targetnode()

        deflist = nodes.definition_list()
        test_def = nodes.definition_list_item()
        test_def += term
        defn = nodes.definition()
        test_def += defn
        deflist += test_def


        # CURRENT : Parse direction list if provided, which is comma-separated
        if 'direction' in self.options:
            input = 0
            output = 0

            for p in self.options['direction'].split(","):
#                print "Testing `" + p.strip() + "' in test_procedure `" + self.name + "'..."

                if p == "input":
                    input = 1
                
                if p == "output":
                    output = 2

            self.direction = input + output


        # Parse the directive contents.
        self.state.nested_parse(self.content, self.content_offset, defn)

        option_map = {}
        option_map['setup'] = 'Required setup'
        option_map['direction'] = 'Direction (input|output|both)'
        field_list = self.options_to_field_list(option_map)

        if (field_list != None):
            defn += field_list

        #print "*** TestProcedure options setup = " + self.options['setup']
        if 'setup' in self.options:
            self.setup = self.options['setup']

        self.parsed('test_procedure').append(self)
        return [targetnode, deflist]
Exemplo n.º 40
0
 def contribute_properties(self, section):
     schema = self.resource_class.properties_schema
     if not schema:
         return
     section.append(nodes.strong('', _('Properties')))
     prop_list = nodes.definition_list()
     section.append(prop_list)
     for prop_key in sorted(schema.keys()):
         prop = schema[prop_key]
         self.contribute_property(prop_list, prop_key, prop)
Exemplo n.º 41
0
 def contribute_properties(self, parent):
     schema = self.resource_class.properties_schema
     if not schema:
         return
     section = self._section(parent, _("Properties"), "%s-props")
     prop_list = nodes.definition_list()
     section.append(prop_list)
     for prop_key in sorted(schema.keys()):
         prop = schema[prop_key]
         self.contribute_property(prop_list, prop_key, prop)
Exemplo n.º 42
0
def format_properties(model):
    list = nodes.definition_list()
    for prop in model['properties']:
        term = nodes.term('', prop['name'])
        definition = nodes.definition('')
        definition += nodes.strong('', '(' + prop['type'] + ') ')
        definition += format_javadoc(prop['doc'])
        item = nodes.definition_list_item('', term, definition)
        list.append(item)
    return list
Exemplo n.º 43
0
    def contribute_update_policy(self, parent):
        if not self.update_policy_schemata:
            return
        section = self._section(parent, _('update_policy'), '%s-updpolicy')
        definition_list = nodes.definition_list()
        section.append(definition_list)

        for _key, _prop in sorted(self.update_policy_schemata.items(),
                                  key=cmp_to_key(self.cmp_prop)):
            self.contribute_property(definition_list, _key, _prop)
Exemplo n.º 44
0
    def _create_def_list(self, parent):
        """Creates a definition list

        :returns: Definition list node
        """

        definition_list = nodes.definition_list()
        parent.append(definition_list)

        return definition_list
Exemplo n.º 45
0
    def run(self):
        # Raise an error if the directive does not have contents.
        self.assert_has_content()
        self.document = self.state_machine.document

        text = '\n'.join(self.content)
        # Create the admonition node, to be populated by `nested_parse`.

        self.name = self.arguments[0]

        term = nodes.term()
        term += nodes.strong(text=self.arguments[0])

        targetnode = self.make_targetnode()

        deflist = nodes.definition_list()
        test_def = nodes.definition_list_item()
        test_def += term
        defn = nodes.definition()
        test_def += defn
        deflist += test_def

        # CURRENT : Parse direction list if provided, which is comma-separated
        if 'direction' in self.options:
            input = 0
            output = 0

            for p in self.options['direction'].split(","):
                #                print "Testing `" + p.strip() + "' in test_procedure `" + self.name + "'..."

                if p == "input":
                    input = 1

                if p == "output":
                    output = 2

            self.direction = input + output

        # Parse the directive contents.
        self.state.nested_parse(self.content, self.content_offset, defn)

        option_map = {}
        option_map['setup'] = 'Required setup'
        option_map['direction'] = 'Direction (input|output|both)'
        field_list = self.options_to_field_list(option_map)

        if (field_list != None):
            defn += field_list

        #print "*** TestProcedure options setup = " + self.options['setup']
        if 'setup' in self.options:
            self.setup = self.options['setup']

        self.parsed('test_procedure').append(self)
        return [targetnode, deflist]
Exemplo n.º 46
0
    def run(self):
        #self.assert_has_content()
        self.document = self.state_machine.document
        #text = '\n'.join(self.content)
        # Create the admonition node, to be populated by `nested_parse`.

        self.name = self.arguments[0]

        term = nodes.term()
        term += nodes.strong(text=self.arguments[0])

        targetnode = self.make_targetnode()

        deflist = nodes.definition_list()
        test_def = nodes.definition_list_item()
        test_def += term
        defn = nodes.definition()
        test_def += defn
        deflist += test_def

        # Parse the directive contents.
        self.state.nested_parse(self.content, self.content_offset, defn)

        option_map = {}
        option_map['runtests'] = 'Tests to run'
        field_list = self.options_to_field_list(option_map)

        if 'runtests' in self.options:
            self.runtests = []
            for p in self.options['runtests'].split(","):
                #                print "Testing for `" + p.strip() + "' in prepare_setup `" + self.name + "'..."
                newruntests = [
                    t for t in self.parsed('test') if p.strip() == t.name
                ]
                if len(newruntests) == 0:
                    sys.stderr.write(
                        "ERROR : runtests field couldn't expand to any tests for name `"
                        + p.strip() + "'\n")
                    if (self.check_errors()):
                        exit(1)


#                for t in newruntests :
#                    print "Runtests adding test : " + t.name

                self.runtests.extend(newruntests)

        else:
            self.runtests = []

        if (field_list != None):
            defn += field_list

        self.parsed('prepare_setup').append(self)
        return [targetnode, deflist]
Exemplo n.º 47
0
def codeitem_directive(dirname, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
    if not content:
        content = [u""]

    m = _CALLABLE_RE.match(u"".join(arguments))
    m2 = _OTHER_RE.match(u"".join(arguments))
    if m:
        g = m.groupdict()
        if g['rest'] is None:
            g['rest'] = ''
        if g['args'].strip():
            firstline = "%s%s **%s** (``%s``) %s" % (g['pre'].replace('*', r'\*'),
                                                     g['module'], g['name'],
                                                     g['args'], g['rest'])
        else: 
            firstline = "%s%s **%s** () %s" % (g['pre'].replace('*', r'\*'),
                                               g['module'], g['name'],
                                               g['rest'])
        if g['module']:
            target = '%s%s' % (g['module'], g['name'])
        else:
            target = g['name']
    elif m2:
        g = m2.groupdict()
        firstline = "%s%s **%s**" % (g['pre'].replace('*', r'\*'),
                                     g['module'], g['name'])
        if g['module']:
            target = '%s%s' % (g['module'], g['name'])
        else:
            target = g['name']
    else:
        firstline = u"".join(arguments)
        target = None


    dl = nodes.definition_list()
    di = nodes.definition_list_item()
    dl += di
    
    title_stuff, messages = state.inline_text(firstline, lineno)
    dt = nodes.term(firstline, *title_stuff)
    di += dt

    dd = nodes.definition()
    di += dd
    
    if target:
        dt['ids'] += [rst.make_target_id(target)]

    dl['classes'] += [dirname, 'code-item']
    _nested_parse(state, content, dd)
    
    return [dl]
Exemplo n.º 48
0
    def contribute_properties(self, parent):
        if not self.props_schemata:
            return
        section = self._section(parent, _('Properties'), '%s-props')
        prop_list = nodes.definition_list()
        section.append(prop_list)

        for prop_key, prop in sorted(self.props_schemata.items(),
                                     self.cmp_prop):
            if prop.support_status.status != support.HIDDEN:
                self.contribute_property(prop_list, prop_key, prop)
Exemplo n.º 49
0
    def rst_nodes(self):

        defs = []

        # Get all the memberdef info
        for memberdef in self.memberdef:
            defs.extend(memberdef.rst_nodes())

        def_list = nodes.definition_list("", *defs)

        # Return with information about which section this is
        return [def_list]
Exemplo n.º 50
0
 def render(self):
   symbol = self.symbol()
   if not symbol.exceptions:
     yield nodes.paragraph(text=_('None.'))
   else:
     definition_list = nodes.definition_list()
     for k, v in symbol.exceptions.iteritems():
       definition_list_item = nodes.definition_list_item('',
         nodes.term('', '', nodes.literal('', k)),
         nodes.definition('', nodes.paragraph(text=v)))
       definition_list.append(definition_list_item)
     yield definition_list
def codeitem_directive(dirname, arguments, options, content, lineno, content_offset, block_set, state, state_machine):
    if not content:
        content = [u""]

    m = _CALLABLE_RE.match(u"".join(arguments))
    m2 = _OTHER_RE.match(u"".join(arguments))
    if m:
        g = m.groupdict()
        if g["rest"] is None:
            g["rest"] = ""
        if g["args"].strip():
            firstline = "%s%s **%s** (``%s``) %s" % (
                g["pre"].replace("*", r"\*"),
                g["module"],
                g["name"],
                g["args"],
                g["rest"],
            )
        else:
            firstline = "%s%s **%s** () %s" % (g["pre"].replace("*", r"\*"), g["module"], g["name"], g["rest"])
        if g["module"]:
            target = "%s%s" % (g["module"], g["name"])
        else:
            target = g["name"]
    elif m2:
        g = m2.groupdict()
        firstline = "%s%s **%s**" % (g["pre"].replace("*", r"\*"), g["module"], g["name"])
        if g["module"]:
            target = "%s%s" % (g["module"], g["name"])
        else:
            target = g["name"]
    else:
        firstline = u"".join(arguments)
        target = None

    dl = nodes.definition_list()
    di = nodes.definition_list_item()
    dl += di

    title_stuff, messages = state.inline_text(firstline, lineno)
    dt = nodes.term(firstline, *title_stuff)
    di += dt

    dd = nodes.definition()
    di += dd

    if target:
        dt["ids"] += [target]

    dl["classes"] += [dirname, "code-item"]
    _nested_parse(state, content, dd)

    return [dl]
Exemplo n.º 52
0
    def contribute_properties(self, parent):
        if not self.props_schemata:
            return
        section = self._section(parent, _('Properties'), '%s-props')
        prop_list_required = nodes.definition_list()
        subsection_required = self._section(section, _('required'),
                                            '%s-props-req')
        subsection_required.append(prop_list_required)

        prop_list_optional = nodes.definition_list()
        subsection_optional = self._section(section, _('optional'),
                                            '%s-props-opt')
        subsection_optional.append(prop_list_optional)

        for prop_key, prop in sorted(self.props_schemata.items(),
                                     self.cmp_prop):
            if prop.support_status.status != support.HIDDEN:
                if prop.required:
                    prop_list = prop_list_required
                else:
                    prop_list = prop_list_optional
                self.contribute_property(prop_list, prop_key, prop)
Exemplo n.º 53
0
 def run(self):
     refid = 'cmdoption-arg-' + nodes.make_id(self.arguments[0])
     target = nodes.target(names=[refid], ids=[refid])
     dl = nodes.definition_list()
     dt = nodes.definition_list_item()
     term = nodes.term()
     term += nodes.literal(self.arguments[0], self.arguments[0], classes=["descname"])
     dt += term
     definition = nodes.definition()
     dt += definition
     definition.document = self.state.document
     self.state.nested_parse(self.content, self.content_offset, definition)
     dl += dt
     return [target, dl]
Exemplo n.º 54
0
    def run(self):
        #self.assert_has_content()
        self.document = self.state_machine.document
        #text = '\n'.join(self.content)
        # Create the admonition node, to be populated by `nested_parse`.

        self.name = self.arguments[0]
        
        term = nodes.term()
        term += nodes.strong(text=self.arguments[0]) 
        
        targetnode = self.make_targetnode()

        deflist = nodes.definition_list()
        test_def = nodes.definition_list_item()
        test_def += term
        defn = nodes.definition()
        test_def += defn
        deflist += test_def

        # Parse the directive contents.
        self.state.nested_parse(self.content, self.content_offset, defn)

        option_map = {}
        option_map['runtests'] = 'Tests to run'
        field_list = self.options_to_field_list(option_map)

        if 'runtests' in self.options:
            self.runtests = []
            for p in self.options['runtests'].split(","):
#                print "Testing for `" + p.strip() + "' in prepare_setup `" + self.name + "'..."
                newruntests = [t for t in self.parsed('test') if p.strip() == t.name]
                if len(newruntests) == 0:
                    sys.stderr.write("ERROR : runtests field couldn't expand to any tests for name `" + p.strip() + "'\n")
                    if (self.check_errors()):
                        exit(1)

#                for t in newruntests :
#                    print "Runtests adding test : " + t.name
    
                self.runtests.extend(newruntests)

        else:
            self.runtests = []

        if (field_list != None):
            defn += field_list

        self.parsed('prepare_setup').append(self)
        return [targetnode, deflist]
Exemplo n.º 55
0
    def document_group(self):
        rv = nodes.definition_list()
        try:
            (children, groups) = \
                self.get_child_elements(self.entity, nodeclass=nodes.paragraph)
        except TypeError:
            return [build_paragraph(nodes.strong("Any", "Any"),
                                    " arbitrary element allowed")]

        append_node(rv, nodes.term, text("Elements:"))
        append_node(rv, nodes.definition, *children)
        if len(groups):
            append_node(rv, nodes.term, text("Element groups:"))
            append_node(rv, nodes.definition, *groups)
        return rv
Exemplo n.º 56
0
 def render(self):
   symbol = self.symbol()
   if not symbol.params:
     yield nodes.paragraph(text=_('None.'))
   else:
     definition_list = nodes.definition_list()
     for param in symbol.params:
       param_name = param.get('declname')
       if param_name is not None:
         param_desc = param.get('briefdescription', '')
         definition_list_item = nodes.definition_list_item('',
           nodes.term('', '', nodes.literal('', param_name)),
           nodes.definition('', nodes.paragraph(text=param_desc)))
         definition_list.append(definition_list_item)
     yield definition_list
Exemplo n.º 57
0
def print_command_args_and_opts(arg_list, opt_list, sub_list=None):
    items = []
    if arg_list:
        items.append(nodes.definition_list_item(
            '', nodes.term(text='Positional arguments:'),
            nodes.definition('', arg_list)))
    if opt_list:
        items.append(nodes.definition_list_item(
            '', nodes.term(text='Options:'),
            nodes.definition('', opt_list)))
    if sub_list and len(sub_list):
        items.append(nodes.definition_list_item(
            '', nodes.term(text='Sub-commands:'),
            nodes.definition('', sub_list)))
    return nodes.definition_list('', *items)