Skip to content

Commit 7e13cc6

Browse files
committed
add section to documentation detailing stderr handling
1 parent d7ea4da commit 7e13cc6

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

doc/source/index.rst

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ much richer output than mere text; plots, for example:
5656
from matplotlib import pyplot
5757
%matplotlib inline
5858

59-
x = np.linspace(0, 2 * np.pi)
59+
x = np.linspace(1E-3, 2 * np.pi)
6060

6161
pyplot.plot(x, np.sin(x) / x)
6262
pyplot.plot(x, np.cos(x))
@@ -155,16 +155,40 @@ a list of error types; if an error is raised that is not in the list then execut
155155
:raises: KeyError, ValueError
156156

157157
a = {'hello': 'world!'}
158-
a['jello']
158+
a['hello']
159159

160160
produces:
161161

162162
.. jupyter-execute::
163163
:raises: KeyError, ValueError
164164

165165
a = {'hello': 'world!'}
166-
a['jello']
166+
a['hello']
167167

168+
Additionally, any output sent to the ``stderr`` stream of a cell will result in jupyter-sphinx
169+
raising an exception. This behaviour can be suppressed (and the ``stderr`` stream printed as regular
170+
output) by providing the ``stderr`` option::
171+
172+
.. jupyter-execute::
173+
:stderr:
174+
175+
import sys
176+
177+
print("hello, world!", file=sys.stderr)
178+
179+
produces:
180+
181+
.. jupyter-execute::
182+
:stderr:
183+
184+
import sys
185+
186+
print("hello, world!", file=sys.stderr)
187+
188+
.. warning::
189+
190+
Note that output written to ``stderr`` is not displayed any differently than output written
191+
to ``stdout``.
168192

169193
Controlling the execution environment
170194
-------------------------------------

0 commit comments

Comments
 (0)