Skip to content

Commit 9265095

Browse files
Allow enabling/disabling execution of REPL code
1 parent 1b3b20b commit 9265095

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def __init__(
269269
code = "\n".join(code_lines)
270270
lite_options["code"] = code
271271

272+
if "execute" in lite_options and lite_options["execute"] == "0":
273+
lite_options["execute"] = "0"
274+
272275
app_path = self.lite_app
273276
if notebook is not None:
274277
lite_options["path"] = notebook
@@ -401,6 +404,7 @@ class RepliteDirective(SphinxDirective):
401404
"width": directives.unchanged,
402405
"height": directives.unchanged,
403406
"kernel": directives.unchanged,
407+
"execute": directives.unchanged,
404408
"toolbar": directives.unchanged,
405409
"theme": directives.unchanged,
406410
"prompt": directives.unchanged,
@@ -421,6 +425,17 @@ def run(self):
421425

422426
new_tab = self.options.pop("new_tab", False)
423427

428+
# We first check the global config, and then the per-directive
429+
# option. It defaults to true for backwards compatibility.
430+
execute = self.options.pop("execute", None)
431+
if execute is None:
432+
execute = str(self.env.config.replite_auto_execute).lower()
433+
else:
434+
execute = execute.lower()
435+
436+
if execute == "false":
437+
self.options["execute"] = "0"
438+
424439
content = self.content
425440

426441
button_text = None
@@ -1155,6 +1170,7 @@ def setup(app):
11551170
man=(skip, None),
11561171
)
11571172
app.add_directive("replite", RepliteDirective)
1173+
app.add_config_value("replite_auto_execute", True, rebuild="html")
11581174

11591175
# Initialize Voici directive and tabbed interface
11601176
app.add_node(

0 commit comments

Comments
 (0)