Skip to content

Commit 502b88c

Browse files
committed
docs(build): turn off interactive mode before every example
1 parent 2f9ec90 commit 502b88c

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

docs/_renderer.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
from textwrap import dedent
4+
35
import quartodoc as qd
46
import toolz
57
from plum import dispatch
@@ -26,6 +28,8 @@ def render(self, el: qd.ast.ExampleCode) -> str:
2628
lambda line: quartodoc_skip_doctest in line or skip_doctest in line
2729
)
2830

31+
has_executed_chunks = False
32+
2933
for chunk in toolz.partitionby(chunker, lines):
3034
first, *rest = chunk
3135

@@ -35,10 +39,11 @@ def render(self, el: qd.ast.ExampleCode) -> str:
3539
# check whether to skip execution and if so, render the code
3640
# block as `python` (not `{python}`) if it's marked with
3741
# skip_doctest, expect_failure or quartodoc_skip_doctest
38-
if not any(map(should_skip, chunk)):
39-
start, end = "{}"
40-
else:
42+
if any(map(should_skip, chunk)):
4143
start = end = ""
44+
else:
45+
has_executed_chunks = True
46+
start, end = "{}"
4247

4348
result.append(f"```{start}python{end}")
4449

@@ -62,4 +67,22 @@ def render(self, el: qd.ast.ExampleCode) -> str:
6267
result.extend(rest)
6368
result.append("```\n")
6469

65-
return "\n".join(result)
70+
examples = "\n".join(result)
71+
72+
if has_executed_chunks:
73+
# turn off interactive mode before rendering
74+
return (
75+
dedent(
76+
"""
77+
```{python}
78+
#| echo: false
79+
80+
import ibis
81+
ibis.options.interactive = False
82+
```
83+
"""
84+
)
85+
+ examples
86+
)
87+
else:
88+
return examples

0 commit comments

Comments
 (0)