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

add pdf and related version generating for Chinese. #272

Merged
merged 4 commits into from
Dec 24, 2024
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
13 changes: 12 additions & 1 deletion .github/workflows/push-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
tags: spinaldoc-pdf
file: pdf.Dockerfile
- name: Build zh-cn translated doc
run: docker run --rm -u $(id -u $USER):$(id -g $USER) -v $PWD:/docs -e sphinx_html_baseurl -e sphinx_github_url spinaldoc-pdf sphinx-build -b html -D language=zh_CN ./source/ docs/html/zh_CN
run: docker run --rm -u $(id -u $USER):$(id -g $USER) -v $PWD:/docs -e SPHINX_LANGUAGE=zh_CN -e sphinx_html_baseurl -e sphinx_github_url spinaldoc-pdf sphinx-multiversion ./source/ docs/html/zh_CN
- name: Build multiversioned doc
run: docker run --rm -u $(id -u $USER):$(id -g $USER) -v $PWD:/docs -e sphinx_html_baseurl -e sphinx_github_url spinaldoc-pdf sphinx-multiversion source docs/html
- name: Add .nojekill
Expand All @@ -55,6 +55,17 @@ jobs:
</head>
</html>
EOF
sudo tee docs/html/zh_CN/index.html << EOF
<!DOCTYPE html>
<html>
<head>
<title>Redirecting to ${sphinx_extra_version}</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=./${sphinx_extra_version}/index.html">
<link rel="canonical" href="${sphinx_html_baseurl}index.html">
</head>
</html>
EOF
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
11 changes: 7 additions & 4 deletions source/_templates/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
{%- if True %}
<dl>
<dt>Languages</dt>
<dd class="rtd-current-item">
<a href="#">en</a>
</dd>
{% for the_language, url in languages %}
<dd><a href="{{ url }}/index.html">{{ the_language }}</a></dd>
{% if the_language == current_language %}
<dd class="rtd-current-item"><a href="#">{{ the_language }}</a></dd>
{% elif current_language == "en" %}
<dd><a href="../{{ the_language }}/index.html">{{ the_language }}</a></dd>
{% else %}
<dd><a href="../../{{ url }}/index.html">{{ the_language }}</a></dd>
{% endif %}
{% endfor %}
</dl>
{%- endif %}
Expand Down
13 changes: 9 additions & 4 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = os.getenv('SPHINX_LANGUAGE', 'en')

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -223,8 +223,9 @@
'github_version': os.getenv('GITHUB_REF_NAME', 'master'), # Version
'conf_py_path': '/source/', # Path in the checkout to the docs root

'current_language': 'en',
'languages': [["zh_CN", "/SpinalDoc-RTD/zh_CN"]],
'current_language': language,
'languages': [["en", "."],
["zh_CN", "zh_CN"]],
'sphinx_latest_version': os.getenv('sphinx_latest_version', None)
}

Expand All @@ -236,7 +237,11 @@
tls_verify = False # disable since Intel urls don't verify on github infra

# Whitelist pattern for tags (set to None to ignore all tags)
smv_tag_whitelist = r'^.*$'
version_whitelist = {
'en': r'^.*$',
'zh_CN': None
}
smv_tag_whitelist = version_whitelist[language]

# The branch called "latest" is not a real branch/tag, it is aliased by the document
# build process to the most recent stable release.
Expand Down
Loading