Skip to content

Commit 29b6538

Browse files
committed
BUG: Make jupyterlite run repeatable
Run in a subdirectory. jupyterlite gets confused by Sphinx _build content otherwise.
1 parent cd8debd commit 29b6538

File tree

3 files changed

+15
-33
lines changed

3 files changed

+15
-33
lines changed

docs/conf.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import os
2020
import json
2121

22-
RTD = json.loads(os.environ.get("READTHEDOCS", "False").lower())
23-
2422
# -- Project information -----------------------------------------------------
2523

2624
project = 'itkwidgets'
@@ -38,9 +36,6 @@
3836
# ones.
3937
extensions = ['myst_parser',]
4038

41-
here = Path(__file__).parent.resolve()
42-
jupyterlite_config = here / "jupyterlite_config.json"
43-
4439
html_theme_options = dict(
4540
github_url='https://github.com/InsightSoftwareConsortium/itkwidgets'
4641
)
@@ -67,21 +62,16 @@
6762
# relative to this directory. They are copied after the builtin static files,
6863
# so a file named "default.css" will overwrite the builtin "default.css".
6964
html_static_path = ['_static',
70-
'_output']
71-
72-
def jupyterlite_build(app: Sphinx):
73-
from pprint import pprint
74-
pprint('jupyterlite_build')
75-
pprint(app)
76-
pprint(app.builder)
77-
if app.builder:
78-
pprint(app.builder.format)
79-
if app.builder and app.builder.format == "html":
80-
subprocess.check_call(['jupyter', 'lite', 'build', '--config',
81-
str(jupyterlite_config)], cwd=str(here))
65+
'jupyterlite/_output']
66+
67+
def jupyterlite_build(app: Sphinx, error):
68+
here = Path(__file__).parent.resolve()
69+
jupyterlite_config = here / "jupyterlite" / "jupyterlite_config.json"
70+
subprocess.check_call(['jupyter', 'lite', 'build', '--config',
71+
str(jupyterlite_config)], cwd=str(here / 'jupyterlite'))
8272

8373
def setup(app):
84-
# For local builds, run jupyter lite build manually
74+
# For local builds, you can run jupyter lite build manually
75+
# $ cd jupyterlite
8576
# $ jupyter lite serve --config ./jupyterlite_config.json
86-
if RTD:
87-
app.connect("builder-inited", jupyterlite_build)
77+
app.connect("config-inited", jupyterlite_build)

docs/files/Hello3DWorld.ipynb renamed to docs/jupyterlite/files/Hello3DWorld.ipynb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
{
5555
"cell_type": "code",
56-
"source": "viewer = view(stent, rotate=True)\nviewer",
56+
"source": "view(stent, rotate=True)",
5757
"metadata": {
5858
"trusted": true
5959
},
@@ -63,36 +63,28 @@
6363
"output_type": "display_data",
6464
"data": {
6565
"text/plain": "<IPython.core.display.Javascript object>",
66-
"application/javascript": "window.connectPlugin && window.connectPlugin(\"cabe680b-467f-411c-9d18-4af39bd42818\")"
66+
"application/javascript": "window.connectPlugin && window.connectPlugin(\"3abf64f7-6e01-4955-8edc-f91265e8fc16\")"
6767
},
6868
"metadata": {}
6969
},
7070
{
7171
"output_type": "display_data",
7272
"data": {
7373
"text/plain": "<IPython.core.display.HTML object>",
74-
"text/html": "<div id=\"28428cf3-8ce6-4b09-bfcb-19c6345f165e\"></div>"
74+
"text/html": "<div id=\"ad0bc621-d53f-4f27-99bd-32a0548341d3\"></div>"
7575
},
7676
"metadata": {}
7777
},
7878
{
79-
"execution_count": 5,
79+
"execution_count": 6,
8080
"output_type": "execute_result",
8181
"data": {
82-
"text/plain": "<itkwidgets.viewer.Viewer at 0x24e0c60>"
82+
"text/plain": "<itkwidgets.viewer.Viewer at 0x384df88>"
8383
},
8484
"metadata": {}
8585
}
8686
],
8787
"id": "26582452"
88-
},
89-
{
90-
"cell_type": "code",
91-
"source": "",
92-
"metadata": {},
93-
"execution_count": null,
94-
"outputs": [],
95-
"id": "9ac0de0c-7693-4a72-871b-0f7a9c4b2739"
9688
}
9789
]
9890
}
File renamed without changes.

0 commit comments

Comments
 (0)