Skip to content

Commit

Permalink
Rename NB conversion caching function to _target_is_stale()
Browse files Browse the repository at this point in the history
Co-authored-by: Albert Steppi <[email protected]>
  • Loading branch information
agriyakhetarpal and steppi authored Dec 20, 2024
1 parent 81c0c09 commit 2c1ef54
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jupyterlite_sphinx/jupyterlite_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ class _LiteDirective(SphinxDirective):
"button_text": directives.unchanged,
}

def _should_convert_notebook(self, source_path: Path, target_path: Path) -> bool:
"""Check if a Markdown notebook needs conversion to IPyNB format based on
some rudimentary timestamp-based caching."""
def _target_is_stale(self, source_path: Path, target_path: Path) -> bool:
# Used as a heuristic to determine if a markdown notebook needs to be
# converted or reconverted to ipynb.
if not target_path.exists():
return True

Expand Down Expand Up @@ -507,7 +507,7 @@ def run(self):
notebook_is_stripped: bool = self.env.config.strip_tagged_cells

if notebook_path.suffix.lower() == ".md":
if self._should_convert_notebook(notebook_path, target_path):
if self._target_is_stale(notebook_path, target_path):
nb = jupytext.read(str(notebook_path))
if notebook_is_stripped:
nb.cells = self._strip_notebook_cells(nb)
Expand Down

0 comments on commit 2c1ef54

Please sign in to comment.