Skip to content

Commit 83fb377

Browse files
Add docs for :execute: and replite_auto_execute
1 parent 9265095 commit 83fb377

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

docs/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ voici_new_tab_button_text = "My custom Voici button text"
8585
You can override this text on a per-directive basis by passing the `:new_tab_button_text:` option
8686
to the directive. Note that this is compatible only if `:new_tab:` is also provided.
8787

88+
## REPL code auto-execution with the `Replite` directive
89+
90+
It is possible to control whether code snippets in REPL environments automatically executeswhen loaded.
91+
For this, you may set `replite_auto_execute = False` globally in `conf.py` with (defaults to `True` if
92+
not present), or override it on a per-directive basis with `:execute: true` or `:execute: false`.
93+
8894
## Strip particular tagged cells from IPython Notebooks
8995

9096
When using the `NotebookLite`, `JupyterLite`, or `Voici` directives with a notebook passed to them, you can

docs/directives/replite.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,44 @@ global value using an additional `:new_tab_button_text:` parameter:
110110
ax.plot(x, y)
111111
plt.show()
112112
```
113+
114+
It is also possible to disable the execution of the code in the Replite console by setting the `:execute:` option to `False`:
115+
116+
```rst
117+
.. replite::
118+
:kernel: xeus-python
119+
:new_tab: True # False works too
120+
:new_tab_button_text: Open REPL with the code execution disabled
121+
:execute: False
122+
123+
import matplotlib.pyplot as plt
124+
import numpy as np
125+
126+
x = np.linspace(0, 2 * np.pi, 200)
127+
y = np.sin(x)
128+
129+
fig, ax = plt.subplots()
130+
ax.plot(x, y)
131+
plt.show()
132+
```
133+
134+
```{eval-rst}
135+
.. replite::
136+
:kernel: xeus-python
137+
:new_tab: True # False works too
138+
:new_tab_button_text: Open REPL with the code execution disabled
139+
:execute: False
140+
141+
import matplotlib.pyplot as plt
142+
import numpy as np
143+
144+
x = np.linspace(0, 2 * np.pi, 200)
145+
y = np.sin(x)
146+
147+
fig, ax = plt.subplots()
148+
ax.plot(x, y)
149+
plt.show()
150+
```
151+
152+
The behaviour can also be [configured globally](../configuration.md#replite-auto-execution-with-the-replite-directive)
153+
and then overridden in individual directives.

0 commit comments

Comments
 (0)