MCPcopy Index your code
hub / github.com/ipython/ipython / getdoc

Function getdoc

IPython/core/oinspect.py:211–229  ·  view source on GitHub ↗

Stable wrapper around inspect.getdoc. This can't crash because of attribute problems. It also attempts to call a getdoc() method on the given object. This allows objects which provide their docstrings via non-standard mechanisms (like Pyro proxies) to still be inspected by ipython

(obj)

Source from the content-addressed store, hash-verified

209
210
211def getdoc(obj) -> Union[str, None]:
212 """Stable wrapper around inspect.getdoc.
213
214 This can't crash because of attribute problems.
215
216 It also attempts to call a getdoc() method on the given object. This
217 allows objects which provide their docstrings via non-standard mechanisms
218 (like Pyro proxies) to still be inspected by ipython's ? system.
219 """
220 # Allow objects to offer customized documentation via a getdoc method:
221 try:
222 ds = obj.getdoc()
223 except Exception:
224 pass
225 else:
226 if isinstance(ds, str):
227 return inspect.cleandoc(ds)
228 docstr = inspect.getdoc(obj)
229 return docstr
230
231
232def getsource(obj, oname='') -> Union[str,None]:

Callers 2

pdocMethod · 0.85
infoMethod · 0.85

Calls 1

getdocMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…