##// END OF EJS Templates
If object has a getdoc() method, override its normal docstring....
Thomas Kluyver -
Show More
@@ -97,26 +97,22 b' def getdoc(obj):'
97 It also attempts to call a getdoc() method on the given object. This
97 It also attempts to call a getdoc() method on the given object. This
98 allows objects which provide their docstrings via non-standard mechanisms
98 allows objects which provide their docstrings via non-standard mechanisms
99 (like Pyro proxies) to still be inspected by ipython's ? system."""
99 (like Pyro proxies) to still be inspected by ipython's ? system."""
100
101 ds = None # default return value
102 try:
103 ds = inspect.getdoc(obj)
104 except:
105 # Harden against an inspect failure, which can occur with
106 # SWIG-wrapped extensions.
107 pass
108 # Allow objects to offer customized documentation via a getdoc method:
100 # Allow objects to offer customized documentation via a getdoc method:
109 try:
101 try:
110 ds2 = obj.getdoc()
102 ds = obj.getdoc()
111 except:
103 except Exception:
112 pass
104 pass
113 else:
105 else:
114 # if we get extra info, we add it to the normal docstring.
106 # if we get extra info, we add it to the normal docstring.
115 if ds is None:
107 if isinstance(ds, basestring):
116 ds = ds2
108 return ds
117 else:
109
118 ds = '%s\n%s' % (ds,ds2)
110 try:
119 return ds
111 return inspect.getdoc(obj)
112 except Exception:
113 # Harden against an inspect failure, which can occur with
114 # SWIG-wrapped extensions.
115 return None
120
116
121
117
122 def getsource(obj,is_binary=False):
118 def getsource(obj,is_binary=False):
General Comments 0
You need to be logged in to leave comments. Login now