Skip to content

Commit d5fed45

Browse files
committed
Doc: fixed broken links in translated changelog page
Fix #108
1 parent 5744146 commit d5fed45

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ doc/extras_require-doc.txt
1414
*.bak
1515
/tutorialnotes*.md
1616
doc/locale/pot/_sphinx_design_static/
17+
doc/contributing/changelog.md
1718

1819
# Visual Studio Code
1920
.venv

doc/conf.py

+45
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# pylint: skip-file
44

55
import os
6+
import os.path as osp
7+
import shutil
68
import sys
79

810
sys.path.insert(0, os.path.abspath(".."))
@@ -11,6 +13,49 @@
1113

1214
os.environ["CDL_DOC"] = "1"
1315

16+
17+
# -- Copy CHANGELOG.md to doc/contributing folder ------------------------
18+
#
19+
# Note: An alternative to this could be to create a 'contributing/changelog.rst' file
20+
# containing the following:
21+
#
22+
# .. include:: ../../CHANGELOG.md
23+
# :parser: myst_parser.sphinx_
24+
#
25+
# But, due to the on-the-fly parsing of the markdown file, this alternative approach
26+
# is not compatible with the internationalization process of the documentation (see
27+
# https://github.com./DataLab-Platform/DataLab/issues/108). That is why we copy the
28+
# CHANGELOG.md file to the doc/contributing folder and remove it after the build.
29+
30+
31+
def copy_changelog(app):
32+
"""Copy CHANGELOG.md to doc/contributing folder."""
33+
docpath = osp.abspath(osp.dirname(__file__))
34+
dest_fname = osp.join(docpath, "contributing", "changelog.md")
35+
if osp.exists(dest_fname):
36+
os.remove(dest_fname)
37+
shutil.copyfile(osp.join(docpath, "..", "CHANGELOG.md"), dest_fname)
38+
app.env.temp_changelog_path = dest_fname
39+
40+
41+
def cleanup_changelog(app, exception):
42+
"""Remove CHANGELOG.md from doc/contributing folder."""
43+
try:
44+
path = getattr(app.env, "temp_changelog_path", None)
45+
if path and osp.exists(path):
46+
os.remove(path)
47+
except Exception as exc:
48+
print(f"Warning: failed to remove {path}: {exc}")
49+
finally:
50+
del app.env.temp_changelog_path
51+
52+
53+
def setup(app):
54+
"""Setup function for Sphinx."""
55+
app.connect("builder-inited", copy_changelog)
56+
app.connect("build-finished", cleanup_changelog)
57+
58+
1459
# -- Project information -----------------------------------------------------
1560

1661
project = "DataLab"

doc/contributing/changelog.rst

-2
This file was deleted.

0 commit comments

Comments
 (0)