##// END OF EJS Templates
Simplify code in core/oinspect.py
Thomas Kluyver -
Show More
@@ -28,7 +28,6 b' from itertools import izip_longest'
28 28
29 29 # IPython's own
30 30 from IPython.core import page
31 from IPython.external.Itpl import itpl
32 31 from IPython.utils import PyColorize
33 32 from IPython.utils import io
34 33 from IPython.utils.text import indent
@@ -298,22 +297,24 b' class Inspector:'
298 297 -formatter: a function to run the docstring through for specially
299 298 formatted docstrings."""
300 299
301 head = self.__head # so that itpl can find it even if private
300 head = self.__head # For convenience
302 301 ds = getdoc(obj)
303 302 if formatter:
304 303 ds = formatter(ds)
305 304 if inspect.isclass(obj):
306 305 init_ds = getdoc(obj.__init__)
307 output = itpl('$head("Class Docstring:")\n'
308 '$indent(ds)\n'
309 '$head("Constructor Docstring"):\n'
310 '$indent(init_ds)')
306 output = "\n".join([head("Class Docstring:"),
307 indent(ds),
308 head("Constructor Docstring:"),
309 indent(init_ds)])
311 310 elif (type(obj) is types.InstanceType or isinstance(obj,object)) \
312 311 and hasattr(obj,'__call__'):
313 312 call_ds = getdoc(obj.__call__)
314 313 if call_ds:
315 output = itpl('$head("Class Docstring:")\n$indent(ds)\n'
316 '$head("Calling Docstring:")\n$indent(call_ds)')
314 output = "\n".join([head("Class Docstring:"),
315 indent(ds),
316 head("Calling Docstring:"),
317 indent(call_ds)])
317 318 else:
318 319 output = ds
319 320 else:
General Comments 0
You need to be logged in to leave comments. Login now