Show More
@@ -73,8 +73,7 b' from IPython.utils.py3compat import (builtin_mod, unicode_type, string_types,' | |||||
73 | with_metaclass, iteritems) |
|
73 | with_metaclass, iteritems) | |
74 | from IPython.utils.strdispatch import StrDispatch |
|
74 | from IPython.utils.strdispatch import StrDispatch | |
75 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
75 | from IPython.utils.syspathcontext import prepended_to_syspath | |
76 |
from IPython.utils.text import |
|
76 | from IPython.utils.text import format_screen, LSString, SList, DollarFormatter | |
77 | DollarFormatter) |
|
|||
78 | from IPython.utils.tempdir import TemporaryDirectory |
|
77 | from IPython.utils.tempdir import TemporaryDirectory | |
79 | from traitlets import ( |
|
78 | from traitlets import ( | |
80 | Integer, Bool, CaselessStrEnum, Enum, List, Dict, Unicode, Instance, Type, |
|
79 | Integer, Bool, CaselessStrEnum, Enum, List, Dict, Unicode, Instance, Type, | |
@@ -87,14 +86,14 b' import IPython.core.hooks' | |||||
87 | try: |
|
86 | try: | |
88 | import docrepr.sphinxify as sphx |
|
87 | import docrepr.sphinxify as sphx | |
89 |
|
88 | |||
90 |
def |
|
89 | def sphinxify(doc): | |
91 | with TemporaryDirectory() as dirname: |
|
90 | with TemporaryDirectory() as dirname: | |
92 | return { |
|
91 | return { | |
93 | 'text/html': sphx.sphinxify(doc, dirname), |
|
92 | 'text/html': sphx.sphinxify(doc, dirname), | |
94 | 'text/plain': doc |
|
93 | 'text/plain': doc | |
95 | } |
|
94 | } | |
96 | except ImportError: |
|
95 | except ImportError: | |
97 |
|
|
96 | sphinxify = None | |
98 |
|
97 | |||
99 | #----------------------------------------------------------------------------- |
|
98 | #----------------------------------------------------------------------------- | |
100 | # Globals |
|
99 | # Globals | |
@@ -278,6 +277,16 b' class InteractiveShell(SingletonConfigurable):' | |||||
278 | display_formatter = Instance(DisplayFormatter, allow_none=True) |
|
277 | display_formatter = Instance(DisplayFormatter, allow_none=True) | |
279 | displayhook_class = Type(DisplayHook) |
|
278 | displayhook_class = Type(DisplayHook) | |
280 | display_pub_class = Type(DisplayPublisher) |
|
279 | display_pub_class = Type(DisplayPublisher) | |
|
280 | sphinxify_docstring = Bool(False, help= | |||
|
281 | """ | |||
|
282 | Enables rich html representation of docstrings. (This requires the | |||
|
283 | docrepr module). | |||
|
284 | """).tag(config=True) | |||
|
285 | enable_html_pager = Bool(False, help= | |||
|
286 | """ | |||
|
287 | (Provisional API) enables html representation in mime bundles sent | |||
|
288 | to pagers. | |||
|
289 | """).tag(config=True) | |||
281 | data_pub_class = None |
|
290 | data_pub_class = None | |
282 |
|
291 | |||
283 | exit_now = Bool(False) |
|
292 | exit_now = Bool(False) | |
@@ -294,12 +303,12 b' class InteractiveShell(SingletonConfigurable):' | |||||
294 | # is ready to be executed. |
|
303 | # is ready to be executed. | |
295 | input_splitter = Instance('IPython.core.inputsplitter.IPythonInputSplitter', |
|
304 | input_splitter = Instance('IPython.core.inputsplitter.IPythonInputSplitter', | |
296 | (), {'line_input_checker': True}) |
|
305 | (), {'line_input_checker': True}) | |
297 |
|
306 | |||
298 | # This InputSplitter instance is used to transform completed cells before |
|
307 | # This InputSplitter instance is used to transform completed cells before | |
299 | # running them. It allows cell magics to contain blank lines. |
|
308 | # running them. It allows cell magics to contain blank lines. | |
300 | input_transformer_manager = Instance('IPython.core.inputsplitter.IPythonInputSplitter', |
|
309 | input_transformer_manager = Instance('IPython.core.inputsplitter.IPythonInputSplitter', | |
301 | (), {'line_input_checker': False}) |
|
310 | (), {'line_input_checker': False}) | |
302 |
|
311 | |||
303 | logstart = Bool(False, help= |
|
312 | logstart = Bool(False, help= | |
304 | """ |
|
313 | """ | |
305 | Start logging to the default log file in overwrite mode. |
|
314 | Start logging to the default log file in overwrite mode. | |
@@ -354,11 +363,11 b' class InteractiveShell(SingletonConfigurable):' | |||||
354 | name=name) |
|
363 | name=name) | |
355 | ) |
|
364 | ) | |
356 | # protect against weird cases where self.config may not exist: |
|
365 | # protect against weird cases where self.config may not exist: | |
357 |
|
366 | |||
358 | show_rewritten_input = Bool(True, |
|
367 | show_rewritten_input = Bool(True, | |
359 | help="Show rewritten input, e.g. for autocall." |
|
368 | help="Show rewritten input, e.g. for autocall." | |
360 | ).tag(config=True) |
|
369 | ).tag(config=True) | |
361 |
|
370 | |||
362 | quiet = Bool(False).tag(config=True) |
|
371 | quiet = Bool(False).tag(config=True) | |
363 |
|
372 | |||
364 | history_length = Integer(10000, |
|
373 | history_length = Integer(10000, | |
@@ -1371,7 +1380,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1371 | user_ns_hidden.pop(name, None) |
|
1380 | user_ns_hidden.pop(name, None) | |
1372 | else: |
|
1381 | else: | |
1373 | user_ns_hidden.update(vdict) |
|
1382 | user_ns_hidden.update(vdict) | |
1374 |
|
1383 | |||
1375 | def drop_by_id(self, variables): |
|
1384 | def drop_by_id(self, variables): | |
1376 | """Remove a dict of variables from the user namespace, if they are the |
|
1385 | """Remove a dict of variables from the user namespace, if they are the | |
1377 | same as the values in the dictionary. |
|
1386 | same as the values in the dictionary. | |
@@ -1537,15 +1546,20 b' class InteractiveShell(SingletonConfigurable):' | |||||
1537 | def _inspect(self, meth, oname, namespaces=None, **kw): |
|
1546 | def _inspect(self, meth, oname, namespaces=None, **kw): | |
1538 | """Generic interface to the inspector system. |
|
1547 | """Generic interface to the inspector system. | |
1539 |
|
1548 | |||
1540 |
This function is meant to be called by pdef, pdoc & friends. |
|
1549 | This function is meant to be called by pdef, pdoc & friends. | |
|
1550 | """ | |||
1541 | info = self._object_find(oname, namespaces) |
|
1551 | info = self._object_find(oname, namespaces) | |
|
1552 | docformat = sphinxify if self.sphinxify_docstring else None | |||
1542 | if info.found: |
|
1553 | if info.found: | |
1543 | pmethod = getattr(self.inspector, meth) |
|
1554 | pmethod = getattr(self.inspector, meth) | |
|
1555 | # TODO: only apply format_screen to the plain/text repr of the mime | |||
|
1556 | # bundle. | |||
1544 | formatter = format_screen if info.ismagic else docformat |
|
1557 | formatter = format_screen if info.ismagic else docformat | |
1545 | if meth == 'pdoc': |
|
1558 | if meth == 'pdoc': | |
1546 | pmethod(info.obj, oname, formatter) |
|
1559 | pmethod(info.obj, oname, formatter) | |
1547 | elif meth == 'pinfo': |
|
1560 | elif meth == 'pinfo': | |
1548 |
pmethod(info.obj, oname, formatter, info, |
|
1561 | pmethod(info.obj, oname, formatter, info, | |
|
1562 | enable_html_pager=self.enable_html_pager, **kw) | |||
1549 | else: |
|
1563 | else: | |
1550 | pmethod(info.obj, oname) |
|
1564 | pmethod(info.obj, oname) | |
1551 | else: |
|
1565 | else: |
@@ -672,7 +672,7 b' class Inspector(Colorable):' | |||||
672 |
|
672 | |||
673 | return mime |
|
673 | return mime | |
674 |
|
674 | |||
675 | def pinfo(self, obj, oname='', formatter=None, info=None, detail_level=0): |
|
675 | def pinfo(self, obj, oname='', formatter=None, info=None, detail_level=0, enable_html_pager=True): | |
676 | """Show detailed information about an object. |
|
676 | """Show detailed information about an object. | |
677 |
|
677 | |||
678 | Optional arguments: |
|
678 | Optional arguments: | |
@@ -695,8 +695,9 b' class Inspector(Colorable):' | |||||
695 | - detail_level: if set to 1, more information is given. |
|
695 | - detail_level: if set to 1, more information is given. | |
696 | """ |
|
696 | """ | |
697 | info = self._get_info(obj, oname, formatter, info, detail_level) |
|
697 | info = self._get_info(obj, oname, formatter, info, detail_level) | |
698 | if info: |
|
698 | if not enable_html_pager: | |
699 | page.page(info) |
|
699 | del info['text/html'] | |
|
700 | page.page(info) | |||
700 |
|
701 | |||
701 | def info(self, obj, oname='', formatter=None, info=None, detail_level=0): |
|
702 | def info(self, obj, oname='', formatter=None, info=None, detail_level=0): | |
702 | """DEPRECATED. Compute a dict with detailed information about an object. |
|
703 | """DEPRECATED. Compute a dict with detailed information about an object. |
General Comments 0
You need to be logged in to leave comments.
Login now