Skip to content

Commit

Permalink
Merge pull request #272 from Readon/master
Browse files Browse the repository at this point in the history
add pdf and related version generating for Chinese.
  • Loading branch information
Readon authored Dec 24, 2024
2 parents 5963c6c + 9550884 commit d0ec7f9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
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

0 comments on commit d0ec7f9

Please sign in to comment.