Skip to content

Commit 02b4b9a

Browse files
authored
Merge pull request #69 from ycexiao/rm-copied-notebook
docs: remove copied notebook files after building the documentation
2 parents bb29999 + 8495bdf commit 02b4b9a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

docs/source/conf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,26 @@
3838
# Include notebooks at build time.
3939
root_dir = Path(__file__).resolve().parents[1]
4040
external_nb_dir = root_dir / "examples"
41+
copied_files = []
4142
for f in external_nb_dir.glob("*.ipynb"):
4243
dest = Path(__file__).parent / "examples" / f.name
4344
if dest.exists():
4445
dest.unlink()
46+
copied_files.append(dest)
4547
shutil.copy(f, dest)
4648

49+
50+
def post_build_hook(app, exception):
51+
"""Remove copied files after building documentation."""
52+
for f in copied_files:
53+
if f.exists():
54+
f.unlink()
55+
56+
57+
def setup(app):
58+
app.connect("build-finished", post_build_hook)
59+
60+
4761
# -- General configuration ------------------------------------------------
4862

4963
# If your documentation needs a minimal Sphinx version, state it here.

news/rm-copied-notebook.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* No news added: Remove the copied notebooks after building the documentation.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

0 commit comments

Comments
 (0)