Skip to content
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
24 changes: 24 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

from docutils import nodes


# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -73,6 +75,8 @@
json_url = "https://inference.readthedocs.io/en/latest/_static/switcher.json"
if not version_match:
version_match = 'en'
if version_match == 'zh-cn':
tags.add("zh_cn")

html_theme_options = {
"show_toc_level": 2,
Expand Down Expand Up @@ -130,3 +134,23 @@
]

html_favicon = "_static/favicon.svg"


def _remove_non_zh_cn_nodes(app, doctree, docname):
current_language = getattr(app.config, "language", None)
is_zh_cn = version_match == "zh-cn" or current_language in {"zh_CN", "zh-cn"}
if is_zh_cn:
return

for node in list(
doctree.findall(
lambda n: isinstance(n, nodes.Element)
and "zh-cn-only" in n.get("classes", [])
)
):
if node.parent is not None and node in node.parent:
node.parent.remove(node)


def setup(app):
app.connect("doctree-resolved", _remove_non_zh_cn_nodes)
3 changes: 2 additions & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ Getting Involved

:fab:`twitter` Follow us on Twitter

.. grid-item-card::
.. grid-item-card::
:link: https://zhihu.com/org/xorbits
:class-item: zh-cn-only

:fab:`zhihu` Read our blogs

Expand Down
Loading