diff --git a/docs/source/conf.py b/docs/source/conf.py index 1570b0f..547675b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -38,12 +38,26 @@ # Include notebooks at build time. root_dir = Path(__file__).resolve().parents[1] external_nb_dir = root_dir / "examples" +copied_files = [] for f in external_nb_dir.glob("*.ipynb"): dest = Path(__file__).parent / "examples" / f.name if dest.exists(): dest.unlink() + copied_files.append(dest) shutil.copy(f, dest) + +def post_build_hook(app, exception): + """Remove copied files after building documentation.""" + for f in copied_files: + if f.exists(): + f.unlink() + + +def setup(app): + app.connect("build-finished", post_build_hook) + + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. diff --git a/news/rm-copied-notebook.rst b/news/rm-copied-notebook.rst new file mode 100644 index 0000000..cbf3562 --- /dev/null +++ b/news/rm-copied-notebook.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news added: Remove the copied notebooks after building the documentation. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +*