Skip to content

Commit 6730bef

Browse files
committed
Enable jupyterlite_contents to be a string again
When we added globs, we accidentally ignored the case where jupyterlite_contents was a string. This refactors the code and handles that case.
1 parent 3927797 commit 6730bef

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,26 +296,27 @@ def jupyterlite_build(app: Sphinx, error):
296296
print("[jupyterlite-sphinx] Running JupyterLite build")
297297
jupyterlite_config = app.env.config.jupyterlite_config
298298
jupyterlite_contents = app.env.config.jupyterlite_contents
299-
if jupyterlite_contents is not None:
300-
jupyterlite_contents = [
301-
match
302-
for pattern in jupyterlite_contents
303-
for match in glob.glob(pattern, recursive=True)
304-
]
305299
jupyterlite_dir = app.env.config.jupyterlite_dir
306300

307301
config = []
308302
if jupyterlite_config:
309303
config = ["--config", jupyterlite_config]
310304

311-
contents = []
312-
if jupyterlite_contents:
313-
if isinstance(jupyterlite_contents, str):
314-
contents.extend(["--contents", jupyterlite_contents])
305+
if jupyterlite_contents is None:
306+
jupyterlite_contents = []
307+
elif isinstance(jupyterlite_contents, str):
308+
jupyterlite_contents = [jupyterlite_contents]
309+
310+
# Expand globs in the contents strings
311+
jupyterlite_contents = [
312+
match
313+
for pattern in jupyterlite_contents
314+
for match in glob.glob(pattern, recursive=True)
315+
]
315316

316-
if isinstance(jupyterlite_contents, (tuple, list)):
317-
for content in jupyterlite_contents:
318-
contents.extend(["--contents", content])
317+
contents = []
318+
for content in jupyterlite_contents:
319+
contents.extend(["--contents", content])
319320

320321
command = [
321322
"jupyter",

0 commit comments

Comments
 (0)