##// 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 # IPython's own
29 # IPython's own
30 from IPython.core import page
30 from IPython.core import page
31 from IPython.external.Itpl import itpl
32 from IPython.utils import PyColorize
31 from IPython.utils import PyColorize
33 from IPython.utils import io
32 from IPython.utils import io
34 from IPython.utils.text import indent
33 from IPython.utils.text import indent
@@ -298,22 +297,24 b' class Inspector:'
298 -formatter: a function to run the docstring through for specially
297 -formatter: a function to run the docstring through for specially
299 formatted docstrings."""
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 ds = getdoc(obj)
301 ds = getdoc(obj)
303 if formatter:
302 if formatter:
304 ds = formatter(ds)
303 ds = formatter(ds)
305 if inspect.isclass(obj):
304 if inspect.isclass(obj):
306 init_ds = getdoc(obj.__init__)
305 init_ds = getdoc(obj.__init__)
307 output = itpl('$head("Class Docstring:")\n'
306 output = "\n".join([head("Class Docstring:"),
308 '$indent(ds)\n'
307 indent(ds),
309 '$head("Constructor Docstring"):\n'
308 head("Constructor Docstring:"),
310 '$indent(init_ds)')
309 indent(init_ds)])
311 elif (type(obj) is types.InstanceType or isinstance(obj,object)) \
310 elif (type(obj) is types.InstanceType or isinstance(obj,object)) \
312 and hasattr(obj,'__call__'):
311 and hasattr(obj,'__call__'):
313 call_ds = getdoc(obj.__call__)
312 call_ds = getdoc(obj.__call__)
314 if call_ds:
313 if call_ds:
315 output = itpl('$head("Class Docstring:")\n$indent(ds)\n'
314 output = "\n".join([head("Class Docstring:"),
316 '$head("Calling Docstring:")\n$indent(call_ds)')
315 indent(ds),
316 head("Calling Docstring:"),
317 indent(call_ds)])
317 else:
318 else:
318 output = ds
319 output = ds
319 else:
320 else:
General Comments 0
You need to be logged in to leave comments. Login now