Skip to content

Commit 27ca883

Browse files
authored
Merge pull request #73 from jasongrout-db/contents
Restore jupyterlite_contents being optionally a string
2 parents 3927797 + 3638e80 commit 27ca883

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

docs/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ You can embed custom content (notebooks and data files) in your JupyterLite buil
1212
1313
jupyterlite_contents = ["./path/to/my/notebooks/", "my_other_notebook.ipynb"]
1414
15+
``jupyterlite_contents`` can be a string or a list of strings. Each string is expanded using the Python ``glob.glob`` function with its recursive option. See the `glob documentation <https://docs.python.org/3/library/glob.html#glob.glob>`_ and the `wildcard pattern documentation <https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch>`_ for more details.
16+
1517
JupyterLite dir
1618
---------------
1719

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)