def import_object(self): """Load an object.""" # Get the object if not ClassLevelDocumenter.import_object(self): return False # Reload modules self.parent = reload_object(self.parent) reload(import_module(self.modname)) # Get the new object return ClassLevelDocumenter.import_object(self)
def import_object(self): # type: () -> Any ret = ClassLevelDocumenter.import_object(self) if not ret: return ret # get parent's class parent_cls = self.parent if not isinstance(parent_cls, type): parent_cls = parent_cls.__class__ # if instance, get its class # to distinguish classmethod/staticmethod obj = parent_cls.__dict__.get(self.object_name) if obj is None: obj = self.object if isclassmethod(obj): self.directivetype = 'classmethod' # document class and static members before ordinary ones self.member_order = self.member_order - 1 elif isstaticmethod(obj, cls=parent_cls, name=self.object_name): self.directivetype = 'staticmethod' # document class and static members before ordinary ones self.member_order = self.member_order - 1 else: self.directivetype = 'method' return ret
def import_object(self): ret = ClassLevelDocumenter.import_object(self) if self.object.static: self.directivetype = 'staticmethod' self.member_order = self.member_order - 1 else: self.directivetype = 'method' return ret
def import_object(self): # type: () -> Any ret = ClassLevelDocumenter.import_object(self) if not ret: return ret # Change the object to the fget method. Ignore everything else. self.object = self.object.fget # to distinguish classmethod/staticmethod obj = self.parent.__dict__.get(self.object_name) if obj is None: obj = self.object self.directivetype = 'attribute' # Treat the property like an attribute in terms of formatting. The object is otherwise treated as a method. return ret
def import_object(self): # MethodDocumenter overrides import_object to do some sniffing in # addition to just importing. But we do our own sniffing and just want # the import, so we un-override it. ret = ClassLevelDocumenter.import_object(self) # Use 'inspect.getattr_static' to properly detect class or static methods. # This also resolves the MRO entries for subclasses. obj = inspect.getattr_static(self.parent, self.object_name) # autodoc likes to re-use dicts here for some reason (!?!) self.options = Options(self.options) update_with_sniffed_options(obj, self.options) # Replicate the special ordering hacks in # MethodDocumenter.import_object if "classmethod" in self.options or "staticmethod" in self.options: self.member_order -= 1 return ret
def import_object(self): # MethodDocumenter overrides import_object to do some sniffing in # addition to just importing. But we do our own sniffing and just want # the import, so we un-override it. ret = ClassLevelDocumenter.import_object(self) # If you have a classmethod or staticmethod, then # # Class.__dict__["name"] # # returns the classmethod/staticmethod object, but # # getattr(Class, "name") # # returns a regular function. We want to detect # classmethod/staticmethod, so we need to go through __dict__. obj = self.parent.__dict__.get(self.object_name) update_with_sniffed_options(obj, self.options) # Replicate the special ordering hacks in # MethodDocumenter.import_object if "classmethod" in self.options or "staticmethod" in self.options: self.member_order -= 1 return ret