diff --git a/docs/zh_cn/conf.py b/docs/zh_cn/conf.py index d20269bb..88659f17 100644 --- a/docs/zh_cn/conf.py +++ b/docs/zh_cn/conf.py @@ -11,6 +11,7 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os +import subprocess import sys import pytorch_sphinx_theme @@ -102,3 +103,11 @@ html_css_files = ['css/readthedocs.css'] # Ignore >>> when copying code copybutton_prompt_text = r'>>> |\.\.\. ' copybutton_prompt_is_regexp = True + + +def builder_inited_handler(app): + subprocess.run(['./cp_origin_docs.sh']) + + +def setup(app): + app.connect('builder-inited', builder_inited_handler) diff --git a/docs/zh_cn/cp_origin_docs.sh b/docs/zh_cn/cp_origin_docs.sh new file mode 100755 index 00000000..1e728323 --- /dev/null +++ b/docs/zh_cn/cp_origin_docs.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Copy *.md files from docs/ if it doesn't have a Chinese translation + +for filename in $(find ../en/ -name '*.md' -printf "%P\n"); +do + mkdir -p $(dirname $filename) + cp -n ../en/$filename ./$filename +done diff --git a/docs/zh_cn/index.rst b/docs/zh_cn/index.rst index 242bc415..9530a18a 100644 --- a/docs/zh_cn/index.rst +++ b/docs/zh_cn/index.rst @@ -91,7 +91,7 @@ .. toctree:: :maxdepth: 2 - :caption: Notes + :caption: 说明 notes/changelog.md