Skip to content

Commit e66f40d

Browse files
committed
document the new setting
1 parent 2d9904b commit e66f40d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/directives/try_examples.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ as the first non-empty line under
202202
the section header for an examples section will prevent a directive from being inserted,
203203
allowing for specification of examples sections which should not be made interactive.
204204

205+
A code cell containing common setup code (similar to `pytest`'s `doctest_namespace`) can be added using `try_examples_preamble`.
205206

206207
The button text, theme, and warning text can be set globally with the config variables
207208
`try_examples_global_button_text`, `try_examples_global_theme`, and `try_examples_global_warning_text` in `conf.py`;
@@ -213,6 +214,11 @@ global_enable_try_examples = True
213214
try_examples_global_button_text = "Try it in your browser!"
214215
try_examples_global_height = "200px"
215216
try_examples_global_warning_text = "Interactive examples are experimental and may not always work as expected."
217+
try_examples_preamble = """
218+
import datetime as dt
219+
220+
now = dt.datetime.now()
221+
"""
216222
```
217223

218224
There is no option to set a global specific height because the proper height

0 commit comments

Comments
 (0)