Skip to content

Commit

Permalink
Raise an error on the first conflict itself
Browse files Browse the repository at this point in the history
Co-Authored-By: Albert Steppi <[email protected]>
  • Loading branch information
agriyakhetarpal and steppi committed Dec 20, 2024
1 parent 574acae commit 29bb810
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions jupyterlite_sphinx/jupyterlite_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,11 @@ def _target_is_stale(self, source_path: Path, target_path: Path) -> bool:
def _assert_no_conflicting_nb_names(
self, source_path: Path, notebooks_dir: Path
) -> None:
"""Checks for duplicate notebook names in the documentation sources.
"""Check for duplicate notebook names in the documentation sources.
Raises if any notebooks would conflict when converted to IPyNB."""
target_stem = source_path.stem
target_ipynb = f"{target_stem}.ipynb"

colliding_files = []

# Only look for conflicts in source directories and among referenced notebooks.
# We do this to prevent conflicts with other files, say, in the "_contents/"
# directory as a result of a previous failed/interrupted build.
Expand All @@ -426,15 +424,11 @@ def _assert_no_conflicting_nb_names(
existing_path.stem == target_stem
and existing_path != source_path
):
colliding_files.append(str(existing_path))

if colliding_files:
colliding_files.append(str(source_path))
raise RuntimeError(
"All notebooks marked for inclusion with JupyterLite must have a "
"unique file basename. Found conflicting files: "
f"{', '.join(colliding_files)}."
)

raise RuntimeError(
"All notebooks marked for inclusion with JupyterLite must have a "
f"unique file basename. Found conflict between {source_path} and {existing_path}."
)

return target_ipynb

Expand Down

0 comments on commit 29bb810

Please sign in to comment.