|
1 | 1 | import os |
2 | 2 | import shutil |
3 | 3 | import tempfile |
| 4 | +from warnings import warn |
4 | 5 |
|
5 | 6 | from pathlib import Path |
6 | 7 |
|
|
10 | 11 |
|
11 | 12 | from docutils.parsers.rst import directives |
12 | 13 | from docutils.nodes import SkipNode, Element |
13 | | -from docutils.parsers import rst |
14 | 14 |
|
15 | 15 | from sphinx.application import Sphinx |
16 | 16 | from sphinx.util.docutils import SphinxDirective |
@@ -266,19 +266,33 @@ def jupyterlite_build(app: Sphinx, error): |
266 | 266 | if app.builder.format == "html": |
267 | 267 | print("[jupyterlite-sphinx] Running JupyterLite build") |
268 | 268 |
|
269 | | - config = [] |
| 269 | + jupyter_lite_config = app.env.config.jupyter_lite_config |
| 270 | + jupyter_lite_contents = app.env.config.jupyter_lite_contents |
| 271 | + jupyter_lite_dir = app.env.config.jupyter_lite_dir |
| 272 | + |
270 | 273 | if app.env.config.jupyterlite_config: |
271 | | - config = ["--config", app.env.config.jupyterlite_config] |
| 274 | + warn( |
| 275 | + "jupyterlite_config config option is deprecated, please use jupyter_lite_config instead" |
| 276 | + ) |
| 277 | + jupyter_lite_config = app.env.config.jupyterlite_config |
272 | 278 |
|
273 | | - contents = [] |
274 | | - if app.env.config.jupyterlite_contents: |
275 | | - jupyterlite_contents = app.env.config.jupyterlite_contents |
| 279 | + if app.env.config.jupyterlite_dir: |
| 280 | + warn( |
| 281 | + "jupyterlite_dir config option is deprecated, please use jupyter_lite_dir instead" |
| 282 | + ) |
| 283 | + jupyter_lite_dir = app.env.config.jupyterlite_dir |
276 | 284 |
|
277 | | - if isinstance(jupyterlite_contents, str): |
278 | | - contents.extend(["--contents", jupyterlite_contents]) |
| 285 | + config = [] |
| 286 | + if jupyter_lite_config: |
| 287 | + config = ["--config", jupyter_lite_config] |
279 | 288 |
|
280 | | - if isinstance(jupyterlite_contents, (tuple, list)): |
281 | | - for content in jupyterlite_contents: |
| 289 | + contents = [] |
| 290 | + if jupyter_lite_contents: |
| 291 | + if isinstance(jupyter_lite_contents, str): |
| 292 | + contents.extend(["--contents", jupyter_lite_contents]) |
| 293 | + |
| 294 | + if isinstance(jupyter_lite_contents, (tuple, list)): |
| 295 | + for content in jupyter_lite_contents: |
282 | 296 | contents.extend(["--contents", content]) |
283 | 297 |
|
284 | 298 | command = [ |
@@ -306,8 +320,8 @@ def jupyterlite_build(app: Sphinx, error): |
306 | 320 | os.path.join(app.outdir, JUPYTERLITE_DIR), |
307 | 321 | ] |
308 | 322 |
|
309 | | - if app.env.config.jupyterlite_dir: |
310 | | - command.extend(["--lite-dir", app.env.config.jupyterlite_dir]) |
| 323 | + if jupyter_lite_dir: |
| 324 | + command.extend(["--lite-dir", jupyter_lite_dir]) |
311 | 325 |
|
312 | 326 | subprocess.run(command, check=True) |
313 | 327 | else: |
@@ -336,8 +350,10 @@ def setup(app): |
336 | 350 |
|
337 | 351 | # Config options |
338 | 352 | app.add_config_value("jupyterlite_config", None, rebuild="html") |
| 353 | + app.add_config_value("jupyter_lite_config", None, rebuild="html") |
339 | 354 | app.add_config_value("jupyterlite_dir", None, rebuild="html") |
340 | | - app.add_config_value("jupyterlite_contents", None, rebuild="html") |
| 355 | + app.add_config_value("jupyter_lite_dir", None, rebuild="html") |
| 356 | + app.add_config_value("jupyter_lite_contents", None, rebuild="html") |
341 | 357 |
|
342 | 358 | # Initialize RetroLite and JupyterLite directives |
343 | 359 | app.add_node( |
|
0 commit comments