def add_directive_header(self, sig):
        """ Add the sphinx directives.

        Add the 'attribute' directive with the annotation option
        set to the trait definition.

        """
        ModuleLevelDocumenter.add_directive_header(self, sig)
        if hasattr(self, 'get_sourcename'):
            sourcename = self.get_sourcename()
        else:
            sourcename = '<autodoc>'
        if not self.options.annotation:
            try:
                definition = get_trait_definition(
                    self.parent, self.object_name)
            except DefinitionError as error:
                self.directive.warn(error.args[0])
                return

            self.add_line(
                '   :annotation: = {0}'.format(definition), sourcename)
        elif self.options.annotation is SUPPRESS:
            pass
        else:
            self.add_line(
                '   :annotation: %s' % self.options.annotation, sourcename)
Пример #2
0
 def add_directive_header(self, sig):
     # We can't call super() here, because we want to *skip* executing
     # FunctionDocumenter.add_directive_header, because starting in Sphinx
     # 2.1 it does its own sniffing, which is worse than ours and will
     # break ours. So we jump straight to the superclass.
     ModuleLevelDocumenter.add_directive_header(self, sig)
     passthrough_option_lines(self, extended_function_option_spec)
Пример #3
0
 def add_directive_header(self, sig):
     ModuleLevelDocumenter.add_directive_header(self, sig)
     if not self.options.annotation:
         try:
             objrepr = safe_repr(self.object)
         except ValueError:
             pass
         else:
             self.add_line(u'   :annotation:', '<autodoc>')
     elif self.options.annotation is object():
         pass
     else:
         self.add_line(u'   :annotation: %s' % self.options.annotation,
                       '<autodoc>')
Пример #4
0
    def add_directive_header(self, sig: str):
        """
		Add the directive's header.

		:param sig:
		"""

        sourcename = self.get_sourcename()

        no_value = self.options.get("no-value", False)
        no_type = self.options.get("no-type", False)

        if not self.options.get("annotation", ''):
            ModuleLevelDocumenter.add_directive_header(self, sig)

            if not no_value:
                if "value" in self.options:
                    self.add_line(f"   :value: {self.options['value']}",
                                  sourcename)
                else:
                    with suppress(ValueError):
                        if self.object is not UNINITIALIZED_ATTR:
                            objrepr = object_description(self.object)
                            self.add_line(f"   :value: {objrepr}", sourcename)

            self.add_line('', sourcename)

            if not no_type:
                if "type" in self.options:
                    the_type = self.options["type"]
                else:
                    # obtain type annotation for this data
                    the_type = get_variable_type(self)
                    if not the_type.strip():
                        obj_type = type(self.object)

                        if obj_type is object:
                            return

                        try:
                            the_type = format_annotation(obj_type)
                        except Exception:
                            return

                line = type_template % the_type
                self.add_line(line, sourcename)

        else:
            super().add_directive_header(sig)
Пример #5
0
 def add_directive_header(self, sig):
     ModuleLevelDocumenter.add_directive_header(self, sig)
     if not self.options.annotation:
         try:
             objrepr = safe_repr(self.object)
         except ValueError:
             pass
         else:
             if not SKIP_ANNOTATION_RE.match(self.fullname):
                 self.add_line(u'   :annotation: = ' + objrepr, '<autodoc>')
     elif self.options.annotation is SUPPRESS:
         pass
     else:
         self.add_line(u'   :annotation: %s' % self.options.annotation,
                       '<autodoc>')
Пример #6
0
 def add_directive_header(self, sig):
     ModuleLevelDocumenter.add_directive_header(self, sig)
     if not self.options.annotation:
         try:
             objrepr = safe_repr(self.object)
         except ValueError:
             pass
         else:
             self.add_line(u'   :annotation:', '<autodoc>')
     elif self.options.annotation is object():
         pass
     else:
         self.add_line(
             u'   :annotation: {}'.format(self.options.annotation),
             '<autodoc>')
Пример #7
0
 def add_directive_header(self, sig):
     ModuleLevelDocumenter.add_directive_header(self, sig)
     if not self.options.annotation:
         try:
             objrepr = safe_repr(self.object)
         except ValueError:
             pass
         else:
             if not (objrepr.startswith('<') and objrepr.endswith('>')):
                 self.add_line(u'   :annotation: = ' + objrepr, '<autodoc>')
             else:
                 self.add_line(u'   :annotation:', '<autodoc>')
     elif self.options.annotation is object():
         pass
     else:
         self.add_line(u'   :annotation: %s' % self.options.annotation,
                       '<autodoc>')
Пример #8
0
    def import_object(self):
        ret = ModuleLevelDocumenter.import_object(self)
        if not ret:
            return ret

        if asyncio.iscoroutinefunction(self.object):
            self.directivetype = "coroutinefunction"

        return ret
Пример #9
0
    def import_object(self):
        ret = ModuleLevelDocumenter.import_object(self)
        if not ret:
            return ret

        if asyncio.iscoroutinefunction(self.object):
            self.directivetype = "coroutinefunction"

        return ret
Пример #10
0
def add_directive_header(self, sig):
    ModuleLevelDocumenter.add_directive_header(self, sig)
    if not self.options.annotation:
        try:
            objrepr = object_description(self.object)

            # PATCH: truncate the value if longer than 50 characters
            if len(objrepr) > 50:
                objrepr = objrepr[:50] + "..."

        except ValueError:
            pass
        else:
            self.add_line(u'   :annotation: = ' + objrepr, '<autodoc>')
    elif self.options.annotation is SUPPRESS:
        pass
    else:
        self.add_line(u'   :annotation: %s' % self.options.annotation,
                      '<autodoc>')
Пример #11
0
def add_directive_header(self, sig):
    # type: (unicode) -> None
    ModuleLevelDocumenter.add_directive_header(self, sig)
    sourcename = self.get_sourcename()
    if not self.options.annotation:
        try:
            objrepr = object_description(self.object)

            # PATCH: truncate the value if longer than 50 characters
            if len(objrepr) > 50:
                objrepr = objrepr[:50] + "..."
        except ValueError:
            pass
        else:
            self.add_line(u'   :annotation: = ' + objrepr, sourcename)
    elif self.options.annotation is SUPPRESS:
        pass
    else:
        self.add_line(u'   :annotation: %s' % self.options.annotation,
                      sourcename)
Пример #12
0
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'crython', 'crython Documentation', author, 'crython',
     'One line description of project.', 'Miscellaneous'),
]

# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}

# Disable displaying module member values.
DataDocumenter.add_directive_header = lambda s, sig: ModuleLevelDocumenter.add_directive_header(
    s, sig)
Пример #13
0
def add_directive_header(self,sig):
    ModuleLevelDocumenter.add_directive_header(self,sig)
Пример #14
0
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'crython', 'crython Documentation',
     author, 'crython', 'One line description of project.',
     'Miscellaneous'),
]

# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}

# Disable displaying module member values.
DataDocumenter.add_directive_header = lambda s, sig: ModuleLevelDocumenter.add_directive_header(s, sig)
Пример #15
0
 def add_directive_header(self, sig):
     self.directivetype = ("arsdk_cmd_message" if
                           self.object.message_type is ArsdkMessageType.CMD
                           else "arsdk_event_message")
     ModuleLevelDocumenter.add_directive_header(self, sig)
Пример #16
0
 def add_directive_header(self, sig):
     self.directivetype = {
         ArsdkMessageType.CMD: "arsdk_cmd_message",
         ArsdkMessageType.EVT: "arsdk_event_message",
     }.get(self.object.message_type, "arsdk_message")
     ModuleLevelDocumenter.add_directive_header(self, sig)
Пример #17
0
 def add_directive_header(self, sig):
     self.directivetype = "arsdk_enum"
     ModuleLevelDocumenter.add_directive_header(self, sig)
Пример #18
0
def add_directive_header(self, sig):
    ModuleLevelDocumenter.add_directive_header(self, sig)
 def add_content(self, more_content, no_docstring=False):
     # Never try to get a docstring from the trait object.
     ModuleLevelDocumenter.add_content(self, more_content, no_docstring=True)