Skip to content

Commit cb5cb8d

Browse files
authored
Default lite directory to the docs directory (#99)
1 parent 7256ae9 commit cb5cb8d

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

docs/configuration.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ jupyterlite_contents = ["./path/to/my/notebooks/", "my_other_notebook.ipynb"]
1414

1515
## JupyterLite dir
1616

17-
By default, jupyterlite-sphinx runs the `jupyter lite build` command in a temporary directory, you can overwrite this behavior and ask jupyterlite to build in a given directory:
17+
By default, jupyterlite-sphinx runs the `jupyter lite build` command in the docs directory, you can overwrite this behavior and ask jupyterlite to build in a given directory:
1818

1919
```python
2020
# Build in the current directory
21-
jupyterlite_dir = "."
21+
jupyterlite_dir = "/path/to/your/lite/dir"
2222
```
2323

24-
This allows for jupyterlite to automatically pick-up some paths <https://jupyterlite.readthedocs.io/en/latest/reference/cli.html#the-lite-dir>
25-
2624
## JupyterLite config
2725

2826
You can provide [custom configuration](https://jupyterlite.readthedocs.io/en/latest/howto/index.html#configuring-a-jupyterlite-deployment)

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,11 @@ def jupyterlite_build(app: Sphinx, error):
328328
os.path.join(app.srcdir, CONTENT_DIR),
329329
"--output-dir",
330330
os.path.join(app.outdir, JUPYTERLITE_DIR),
331+
"--lite-dir",
332+
jupyterlite_dir,
331333
]
332334

333-
if jupyterlite_dir:
334-
command.extend(["--lite-dir", jupyterlite_dir])
335-
336-
subprocess.run(command, check=True)
337-
else:
338-
with tempfile.TemporaryDirectory() as tmp_dir:
339-
command.extend(["--lite-dir", tmp_dir])
340-
341-
subprocess.run(command, check=True)
335+
subprocess.run(command, cwd=app.srcdir, check=True)
342336

343337
print("[jupyterlite-sphinx] JupyterLite build done")
344338

@@ -360,7 +354,7 @@ def setup(app):
360354

361355
# Config options
362356
app.add_config_value("jupyterlite_config", None, rebuild="html")
363-
app.add_config_value("jupyterlite_dir", None, rebuild="html")
357+
app.add_config_value("jupyterlite_dir", app.srcdir, rebuild="html")
364358
app.add_config_value("jupyterlite_contents", None, rebuild="html")
365359
app.add_config_value("jupyterlite_bind_ipynb_suffix", True, rebuild="html")
366360

0 commit comments

Comments
 (0)