Skip to content
Browse files

If object has a getdoc() method, override its normal docstring.

Closes gh-89
  • Loading branch information...
1 parent e89be0c commit bbbc9d010f2641139a44d8f36160bf1072913d00 @takluyver committed Nov 30, 2011
Showing with 11 additions and 15 deletions.
  1. +11 −15 IPython/core/oinspect.py
View
26 IPython/core/oinspect.py
@@ -97,26 +97,22 @@ def getdoc(obj):
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's ? system."""
-
- ds = None # default return value
- try:
- ds = inspect.getdoc(obj)
- except:
- # Harden against an inspect failure, which can occur with
- # SWIG-wrapped extensions.
- pass
# Allow objects to offer customized documentation via a getdoc method:
try:
- ds2 = obj.getdoc()
- except:
+ ds = obj.getdoc()
+ except Exception:
pass
else:
# if we get extra info, we add it to the normal docstring.
- if ds is None:
- ds = ds2
- else:
- ds = '%s\n%s' % (ds,ds2)
- return ds
+ if isinstance(ds, basestring):
+ return ds
+
+ try:
+ return inspect.getdoc(obj)
+ except Exception:
+ # Harden against an inspect failure, which can occur with
+ # SWIG-wrapped extensions.
+ return None
def getsource(obj,is_binary=False):

0 comments on commit bbbc9d0

Please sign in to comment.
Something went wrong with that request. Please try again.