Skip to content

Commit c205b2e

Browse files
authored
More work on docs demo (#46)
1 parent 49343ec commit c205b2e

File tree

21 files changed

+434
-226
lines changed

21 files changed

+434
-226
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ __pycache__/
66
*.doit.*
77
build/
88
dist/
9+
examples/files/*.md

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
### `jupyterlite-pyodide-lock 0.2.0`
1010

11-
- [#44] adds a `FixHtmlConfigAddon` for fixing config paths (like `pyodide-lock.json`)
12-
in HTML generated by other JupyterLite addons
11+
- [#44] adds a `FixHtmlAddon` for fixing config paths (like `pyodide-lock.json`) in HTML
12+
generated by other JupyterLite addons
1313
- [#44] adds support for `jupyterlite-pyodide-kernel 0.7`
1414
- [#38] adds a `--check` flag to the CLI, which fails if _no_ browsers are available
1515
- [#41] adds support for `micropip >=0.9.0` constraints when locking

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Several JupyterLite addons extend a build, and are configured in
5252
| ------------------------- | --------------------------------------------------------------------------- |
5353
| `PyodideLockAddon` | re-configure `jupyterlite-pyodide-kernel` with a custom `pyodide-lock.json` |
5454
| `PyodideLockOfflineAddon` | replace remote CDN URLs with local packages to be served with the site |
55-
| `FixHtmlConfigAddon` | fix paths in HTML generated by third-pary JupyterLite addons |
55+
| `FixHtmlAddon` | fix paths in HTML generated by third-pary JupyterLite addons |
5656

5757
### Lockers
5858

_scripts/.markdownlint.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ line-length:
77

88
# specific rules ###############################################################
99
MD033:
10-
allowed_elements: [kbd, details, summary, i, code, br, b, section, iframe, div, pre]
10+
allowed_elements:
11+
- a
12+
- b
13+
- br
14+
- button
15+
- code
16+
- details
17+
- div
18+
- form
19+
- i
20+
- iframe
21+
- input
22+
- kbd
23+
- li
24+
- pre
25+
- section
26+
- summary
27+
- ul
1128

1229
MD041: false

_scripts/vale/config/vocabularies/jlpl/accept.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ pythonhosted
9797
raw_packages
9898
README
9999
ReadTheDocs
100+
REPL
100101
REPLite
101102
repo
102103
reproducibility
103104
resolvers
105+
rewrite_missing
104106
root_posix
105107
runtimes
106108
service_class
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,37 @@
3030
/** theme customizations */
3131
.jlpl-demo {
3232
position: fixed;
33-
top: var(--jlpl-header-height);
33+
top: calc(var(--jlpl-header-height) + 3.5rem);
3434
bottom: 0;
3535
left: 0;
3636
right: 0;
3737
z-index: 1;
3838
display: flex;
3939
flex-direction: row;
4040
}
41+
42+
body:has(.jlpl-demo) #pst-secondary-sidebar {
43+
display: none;
44+
}
45+
46+
#jlpl-demo-choices {
47+
position: fixed;
48+
top: calc(var(--jlpl-header-height) + 0.5rem);
49+
display: flex;
50+
left: 10rem;
51+
margin: 0;
52+
padding: 0;
53+
}
54+
55+
#jlpl-demo-choices > li {
56+
flex: 1;
57+
margin: 0 0.5rem 0 0;
58+
padding: 0;
59+
font-weight: bold;
60+
list-style: none;
61+
white-space: nowrap;
62+
}
63+
4164
.jlpl-demo iframe {
4265
flex: 1;
4366
}

docs/_templates/layout.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% extends "pydata_sphinx_theme/layout.html" %}
2+
3+
{% block css %}
4+
<link
5+
rel="preload"
6+
href="{{ with_v(pathto, '_static/jlpl.css') }}"
7+
as="style" />
8+
{{ super() }}
9+
{% endblock %}

docs/api/jupyterlite-pyodide-lock.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
.. automodule:: jupyterlite_pyodide_lock.addons.offline
2727
```
2828

29-
### FixHtmlConfigAddon
29+
### FixHtmlAddon
3030

3131
```{eval-rst}
3232
.. currentmodule:: jupyterlite_pyodide_lock
33-
.. automodule:: jupyterlite_pyodide_lock.addons.fix_html_config
33+
.. automodule:: jupyterlite_pyodide_lock.addons.fix_html
3434
```
3535

3636
## Lockers

docs/conf.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from typing import TYPE_CHECKING, Any
1111

1212
if TYPE_CHECKING:
13+
from collections.abc import Callable
14+
1315
from sphinx.application import Sphinx
1416

1517

@@ -20,7 +22,6 @@
2022
ROOT = HERE.parent
2123
SPX_J2 = HERE / "sphinx-j2.toml"
2224

23-
2425
if not os.getenv("PIXI_PROJECT_ROOT"):
2526
# provide a fake root doc
2627
root_doc = "rtd"
@@ -36,6 +37,28 @@ def _run_pixi(*_args: Any) -> None:
3637
app.connect("build-finished", _run_pixi)
3738

3839
else:
40+
from sphinx.builders.html._assets import _file_checksum # noqa: PLC2701
41+
42+
def setup(app: Sphinx) -> None:
43+
"""Gather builder info."""
44+
45+
def update_context(
46+
app: Sphinx,
47+
pagename: str, # noqa: ARG001
48+
templatename: str, # noqa: ARG001
49+
context: dict[str, Any],
50+
doctree: Any, # noqa: ARG001
51+
) -> None:
52+
def with_v(pathto: Callable[[str, int], str], filename: str) -> str:
53+
outdir = app.builder.outdir
54+
return (
55+
f"""{pathto(filename, 1)}?"""
56+
f"""?v={_file_checksum(filename=filename, outdir=outdir)}"""
57+
)
58+
59+
context["with_v"] = with_v
60+
61+
app.connect("html-page-context", update_context)
3962

4063
def load_from_pyproject_toml() -> dict[str, Any]:
4164
"""Read templated sphinx config."""
@@ -50,7 +73,7 @@ def load_from_pyproject_toml() -> dict[str, Any]:
5073
k: tomllib.load((HERE / f"{v}").open("rb"))
5174
for k, v in spx_j2["context"].items()
5275
}
53-
config = json.loads(Template(json.dumps(spx_j2["template"])).render(**ctx))
76+
config = {**json.loads(Template(json.dumps(spx_j2["template"])).render(**ctx))}
5477
config.update(
5578
intersphinx_mapping={k: (v, None) for k, v in spx_j2["intersphinx"].items()}
5679
)

docs/configuration/core.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
"outputs": [],
314314
"source": [
315315
"if __name__ == \"__main__\":\n",
316-
" display(markdown(config_table(f\"{CORE}.addons.fix_html_config.FixHtmlConfigAddon\")))"
316+
" display(markdown(config_table(f\"{CORE}.addons.fix_html.FixHtmlAddon\")))"
317317
]
318318
},
319319
{

0 commit comments

Comments
 (0)