MCPcopy Create free account
hub / github.com/PyWavelets/pywt / preprocess_notebooks

Function preprocess_notebooks

doc/source/conf.py:34–55  ·  view source on GitHub ↗

Preprocess Markdown notebooks to convert them to IPyNB format.

(app: Sphinx, *args, **kwargs)

Source from the content-addressed store, hash-verified

32
33
34def preprocess_notebooks(app: Sphinx, *args, **kwargs):
35 """Preprocess Markdown notebooks to convert them to IPyNB format."""
36
37 import jupytext
38 import nbformat
39
40 print("Converting Markdown files to IPyNB...")
41 for path in (HERE / "regression").glob("*.md"):
42 if any(path.match(pattern) for pattern in exclude_patterns):
43 continue
44 nb = jupytext.read(str(path))
45
46 # In .md to .ipynb conversion, do not include any cells that have the
47 # jupyterlite_sphinx_strip tag
48 nb.cells = [
49 cell for cell in nb.cells if "jupyterlite_sphinx_strip" not in cell.metadata.get("tags", [])
50 ]
51
52 ipynb_path = path.with_suffix(".ipynb")
53 with open(ipynb_path, "w") as f:
54 nbformat.write(nb, f)
55 print(f"Converted {path} to {ipynb_path}")
56
57
58# Should match {{ parent_docname }} or {{parent_docname}}

Callers

nothing calls this directly

Calls 2

readMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected