Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: 添加在github上编辑的按钮,以及扩展footer #940

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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/
8 changes: 8 additions & 0 deletions docs/_templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "!footer.html" %}

{% block extrafooter %}
<div>
<br>
官网 <a href="https://dragonos.org">https://dragonos.org</a> | 论坛 <a href="https://bbs.dragonos.org.cn">https://bbs.dragonos.org.cn</a> | <a href="https://dragonos.org">赞助DragonOS,成就未来!</a>
</div>
{% endblock %}
15 changes: 14 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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/'
Loading