|
13 | 13 | # import os
|
14 | 14 | # import sys
|
15 | 15 | # sys.path.insert(0, os.path.abspath('.'))
|
| 16 | +from pathlib import Path |
| 17 | +from sphinx.application import Sphinx |
| 18 | +import subprocess |
| 19 | +import os |
| 20 | +import json |
16 | 21 |
|
| 22 | +RTD = json.loads(os.environ.get("READTHEDOCS", "False").lower()) |
17 | 23 |
|
18 | 24 | # -- Project information -----------------------------------------------------
|
19 | 25 |
|
|
30 | 36 | # Add any Sphinx extension module names here, as strings. They can be
|
31 | 37 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
32 | 38 | # ones.
|
33 |
| -extensions = ['myst_parser'] |
| 39 | +extensions = ['myst_parser',] |
| 40 | + |
| 41 | +here = Path(__file__).parent.resolve() |
| 42 | +jupyterlite_config = here / "jupyterlite_config.json" |
| 43 | + |
| 44 | +html_theme_options = dict( |
| 45 | + github_url='https://github.com/InsightSoftwareConsortium/itkwidgets' |
| 46 | +) |
| 47 | + |
| 48 | +# jupyterlite_config = jupyterlite_dir / "jupyterlite_config.json" |
34 | 49 |
|
35 | 50 | # Add any paths that contain templates here, relative to this directory.
|
36 | 51 | templates_path = ['_templates']
|
|
51 | 66 | # Add any paths that contain custom static files (such as style sheets) here,
|
52 | 67 | # relative to this directory. They are copied after the builtin static files,
|
53 | 68 | # so a file named "default.css" will overwrite the builtin "default.css".
|
54 |
| -html_static_path = ['_static'] |
| 69 | +html_static_path = ['_static', |
| 70 | + '_output'] |
| 71 | + |
| 72 | +def jupyterlite_build(app: Sphinx, error): |
| 73 | + subprocess.check_call(['jupyter', 'lite', 'build', '--config', |
| 74 | + str(jupyterlite_config)], cwd=str(here)) |
| 75 | + |
| 76 | +def setup(app): |
| 77 | + # For local builds, run jupyter lite build manually |
| 78 | + # $ jupyter lite serve --config ./jupyterlite_config.json |
| 79 | + if RTD: |
| 80 | + app.connect("config-inited", jupyterlite_build) |
0 commit comments