This notebook is part of the nbsphinx
documentation: https://nbsphinx.readthedocs.io/.
Automatically executing notebooks during the Sphinx build process is an important feature of nbsphinx
.
However, there are a few use cases where pre-executing a notebook and storing the outputs might be preferable.
Storing any output will, by default, stop nbsphinx
from executing the notebook.
In [1]:
import time
In [2]:
%time time.sleep(60 * 60)
6 * 7
Out[2]:
In [3]:
from a_very_rare_library import calculate_the_answer
In [4]:
calculate_the_answer()
Out[4]:
If an exception is raised during the Sphinx build process, it is stopped (the build process, not the exception!). If you want to show to your audience how an exception looks like, you have two choices:
Allow errors -- either generally or on a per-notebook or per-cell basis -- see Ignoring Errors (per cell).
Execute the notebook beforehand and save the results, like it's done in this example notebook:
In [5]:
1 / 0
When nbsphinx
executes notebooks,
it uses the nbconvert
module to do so.
Certain Jupyter clients might produce output
that differs from what nbconvert
would produce.
To preserve those original outputs,
the notebook has to be executed and saved
before running Sphinx.
For example,
the JupyterLab help system shows the help text as cell outputs,
while executing with nbconvert
doesn't produce any output.
In [6]:
sorted?