diff --git a/docs/Makefile b/docs/Makefile index 25548584f..92615f16a 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 000000000..5f97eb4ae --- /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 298876155..235cd9ca3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,6 +19,8 @@ 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("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/'