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) | |
@@ -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,7 +695,8 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 | del info['text/html'] | |||
699 |
|
|
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): |
General Comments 0
You need to be logged in to leave comments.
Login now