Skip to content

Commit

Permalink
[docs] Fix docs language switcher for the version (backport #5679) (#…
Browse files Browse the repository at this point in the history
…5684)

[docs] Fix docs language switcher for the version (#5679)

* [docs] Fix docs language switcher for the version

* Update conf.py

(cherry picked from commit f8e1ef6)

Co-authored-by: Hailin Wang <[email protected]>
  • Loading branch information
mergify[bot] and haiiliin authored Jul 14, 2024
1 parent f0413f8 commit 07cb9f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import sys
import typing

from packaging.version import Version
from sphinx.builders.html import StandaloneHTMLBuilder

# Environment variables
Expand All @@ -36,8 +37,9 @@
author = "WANG Hailin"

release = abqpy.__version__
major, minor, patch, *_ = release.split(".")
release = version = major
rel = Version(release)
version, major = rel.base_version, rel.major
branch = major if not rel.is_prerelease else "latest"

sys.path.insert(0, os.path.abspath("../../src"))
sys.path.insert(0, os.path.abspath("./_ext"))
Expand Down Expand Up @@ -278,7 +280,7 @@
],
# END: version_dropdown
"languages": [
{"name": alias, "link": f"/{lang}/{version}" if READTHEDOCS else f"/abqpy/{lang}/{version}", "lang": lang}
{"name": alias, "link": f"/{lang}/{branch}" if READTHEDOCS else f"/abqpy/{lang}/{branch}", "lang": lang}
for lang, alias in zip(("en", "zh_CN"), ("English", "简体中文"))
],
"toc_title_is_page_title": True,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ docs = [
"gitpython",
"myst-parser",
"pandas",
"packaging",
"pillow",
"sphinx",
"sphinx-autoapi",
Expand Down

0 comments on commit 07cb9f1

Please sign in to comment.