pdoc/doc.py
def members(self) -> dict[str, Doc]:
        """A mapping from all members to their documentation objects."""
        members: dict[str, Doc] = {}
        for name, obj in self._member_objects.items():
            qualname = f"{self.qualname}.{name}".lstrip(".")
            taken_from = self._taken_from(name, obj)
            doc: Doc[Any]

            is_classmethod = isinstance(obj, classmethod)
            is_property = (
                isinstance(obj, (property, cached_property))
                or
                # Python 3.9: @classmethod @property is now allowed.
                is_classmethod
                and isinstance(obj.__func__, (property, cached_property))
            )
            if is_property:
                func = obj
                if is_classmethod:
                    func = obj.__func__
                if isinstance(func, property):
                    func = func.fget
                else:
                    assert isinstance(func, cached_property)
                    func = func.func

                doc_f = Function(self.modulename, qualname, func, taken_from)
                doc = Variable(
                    self.modulename,
                    qualname,
                    docstring=doc_f.docstring,
                    annotation=doc_f.signature.return_annotation,
                    default_value=empty,
                    taken_from=taken_from,
                )
            elif inspect.isroutine(obj):
                doc = Function(self.modulename, qualname, obj, taken_from)
            elif inspect.isclass(obj) and obj is not empty:
                doc = Class(self.modulename, qualname, obj, taken_from)
            elif inspect.ismodule(obj):
                doc = Module(obj)
                doc.modulename = self.modulename
                doc.qualname = qualname
            else:
                docstring = self._var_docstrings.get(name, "")
                if not docstring and inspect.isdatadescriptor(obj):
                    docstring = getattr(obj, "__doc__", None) or ""
                doc = Variable(
                    self.modulename,
                    qualname,
                    docstring=docstring,
                    annotation=self._var_annotations.get(name, empty),
                    default_value=obj,
                    taken_from=taken_from,
                )
            members[doc.name] = doc
        return members
A mapping from all members to their documentation objects.
A mapping from all members to their documentation objects.
A mapping from all members to their documentation objects .
def members(self) -> dict[str, Doc]:
        members: dict[str, Doc] = {}
        for name, obj in self._member_objects.items():
            qualname = f"{self.qualname}.{name}".lstrip(".")
            taken_from = self._taken_from(name, obj)
            doc: Doc[Any]
            is_classmethod = isinstance(obj, classmethod)
            is_property = (
                isinstance(obj, (property, cached_property))
                or
                is_classmethod
                and isinstance(obj.__func__, (property, cached_property))
            )
            if is_property:
                func = obj
                if is_classmethod:
                    func = obj.__func__
                if isinstance(func, property):
                    func = func.fget
                else:
                    assert isinstance(func, cached_property)
                    func = func.func
                doc_f = Function(self.modulename, qualname, func, taken_from)
                doc = Variable(
                    self.modulename,
                    qualname,
                    docstring=doc_f.docstring,
                    annotation=doc_f.signature.return_annotation,
                    default_value=empty,
                    taken_from=taken_from,
                )
            elif inspect.isroutine(obj):
                doc = Function(self.modulename, qualname, obj, taken_from)
            elif inspect.isclass(obj) and obj is not empty:
                doc = Class(self.modulename, qualname, obj, taken_from)
            elif inspect.ismodule(obj):
                doc = Module(obj)
                doc.modulename = self.modulename
                doc.qualname = qualname
            else:
                docstring = self._var_docstrings.get(name, "")
                if not docstring and inspect.isdatadescriptor(obj):
                    docstring = getattr(obj, "__doc__", None) or ""
                doc = Variable(
                    self.modulename,
                    qualname,
                    docstring=docstring,
                    annotation=self._var_annotations.get(name, empty),
                    default_value=obj,
                    taken_from=taken_from,
                )
            members[doc.name] = doc
        return members
def members ( self ) -> dict [ str , Doc ] : members : dict [ str , Doc ] = { } for name , obj in self . _member_objects . items ( ) : qualname = f"{self.qualname}.{name}" . lstrip ( "." ) taken_from = self . _taken_from ( name , obj ) doc : Doc [ Any ] is_classmethod = isinstance ( obj , classmethod ) is_property = ( isinstance ( obj , ( property , cached_property ) ) or is_classmethod and isinstance ( obj . __func__ , ( property , cached_property ) ) ) if is_property : func = obj if is_classmethod : func = obj . __func__ if isinstance ( func , property ) : func = func . fget else : assert isinstance ( func , cached_property ) func = func . func doc_f = Function ( self . modulename , qualname , func , taken_from ) doc = Variable ( self . modulename , qualname , docstring = doc_f . docstring , annotation = doc_f . signature . return_annotation , default_value = empty , taken_from = taken_from , ) elif inspect . isroutine ( obj ) : doc = Function ( self . modulename , qualname , obj , taken_from ) elif inspect . isclass ( obj ) and obj is not empty : doc = Class ( self . modulename , qualname , obj , taken_from ) elif inspect . ismodule ( obj ) : doc = Module ( obj ) doc . modulename = self . modulename doc . qualname = qualname else : docstring = self . _var_docstrings . get ( name , "" ) if not docstring and inspect . isdatadescriptor ( obj ) : docstring = getattr ( obj , "__doc__" , None ) or "" doc = Variable ( self . modulename , qualname , docstring = docstring , annotation = self . _var_annotations . get ( name , empty ) , default_value = obj , taken_from = taken_from , ) members [ doc . name ] = doc return members
A mapping from all members to their documentation objects.
A mapping from all members to their documentation objects .
"""A mapping from all members to their documentation objects.""" # Python 3.9: @classmethod @property is now allowed.
self