Important
This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.
If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).
IPython Sphinx extension¶
Sphinx directive to support embedded IPython code.
IPython provides an extension for Sphinx to highlight and run code.
This directive allows pasting of entire interactive IPython sessions, prompts and all, and their code will actually get re-executed at doc build time, with all prompts renumbered sequentially. It also allows you to input code as a pure python input by giving the argument python to the directive. The output looks like an interactive ipython section.
Here is an example of how the IPython directive can run python code, at build time.
In [1]: 1+1
Out[1]: 2
In [2]: import datetime
...: datetime.datetime.now()
...: