MCPcopy Create free account
hub / github.com/ipython/ipython / getdoc

Function getdoc

IPython/core/oinspect.py:114–132  ·  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

112 return encoding
113
114def getdoc(obj) -> Union[str,None]:
115 """Stable wrapper around inspect.getdoc.
116
117 This can't crash because of attribute problems.
118
119 It also attempts to call a getdoc() method on the given object. This
120 allows objects which provide their docstrings via non-standard mechanisms
121 (like Pyro proxies) to still be inspected by ipython's ? system.
122 """
123 # Allow objects to offer customized documentation via a getdoc method:
124 try:
125 ds = obj.getdoc()
126 except Exception:
127 pass
128 else:
129 if isinstance(ds, str):
130 return inspect.cleandoc(ds)
131 docstr = inspect.getdoc(obj)
132 return docstr
133
134
135def 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