doc: add commit revision to footer while build with sphinx-multiversion (#939)

Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
LoGin 2024-09-25 22:53:31 +08:00 committed by GitHub
parent 013ffb708f
commit 09dacded09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -54,6 +54,8 @@ source_suffix = ['.rst', '.md']
#
html_theme = 'sphinx_rtd_theme'
html_context = dict()
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
@ -91,4 +93,13 @@ html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
# Tell Jinja2 templates the build is running on Read the Docs
if os.environ.get("READTHEDOCS", "") == "True":
html_context["READTHEDOCS"] = True
html_context["READTHEDOCS"] = True
if os.environ.get("SPHINX_MULTIVERSION_GIT_COMMIT", "") != "":
html_context["commit"] = os.environ["SPHINX_MULTIVERSION_GIT_COMMIT"]
# 截取前 7 位 commit hash如果长度不足则不截取
if "commit" in html_context:
html_context["commit"] = html_context["commit"][:7]

View File

@ -1,4 +1,4 @@
sphinx==5.0.2
myst-parser==0.18.0
sphinx-rtd-theme
sphinx-multiversion==0.2.4
git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/sphinx-multiversion.git@5858b75#egg=sphinx-multiversion