diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index aca1a54..9f1d782 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -1550,11 +1550,13 @@ class InteractiveShell(SingletonConfigurable): """ info = self._object_find(oname, namespaces) docformat = sphinxify if self.sphinxify_docstring else None + print("using docformat", docformat, self.sphinxify_docstring, sphinxify) if info.found: pmethod = getattr(self.inspector, meth) # TODO: only apply format_screen to the plain/text repr of the mime # bundle. formatter = format_screen if info.ismagic else docformat + print("usingformatter", formatter) if meth == 'pdoc': pmethod(info.obj, oname, formatter) elif meth == 'pinfo': diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index 88093af..d4c56e5 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -44,6 +44,13 @@ from IPython.utils.py3compat import cast_unicode, string_types, PY3 from IPython.utils.signatures import signature from IPython.utils.colorable import Colorable +from pygments import highlight +from pygments.lexers import PythonLexer +from pygments.formatters import HtmlFormatter + +def pylight(code): + return highlight(code, PythonLexer(), HtmlFormatter(noclasses=True)) + # builtin docstrings to ignore _func_call_docstring = types.FunctionType.__call__.__doc__ _object_init_docstring = object.__init__.__doc__ @@ -365,14 +372,6 @@ def find_source_lines(obj): return lineno -from pygments import highlight -from pygments.lexers import PythonLexer -from pygments.formatters import HtmlFormatter - -def pylight(code): - return highlight(code, PythonLexer(), HtmlFormatter(noclasses=True)) - - class Inspector(Colorable): def __init__(self, color_table=InspectColors, diff --git a/docs/source/whatsnew/version5.rst b/docs/source/whatsnew/version5.rst index fe83f27..2a6382e 100644 --- a/docs/source/whatsnew/version5.rst +++ b/docs/source/whatsnew/version5.rst @@ -41,3 +41,46 @@ IPython itself. the `PromptManager` class have been removed, and the prompt machinery simplified. See `TerminalINteractiveShell.prompts` configurable for how to setup your prompts. + + +Provisional Changes +------------------- + +Provisional changes are in experimental functionality that may, or may not make +it to future version of IPython, and which API may change without warnings. +Activating these feature and using these API is at your own risk, and may have +security implication for your system, especially if used with the Jupyter notebook, + +When running via the Jupyter notebook interfaces, or other compatible client, +you can enable rich documentation experimental functionality: + +When the ``docrepr`` package is installed setting the boolean flag +``InteractiveShell.sphinxify_docstring`` to ``True``, will process the various +object through sphinx before displaying them (see the ``docrepr`` package +documentation for more information. + +You need to also enable the IPython pager display rich HTML representation +using the ``InteractiveShell.enable_html_pager`` boolean configuration option. +As usual you can set these configuration options globally in your configuration +files, alternatively you can turn them on dynamically using the following +snippet: + +.. code-block:: python + + ip = get_ipython() + ip.sphinxify_docstring = True + ip.enable_html_pager = True + +You can test the effect of various combinations of the above configuration in +the Jupyter notebook, with things example like : + +.. code-block:: python + + import numpy as np + np.histogram? + +This is part of an effort to make Documentation in Python richer and provide in +the long term if possible dynamic examples that can contain math, images, +widgets... As stated above this is nightly experimental feature with a lot of +(fun) problem to solve. We would be happy to get your feedback and expertise on +it.