|
4 | 4 |
|
5 | 5 | import os |
6 | 6 | import os.path as osp |
7 | | -import shutil |
8 | 7 | import sys |
9 | 8 | import zipfile |
10 | 9 |
|
|
23 | 22 | # (documentation build is not the right place for validation) |
24 | 23 | gcfg.set_validation_mode(gcfg.ValidationMode.DISABLED) |
25 | 24 |
|
26 | | -# -- Copy CHANGELOG.md to doc folder ------------------------ |
27 | | -# |
28 | | -# Note: An alternative to this could be to create a 'changelog.rst' file |
29 | | -# containing the following: |
30 | | -# |
31 | | -# .. include:: ../../CHANGELOG.md |
32 | | -# :parser: myst_parser.sphinx_ |
33 | | -# |
34 | | -# But, due to the on-the-fly parsing of the markdown file, this alternative approach |
35 | | -# is not compatible with the internationalization process of the documentation (see |
36 | | -# https://github.com/DataLab-Platform/DataLab/issues/108). That is why we copy the |
37 | | -# CHANGELOG.md file to the doc/contributing folder and remove it after the build. |
38 | | - |
39 | | - |
40 | | -def copy_changelog(app): |
41 | | - """Copy CHANGELOG.md to doc/contributing folder.""" |
42 | | - docpath = osp.abspath(osp.dirname(__file__)) |
43 | | - dest_fname = osp.join(docpath, "changelog.md") |
44 | | - if osp.exists(dest_fname): |
45 | | - os.remove(dest_fname) |
46 | | - shutil.copyfile(osp.join(docpath, "..", "CHANGELOG.md"), dest_fname) |
47 | | - app.env.temp_changelog_path = dest_fname |
48 | | - |
49 | | - |
50 | | -def cleanup_changelog(app, exception): |
51 | | - """Remove CHANGELOG.md from doc/contributing folder.""" |
52 | | - try: |
53 | | - path = getattr(app.env, "temp_changelog_path", None) |
54 | | - if path and osp.exists(path): |
55 | | - os.remove(path) |
56 | | - except Exception as exc: |
57 | | - print(f"Warning: failed to remove {path}: {exc}") |
58 | | - finally: |
59 | | - if hasattr(app.env, "temp_changelog_path"): |
60 | | - del app.env.temp_changelog_path |
61 | | - |
62 | 25 |
|
63 | 26 | def compress_tutorials_data(app): |
64 | 27 | """Compress tutorials data folders to zip files in doc/_download directory.""" |
@@ -96,9 +59,7 @@ def compress_tutorials_data(app): |
96 | 59 |
|
97 | 60 | def setup(app): |
98 | 61 | """Setup function for Sphinx.""" |
99 | | - app.connect("builder-inited", copy_changelog) |
100 | 62 | app.connect("builder-inited", compress_tutorials_data) |
101 | | - app.connect("build-finished", cleanup_changelog) |
102 | 63 |
|
103 | 64 | # Exclude outreach directory from LaTeX/PDF builds |
104 | 65 | def exclude_outreach_from_latex(app): |
|
0 commit comments