コード例 #1
0
    def after_content(self):
        ObjectDescription.after_content(self)

        if not self.content:
            return

        node = nodes.paragraph()
        self.state.nested_parse(self.content, 0, node)

        sig_done = False
        sig = f"function {self.names[0]}"
        try:
            func_def = node.children[0][0][1][0]
            node_type = func_def.children[0][0][0]
            if node_type == "function":
                for a in func_def.children[1:-2:2]:
                    sig += a.title().strip()
                sig_done = True
        except IndexError:
            pass

        if sig_done:
            sig += ")"
            print(sig)
        if not node.children or node.children[-1].tagname != "paragraph":
            logger.error(f"{self.names[0]} is undocumented")
コード例 #2
0
ファイル: rose_domain.py プロジェクト: aosprey/rose
    def after_content(self):
        """This method is called after child objects have been processed.

        There is also the ``before_content()`` method which is called during
        ``run()`` before child objects have been processed but after the
        current object has been processed.
        """
        for ind, child_node in enumerate(self.registered_children):
            self.registered_children[ind] = child_node.run()[1]
        for context_var in self.ref_context_to_remove:
            self.remove_ref_context(context_var)
        ObjectDescription.after_content(self)
コード例 #3
0
    def after_content(self):
        """This method is called after child objects have been processed.

        There is also the ``before_content()`` method which is called during
        ``run()`` before child objects have been processed but after the
        current object has been processed.
        """
        for ind, child_node in enumerate(self.registered_children):
            self.registered_children[ind] = child_node.run()[1]
        for context_var in self.ref_context_to_remove:
            self.remove_ref_context(context_var)
        ObjectDescription.after_content(self)
コード例 #4
0
ファイル: base.py プロジェクト: otamachan2/sphinxcontrib-ros
 def run(self):
     node = ObjectDescription.run(self)
     contentnode = node[1][-1]
     # label is the key to find the field-value
     labelmap = {field_type.name: unicode(field_type.label)  # name -> label
                 for field_type in self.doc_field_types}
     field_nodes = {}
     for child in contentnode:
         if isinstance(child, nodes.field_list):
             for field in child:
                 if isinstance(field, nodes.field):
                     # label -> field_node
                     field_nodes[field[0].astext()] = field
     # merge
     for field_src, field_dest in self.doc_merge_fields.items():
         # name -> label -> field_node
         label_src = labelmap[field_src]
         if label_src in field_nodes:
             field_node_src = field_nodes[label_src]
             label_dest = labelmap[field_dest]
             if label_dest in field_nodes:
                 field_node_dest = field_nodes[label_dest]
                 for item_src in field_node_src[1][0]:
                     name = item_src[0][0].astext()
                     for item_dest in field_node_dest[1][0]:
                         if name == item_dest[0][0].astext():
                             # merge first paragraph
                             self.merge_field(item_src[0],
                                              item_dest[0])
             for child in contentnode:
                 if isinstance(child, nodes.field_list):
                     child.remove(field_node_src)
     return node
コード例 #5
0
ファイル: desc.py プロジェクト: lunaryorn/sphinxcontrib-emacs
    def run(self):
        """Run this directive.

        In addition to the default processing of the
        :class:`~sphinx.directives.ObjectDescription` directive, add the
        automatically extracted documentation if the ``auto`` option was set.

        """
        result_nodes = ObjectDescription.run(self)

        if 'auto' in self.options:
            cont_node = result_nodes[-1][-1]
            symbol = self.lookup_auto_symbol()
            docstring = symbol and self.get_auto_docstring(symbol)
            if not docstring:
                self.state_machine.reporter.warning(
                    'no docstring for symbol {0}'.format(self.names[0]),
                    line=self.lineno)
            else:
                self.before_content()
                # We don't add the raw source to prevent Sphinx from trying to
                # highlight this block.  Yes, that's hacky, but we've
                # apparently no other chance to keep Pygments out of the party
                docstring_block = nodes.el_docstring_block(docstring, docstring)
                cont_node.insert(0, docstring_block)
                transformer = EmacsHelpModeMarkup(self.state.document,
                                                  docstring_block)
                transformer.apply()
                self.after_content()

        return result_nodes
コード例 #6
0
ファイル: faberdomain.py プロジェクト: terrorfisch/faber
 def run(self):
     index, content = ObjectDescription.run(self)
     fields = nodes.field_list()
     for f in self.fields:
         field = f.make_field(self)
         if field:
             fields += field
     # Insert option fields right after signature
     content.insert(1, fields)
     return [index, content]
コード例 #7
0
    def run(self):
        env = self.state.document.settings.env

        self.name = self.get_name()
        fullname = self.get_fullname(self.name)

        if 'noindex' not in self.options:
            env.domaindata['d']['objects'][fullname] = (env.docname, self.get_objtype())

        return ObjectDescription.run(self)
コード例 #8
0
    def after_content(self):
        ObjectDescription.after_content(self)

        if not self.content:
            return

        node = nodes.paragraph()
        self.state.nested_parse(self.content, 0, node)

        # node    <paragraph>
        # node[0]        <field_list>
        # node[0][0]            <field>
        # node[0][0][0]                <field_name>
        # node[0][0][0][0]                     Type
        # node[0][0][1]                <field_body>
        # node[0][0][1][0]                    <paragraph>
        # node[0][0][1][0][0]                        <pending_xref refdoc="scripts/NCSA/external_dns/main.zeek" refdomain="zeek" refexplicit="False" reftarget="function" reftype="type" refwarn="False">
        # node[0][0][1][0][0][0]                            <literal classes="xref zeek zeek-type">
        # node[0][0][1][0][0][0][0]                                function

        sig_done = False
        sig = f"function {self.names[0]}"
        try:
            func_def = node.children[0][0][1][0]
            node_type = func_def.children[0][0][0]
            if node_type == "function":
                for a in func_def.children[1:-2:2]:
                    sig += a.title().strip()
                sig_done = True
        except Exception:
            pass

        if sig_done:
            sig += ")"
            print(sig)
        if not node.children or node.children[-1].tagname != "paragraph":
            logger.error(f"{self.names[0]} is undocumented")
コード例 #9
0
ファイル: desc.py プロジェクト: lunaryorn/sphinxcontrib-emacs
    def get_signatures(self):
        """Get all signatures of the current description unit.

        If the symbol is auto-documented, get the source code signature via
        :meth:`get_auto_signature`.  Otherwise, fall back to Sphinx' standard
        means of parsing signatures.

        Return a list of all signatures.

        """
        symbol = self.lookup_auto_symbol(self.arguments[0].split(None, 1)[0])
        if symbol:
            return [self.get_auto_signature(symbol)]
        else:
            return ObjectDescription.get_signatures(self)
コード例 #10
0
ファイル: rose_domain.py プロジェクト: aosprey/rose
    def run(self):
        # Automatically generate the "rose:NAME" ref_context variable.
        self.add_ref_context(self.NAME)
        index_node, cont_node = ObjectDescription.run(self)

        # Add a marker on the output node so we can determine the context
        # namespace later (see RoseDomain.resolve_xref).
        context_var = self.ROSE_CONTEXT % self.NAME
        cont_node.ref_context = {context_var: self.process_name(
            self.arguments[0].strip())[0]}

        # Add children if initialised via python - see RoseAutoDirective.
        block = block_quote()  # Create indented section.
        for child_node in self.registered_children:
            block.append(child_node)  # Add child node to indented section.
        cont_node.append(block)  # Add indented section to this node.

        return [index_node, cont_node]
コード例 #11
0
    def run(self):
        # Automatically generate the "rose:NAME" ref_context variable.
        self.add_ref_context(self.NAME)
        index_node, cont_node = ObjectDescription.run(self)

        # Add a marker on the output node so we can determine the context
        # namespace later (see RoseDomain.resolve_xref).
        context_var = self.ROSE_CONTEXT % self.NAME
        cont_node.ref_context = {context_var: self.process_name(
            self.arguments[0].strip())[0]}

        # Add children if initialised via python - see RoseAutoDirective.
        block = block_quote()  # Create indented section.
        for child_node in self.registered_children:
            block.append(child_node)  # Add child node to indented section.
        cont_node.append(block)  # Add indented section to this node.

        return [index_node, cont_node]
コード例 #12
0
    def run(self):
        nodes = ObjectDescription.run(self)

        # Insert a dedicated signature for the key binding before all other
        # signatures, but only for commands.  Nothing else has key bindings.
        binding = self.options.get('binding')
        if binding:
            binding = self.with_prefix_arg(binding)
            desc_node = nodes[-1]
            assert isinstance(desc_node, addnodes.desc)
            signode = addnodes.desc_signature(binding, '')
            # No clue what this property is for, but ObjectDescription sets it
            # for its signatures, so we should do as well for our signature.
            signode['first'] = False
            desc_node.insert(0, signode)
            signode += addnodes.desc_name(binding, binding)

        return nodes
コード例 #13
0
ファイル: eldomain.py プロジェクト: huonw/flycheck
    def run(self):
        nodes = ObjectDescription.run(self)

        # Insert a dedicated signature for the key binding before all other
        # signatures, but only for commands.  Nothing else has key bindings.
        binding = self.options.get('binding')
        if binding:
            binding = self.with_prefix_arg(binding)
            desc_node = nodes[-1]
            assert isinstance(desc_node, addnodes.desc)
            signode = addnodes.desc_signature(binding, '')
            # No clue what this property is for, but ObjectDescription sets it
            # for its signatures, so we should do as well for our signature.
            signode['first'] = False
            desc_node.insert(0, signode)
            signode += addnodes.desc_name(binding, binding)

        return nodes
コード例 #14
0
    def run(self):
        index, content = ObjectDescription.run(self)
        fields = nodes.field_list()
        for f in self.fields:
            field = f.make_field(self)
            if field:
                fields += field
        # Insert option fields right after signature
        content.insert(1, fields)

        name = self.arguments[0]
        module = self.options.get('module', None)
        qname = '{}.{}'.format(module, name) if module else name
        classname = self.name[4:] if self.name.startswith(
            'fab:') else self.name
        indextext = '{} ({} in {})'.format(name, classname, module)
        index = addnodes.index(entries=[('single', indextext, name, None,
                                         None)])
        return [index, content]
コード例 #15
0
ファイル: base.py プロジェクト: yosuke/sphinxcontrib-ros
 def run(self):
     node = ObjectDescription.run(self)
     contentnode = node[1][-1]
     # label is the key to find the field-value
     labelmap = {field_type.name: unicode(field_type.label)  # name -> label
                 for field_type in self.doc_field_types}
     field_nodes = {}
     for child in contentnode:
         if isinstance(child, nodes.field_list):
             for field in child:
                 if isinstance(field, nodes.field):
                     # label -> field_node
                     field_nodes[field[0].astext()] = field
     # merge fields
     # ex)
     # :constant CONST: description
     # :constant-type CONST: int32
     # :constant-value: value
     for field_src, field_dest in self.doc_merge_fields.items():
         # name -> label -> field_node
         label_src = labelmap[field_src]
         if label_src in field_nodes:
             field_node_src = field_nodes[label_src]
             label_dest = labelmap[field_dest]
             if label_dest in field_nodes:
                 field_node_dest = field_nodes[label_dest]
                 for item_src in field_node_src[1][0]:
                     name = item_src[0][0].astext()
                     for item_dest in field_node_dest[1][0]:
                         if name == item_dest[0][0].astext():
                             # merge first paragraph
                             self.merge_field(item_src[0],
                                              item_dest[0])
             for child in contentnode:
                 if isinstance(child, nodes.field_list):
                     child.remove(field_node_src)
     return node
コード例 #16
0
    def run(self):
        self.ref_context_key = self.get_reference_context()

        index_node, cont_node = ObjectDescription.run(self)

        return [index_node, cont_node]
コード例 #17
0
 def __init__(self, *args, **kwargs):
     self.ref_context_to_remove = []  # Cannot do this in run().
     self.registered_children = []
     ObjectDescription.__init__(self, *args, **kwargs)
コード例 #18
0
ファイル: rose_domain.py プロジェクト: aosprey/rose
 def __init__(self, *args, **kwargs):
     self.ref_context_to_remove = []  # Cannot do this in run().
     self.registered_children = []
     ObjectDescription.__init__(self, *args, **kwargs)
コード例 #19
0
ファイル: bsvsphinx.py プロジェクト: chenm001/connectal
 def get_signatures(self):
     siglines = ObjectDescription.get_signatures(self)
     return siglines
コード例 #20
0
 def after_content(self):
     # remove ref_context_key variable
     self.state.document.settings.env.ref_context.pop(self.ref_context_key)
     ObjectDescription.after_content(self)
コード例 #21
0
 def before_content(self):
     ObjectDescription.before_content(self)
     if self.names:
         self.env.temp_data["java:class"] = self.names[0]
コード例 #22
0
ファイル: __init__.py プロジェクト: aldebaran/doc-tools
 def __init__(self, *args, **kwargs):
     CPPAutoDocObject.__init__(self)
     ObjectDescription.__init__(self, *args, **kwargs)
コード例 #23
0
 def before_content(self):
     # add ref_context_key variable
     self.state.document.settings.env.ref_context[self.ref_context_key] = (
         id(self))
     ObjectDescription.before_content(self)
コード例 #24
0
ファイル: bsvsphinx.py プロジェクト: acw1251/connectal
 def get_signatures(self):
     siglines = ObjectDescription.get_signatures(self)
     return siglines