Skip to content

Commit 97014e2

Browse files
authored
Remove Apps config auto-computation (#104)
This brings a backward incompatibility: we used to always build the lab app if apps was not specified in the user config
1 parent 047eb92 commit 97014e2

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
from sphinx.util.fileutil import copy_asset
2020
from sphinx.parsers import RSTParser
2121

22+
try:
23+
import voici
24+
except ImportError:
25+
voici = None
26+
2227
HERE = Path(__file__).parent
2328

2429
CONTENT_DIR = "_contents"
2530
JUPYTERLITE_DIR = "lite"
26-
# Using a global variable, is there a better way?
27-
APPS = []
2831

2932

3033
# Used for nodes that do not need to be rendered
@@ -196,9 +199,6 @@ class RepliteDirective(SphinxDirective):
196199
}
197200

198201
def run(self):
199-
if not "repl" in APPS:
200-
APPS.append("repl")
201-
202202
width = self.options.pop("width", "100%")
203203
height = self.options.pop("height", "100%")
204204

@@ -289,12 +289,6 @@ class JupyterLiteDirective(_LiteDirective):
289289

290290
iframe_cls = JupyterLiteIframe
291291

292-
def run(self):
293-
if not "lab" in APPS:
294-
APPS.append("lab")
295-
296-
return super().run()
297-
298292

299293
class RetroLiteDirective(_LiteDirective):
300294
"""The ``.. retrolite::`` directive.
@@ -304,12 +298,6 @@ class RetroLiteDirective(_LiteDirective):
304298

305299
iframe_cls = RetroLiteIframe
306300

307-
def run(self):
308-
if not "retro" in APPS:
309-
APPS.append("retro")
310-
311-
return super().run()
312-
313301

314302
class VoiciDirective(_LiteDirective):
315303
"""The ``.. voici::`` directive.
@@ -320,16 +308,11 @@ class VoiciDirective(_LiteDirective):
320308
iframe_cls = VoiciIframe
321309

322310
def run(self):
323-
try:
324-
import voici
325-
except ImportError:
311+
if voici is None:
326312
raise RuntimeError(
327313
"Voici must be installed if you want to make use of the voici directive: pip install voici"
328314
)
329315

330-
if not "voici" in APPS:
331-
APPS.append("voici")
332-
333316
return super().run()
334317

335318

@@ -393,22 +376,26 @@ def jupyterlite_build(app: Sphinx, error):
393376
for content in jupyterlite_contents:
394377
contents.extend(["--contents", content])
395378

396-
apps = []
397-
for jlite_app in APPS:
398-
apps.extend(["--apps", jlite_app])
379+
voici_option = [] if voici is None else ["--apps", "voici"]
399380

400381
command = [
401382
"jupyter",
402383
"lite",
403384
"build",
404385
"--debug",
405386
*config,
406-
*apps,
407387
*contents,
408388
"--contents",
409389
os.path.join(app.srcdir, CONTENT_DIR),
410390
"--output-dir",
411391
os.path.join(app.outdir, JUPYTERLITE_DIR),
392+
"--apps",
393+
"lab",
394+
"--apps",
395+
"retro",
396+
"--apps",
397+
"repl",
398+
*voici_option,
412399
"--lite-dir",
413400
jupyterlite_dir,
414401
]

0 commit comments

Comments
 (0)