From 920bda5958b1ac1c143b3f1c5663d42b1574733e Mon Sep 17 00:00:00 2001 From: LoGin Date: Wed, 25 Sep 2024 23:53:23 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E6=B7=BB=E5=8A=A0=E5=9C=A8github?= =?UTF-8?q?=E4=B8=8A=E7=BC=96=E8=BE=91=E7=9A=84=E6=8C=89=E9=92=AE,?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=89=A9=E5=B1=95footer=20(#940)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: longjin --- docs/Makefile | 16 +++++++++++++++- docs/_templates/footer.html | 8 ++++++++ docs/conf.py | 15 ++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 docs/_templates/footer.html diff --git a/docs/Makefile b/docs/Makefile index 25548584..92615f16 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -8,6 +8,20 @@ SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build +LANGUAGE = zh_CN + +SPHINXOPTS += -D language=$(LANGUAGE) + +export CURRENT_GIT_COMMIT_HASH := $(shell git rev-parse --short HEAD) + +GIT_STATUS := $(shell git status --porcelain --untracked-files=no) + +ifeq ($(strip $(GIT_STATUS)),) + export CURRENT_GIT_COMMIT_DIRTY = 0 +else + export CURRENT_GIT_COMMIT_DIRTY = 1 +endif + # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @@ -21,4 +35,4 @@ help: .PHONY: html-multiversion: - rm -rf ./$(BUILDDIR) && sphinx-multiversion "$(SOURCEDIR)" ./$(BUILDDIR)/html && cp -rf ./$(BUILDDIR)/html/master/* ./$(BUILDDIR)/html/ + rm -rf ./$(BUILDDIR) && CURRENT_GIT_COMMIT_DIRTY=0 sphinx-multiversion $(SPHINXOPTS) "$(SOURCEDIR)" ./$(BUILDDIR)/html && cp -rf ./$(BUILDDIR)/html/master/* ./$(BUILDDIR)/html/ diff --git a/docs/_templates/footer.html b/docs/_templates/footer.html new file mode 100644 index 00000000..5f97eb4a --- /dev/null +++ b/docs/_templates/footer.html @@ -0,0 +1,8 @@ +{% extends "!footer.html" %} + +{% block extrafooter %} +
+
+ 官网 https://dragonos.org | 论坛 https://bbs.dragonos.org.cn | 赞助DragonOS,成就未来! +
+{% endblock %} diff --git a/docs/conf.py b/docs/conf.py index 29887615..235cd9ca 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,6 +19,8 @@ import os project = 'DragonOS' copyright = '2022-2024, DragonOS Community' author = 'longjin' +github_org = 'DragonOS-Community' +github_repo = 'DragonOS' # The full version, including alpha/beta/rc tags release = 'dev' @@ -97,9 +99,20 @@ if os.environ.get("READTHEDOCS", "") == "True": if os.environ.get("SPHINX_MULTIVERSION_GIT_COMMIT", "") != "": html_context["commit"] = os.environ["SPHINX_MULTIVERSION_GIT_COMMIT"] - +elif os.environ.get("CURRENT_GIT_COMMIT_HASH", "") != "": + html_context["commit"] = os.environ["CURRENT_GIT_COMMIT_HASH"] # 截取前 7 位 commit hash,如果长度不足则不截取 if "commit" in html_context: html_context["commit"] = html_context["commit"][:7] + if os.environ.get("CURRENT_GIT_COMMIT_DIRTY", "") == "1": + html_context["commit"] += "-dirty" + + +# -- Set GitHub URL for Edit on GitHub links --- +html_context['display_github'] = True +html_context['github_user'] = github_org +html_context['github_repo'] = github_repo +html_context['github_version'] = html_context['commit'] if 'commit' in html_context else 'master' +html_context['conf_py_path'] = '/docs/'