Skip to content

Commit 72393f7

Browse files
authored
Update to jupyterlite v0.2 (#113)
* Update to jupyterlite v0.2 * Install xeus-python with pip * Formatting issue * Variable shadowing * Install from conda-forge * Try fixing path
1 parent f8a77cc commit 72393f7

File tree

7 files changed

+67
-67
lines changed

7 files changed

+67
-67
lines changed

dev-environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ dependencies:
55
- pip
66
- jupyter_server
77
- jupyterlab_server
8-
- jupyterlite-core >=0.1.0,<0.2
9-
- jupyterlite-xeus-python >=0.9.0,<0.10.0
8+
- jupyterlite-xeus-python >=0.9.7,<0.10.0
9+
- jupyterlite-core >=0.2,<0.3
1010
- pydata-sphinx-theme
1111
- myst-parser
1212
- docutils

docs/directives/notebooklite.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# NotebookLite directive
2+
3+
`jupyterlite-sphinx` provides a `notebooklite` directive that allows you to embed the classic Notebook UI in your docs.
4+
5+
```rst
6+
.. notebooklite::
7+
:width: 100%
8+
:height: 600px
9+
:prompt: Try classic Notebook!
10+
```
11+
12+
```{eval-rst}
13+
.. notebooklite::
14+
:width: 100%
15+
:height: 600px
16+
:prompt: Try classic Notebook!
17+
```
18+
19+
You can also pass a Notebook file to open:
20+
21+
```rst
22+
.. notebooklite:: my_notebook.ipynb
23+
:width: 100%
24+
:height: 600px
25+
:prompt: Try classic Notebook!
26+
```
27+
28+
```{eval-rst}
29+
.. notebooklite:: my_notebook.ipynb
30+
:width: 100%
31+
:height: 600px
32+
:prompt: Try classic Notebook!
33+
```

docs/directives/retrolite.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/full.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
You can access the JupyterLite deployment that `jupyterlite-sphinx` made for you, in fullscreen, following the `./lite/lab` and `./lite/retro` relative urls:
44

55
- [JupyterLab](./lite/lab/index.html)
6-
- [Retrolab](./lite/retro/index.html)
6+
- [Notebook](./lite/tree/index.html)
77

8-
If you want to open a specific notebook in fullscreen JupyterLab/Retrolab you can use the `path` URL parameter, e.g. `./lite/lab/?path=my_noteboook.ipynb`.
8+
If you want to open a specific notebook in fullscreen JupyterLab/Notebook you can use the `path` URL parameter, e.g. `./lite/lab/?path=my_noteboook.ipynb`.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Each of those directives can be configured with the following options:
3737
:maxdepth: 2
3838
3939
directives/jupyterlite
40-
directives/retrolite
40+
directives/notebooklite
4141
directives/replite
4242
directives/voici
4343
full

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ class JupyterLiteIframe(_LiteIframe):
162162
notebooks_path = ""
163163

164164

165-
class RetroLiteIframe(_LiteIframe):
166-
"""Appended to the doctree by the RetroliteDirective directive
165+
class NotebookLiteIframe(_LiteIframe):
166+
"""Appended to the doctree by the NotebookliteDirective directive
167167
168-
Renders an iframe that shows a Notebook with RetroLite.
168+
Renders an iframe that shows a Notebook with NotebookLite.
169169
"""
170170

171-
lite_app = "retro/"
172-
notebooks_path = "notebooks/"
171+
lite_app = "tree/"
172+
notebooks_path = "../notebooks/"
173173

174174

175175
class VoiciIframe(_PromptedIframe):
@@ -287,7 +287,7 @@ def run(self):
287287

288288
notebooks_dir = Path(self.env.app.srcdir) / CONTENT_DIR / notebook_name
289289

290-
# Copy the Notebook for RetroLite to find
290+
# Copy the Notebook for NotebookLite to find
291291
os.makedirs(os.path.dirname(notebooks_dir), exist_ok=True)
292292
try:
293293
shutil.copyfile(notebook, str(notebooks_dir))
@@ -319,13 +319,13 @@ class JupyterLiteDirective(_LiteDirective):
319319
iframe_cls = JupyterLiteIframe
320320

321321

322-
class RetroLiteDirective(_LiteDirective):
323-
"""The ``.. retrolite::`` directive.
322+
class NotebookLiteDirective(_LiteDirective):
323+
"""The ``.. notebooklite::`` directive.
324324
325-
Renders a Notebook with RetroLite in the docs.
325+
Renders a Notebook with NotebookLite in the docs.
326326
"""
327327

328-
iframe_cls = RetroLiteIframe
328+
iframe_cls = NotebookLiteIframe
329329

330330

331331
class VoiciDirective(_LiteDirective):
@@ -345,10 +345,10 @@ def run(self):
345345
return super().run()
346346

347347

348-
class RetroLiteParser(RSTParser):
348+
class NotebookLiteParser(RSTParser):
349349
"""Sphinx source parser for Jupyter notebooks.
350350
351-
Shows the Notebook using retrolite."""
351+
Shows the Notebook using notebooklite."""
352352

353353
supported = ("jupyterlite_notebook",)
354354

@@ -357,7 +357,7 @@ def parse(self, inputstring, document):
357357
# Make the "absolute" filename relative to the source root
358358
filename = "/" + os.path.relpath(document.current_source, self.env.app.srcdir)
359359
super().parse(
360-
f"{title}\n{'=' * len(title)}\n.. retrolite:: {filename}",
360+
f"{title}\n{'=' * len(title)}\n.. notebooklite:: {filename}",
361361
document,
362362
)
363363

@@ -388,7 +388,7 @@ def run(self):
388388
relative_path_to_root = "/".join([".."] * depth)
389389
prefix = os.path.join(relative_path_to_root, JUPYTERLITE_DIR)
390390

391-
lite_app = "retro/"
391+
lite_app = "tree/"
392392
notebooks_path = "notebooks/"
393393

394394
content_container_node = nodes.container(
@@ -410,7 +410,7 @@ def run(self):
410410
self.env.temp_data["generated_notebooks"][
411411
directive_key
412412
] = notebook_unique_name
413-
# Copy the Notebook for RetroLite to find
413+
# Copy the Notebook for NotebookLite to find
414414
os.makedirs(notebooks_dir, exist_ok=True)
415415
with open(notebooks_dir / Path(notebook_unique_name), "w") as f:
416416
# nbf.write incorrectly formats multiline arrays in output.
@@ -547,7 +547,11 @@ def jupyterlite_build(app: Sphinx, error):
547547
for content in jupyterlite_contents:
548548
contents.extend(["--contents", content])
549549

550-
voici_option = [] if voici is None else ["--apps", "voici"]
550+
apps_option = []
551+
for liteapp in ["notebooks", "edit", "lab", "repl", "tree", "consoles"]:
552+
apps_option.extend(["--apps", liteapp])
553+
if voici is not None:
554+
apps_option.extend(["--apps", "voici"])
551555

552556
command = [
553557
"jupyter",
@@ -560,13 +564,7 @@ def jupyterlite_build(app: Sphinx, error):
560564
os.path.join(app.srcdir, CONTENT_DIR),
561565
"--output-dir",
562566
os.path.join(app.outdir, JUPYTERLITE_DIR),
563-
"--apps",
564-
"lab",
565-
"--apps",
566-
"retro",
567-
"--apps",
568-
"repl",
569-
*voici_option,
567+
*apps_option,
570568
"--lite-dir",
571569
jupyterlite_dir,
572570
]
@@ -584,8 +582,8 @@ def jupyterlite_build(app: Sphinx, error):
584582

585583

586584
def setup(app):
587-
# Initialize RetroLite parser
588-
app.add_source_parser(RetroLiteParser)
585+
# Initialize NotebookLite parser
586+
app.add_source_parser(NotebookLiteParser)
589587

590588
app.connect("config-inited", inited)
591589
# We need to build JupyterLite at the end, when all the content was created
@@ -603,16 +601,18 @@ def setup(app):
603601
app.add_config_value("try_examples_global_toolbar", default=None, rebuild=True)
604602
app.add_config_value("try_examples_global_theme", default=None, rebuild=True)
605603

606-
# Initialize RetroLite and JupyterLite directives
604+
# Initialize NotebookLite and JupyterLite directives
607605
app.add_node(
608-
RetroLiteIframe,
606+
NotebookLiteIframe,
609607
html=(visit_element_html, None),
610608
latex=(skip, None),
611609
textinfo=(skip, None),
612610
text=(skip, None),
613611
man=(skip, None),
614612
)
615-
app.add_directive("retrolite", RetroLiteDirective)
613+
app.add_directive("notebooklite", NotebookLiteDirective)
614+
# For backward compatibility
615+
app.add_directive("retrolite", NotebookLiteDirective)
616616
app.add_node(
617617
JupyterLiteIframe,
618618
html=(visit_element_html, None),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies = [
1616
"docutils",
1717
"jupyter_server",
1818
"jupyterlab_server",
19-
"jupyterlite-core >=0.1.0",
19+
"jupyterlite-core >=0.2,<0.3",
2020
"nbformat",
2121
"sphinx>=4",
2222
]

0 commit comments

Comments
 (0)