def import_object(self, raiseerror: bool = False) -> bool: """ Never import anything. :param raiseerror: """ # disguise as an attribute self.objtype = "attribute" self._datadescriptor = True with mock(self.env.config.autodoc_mock_imports): try: ret = import_object( self.modname, self.objpath[:-1], "class", attrgetter=self.get_attr, warningiserror=self.env.config.autodoc_warningiserror) self.module, _, _, self.parent = ret return True except ImportError as exc: if raiseerror: raise else: logger.warning(exc.args[0], type="autodoc", subtype="import_object") self.env.note_reread() return False
def import_object(self, raiseerror: bool = False) -> bool: """ Import the object given by *self.modname* and *self.objpath* and set it as ``self.object``. :returns: :py:obj:`True` if successful, :py:obj:`False` if an error occurred. """ try: ret = super().import_object(raiseerror=True) if inspect.isenumattribute(self.object): self.object = self.object.value if inspect.isattributedescriptor(self.object): self._datadescriptor = True else: # if it's not a data descriptor self._datadescriptor = False except ImportError as exc: if self.isinstanceattribute(): self.object = INSTANCEATTR self._datadescriptor = False ret = True elif raiseerror: raise else: logger.warning(exc.args[0], type="autodoc", subtype="import_object") self.env.note_reread() ret = False return ret
def unknown_module_warning(documenter: Documenter) -> None: """ Log a warning that the module to import the object from is unknown. .. versionadded:: 0.2.0 :param documenter: """ msg = __( "don't know which module to import for autodocumenting %r " '(try placing a "module" or "currentmodule" directive in the document, ' "or giving an explicit module name)") logger.warning(msg % documenter.name, type="autodoc")
def filter_members_warning(member, exception: Exception) -> None: """ Log a warning when filtering members. .. versionadded:: 0.2.0 :param member: :param exception: """ logger.warning(__( "autodoc: failed to determine %r to be documented, the following exception was raised:\n%s" ), member, exception, type="autodoc")
def unknown_module_warning(documenter: Documenter) -> None: """ Log a warning that the module to import the object from is unknown. :param documenter: :rtype: .. versionadded:: 0.2.0 """ logger.warning( __("don't know which module to import for autodocumenting " '%r (try placing a "module" or "currentmodule" directive ' "in the document, or giving an explicit module name)") % documenter.name, type="autodoc")