MCPcopy Index your code
hub / github.com/RustPython/RustPython / _finddoc

Function _finddoc

Lib/pydoc.py:121–169  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

119 return cls
120
121def _finddoc(obj):
122 if inspect.ismethod(obj):
123 name = obj.__func__.__name__
124 self = obj.__self__
125 if (inspect.isclass(self) and
126 getattr(getattr(self, name, None), '__func__') is obj.__func__):
127 # classmethod
128 cls = self
129 else:
130 cls = self.__class__
131 elif inspect.isfunction(obj):
132 name = obj.__name__
133 cls = _findclass(obj)
134 if cls is None or getattr(cls, name) is not obj:
135 return None
136 elif inspect.isbuiltin(obj):
137 name = obj.__name__
138 self = obj.__self__
139 if (inspect.isclass(self) and
140 self.__qualname__ + '.' + name == obj.__qualname__):
141 # classmethod
142 cls = self
143 else:
144 cls = self.__class__
145 # Should be tested before isdatadescriptor().
146 elif isinstance(obj, property):
147 name = obj.__name__
148 cls = _findclass(obj.fget)
149 if cls is None or getattr(cls, name) is not obj:
150 return None
151 elif inspect.ismethoddescriptor(obj) or inspect.isdatadescriptor(obj):
152 name = obj.__name__
153 cls = obj.__objclass__
154 if getattr(cls, name) is not obj:
155 return None
156 if inspect.ismemberdescriptor(obj):
157 slots = getattr(cls, '__slots__', None)
158 if isinstance(slots, dict) and name in slots:
159 return slots[name]
160 else:
161 return None
162 for base in cls.__mro__:
163 try:
164 doc = _getowndoc(getattr(base, name))
165 except AttributeError:
166 continue
167 if doc is not None:
168 return doc
169 return None
170
171def _getowndoc(obj):
172 """Get the documentation string for an object if it is not

Callers 1

_getdocFunction · 0.70

Calls 5

getattrFunction · 0.85
isinstanceFunction · 0.85
_getowndocFunction · 0.85
ismethodMethod · 0.80
_findclassFunction · 0.70

Tested by

no test coverage detected