Skip to content

Commit dfa6220

Browse files
committed
DOC: add section about IPython code blocks
1 parent a6645da commit dfa6220

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

docs/src/examples.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,27 @@ However, any test setup and teardown code is not taken into account.
211211
>>> import lib
212212
>>> lib.Knight()
213213

214+
IPython code blocks
215+
-------------------
216+
Code blocks using the language setting ``ipython3`` are supported by default.
217+
The function :func:`~sphinx_codeautolink.clean_ipython` is used to handle
218+
IPython-specific syntax like so-called `magic functions`_.
219+
220+
.. _magic functions: https://ipython.readthedocs.io/en/stable/
221+
interactive/tutorial.html#magic-functions
222+
223+
.. code-block:: ipython3
224+
225+
%reset
226+
import lib
227+
lib.Knight().taunt()
228+
229+
This is useful for integrating Jupyter notebooks, which is possible with
230+
separate Sphinx extensions like nbsphinx_ or MyST-NB_.
231+
232+
.. _nbsphinx: https://nbsphinx.readthedocs.io/
233+
.. _MyST-NB: https://myst-nb.readthedocs.io/
234+
214235
Third-party code blocks
215236
-----------------------
216237
Third-party code blocks that use the basic Pygments lexers for Python

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
],
1414
"docs": [
1515
"sphinx-rtd-theme",
16-
"matplotlib"
16+
"matplotlib",
17+
"ipython",
1718
],
1819
"tests": [
1920
"pytest>=6",

0 commit comments

Comments
 (0)