Created by: luotao1
由于合并中英文目录到doc/后,会有index_en.rst和index_cn.rst。而sphinx编译时,必须有名字为index.rst或index.md的文件。因此在sphinx编译前复制index_en/cn.rst为index.rst,编译后删除复制出的index.rst,能生成两颗目录树。
将doc_cn目录合并到doc后,只需修改doc/CMakeLists.txt
如下,就能在一个doc目录下,生成两颗目录树。:
set(BINARY_BUILD_DIR_EN "${CMAKE_CURRENT_BINARY_DIR}/en/_build")
set(SPHINX_CACHE_DIR_EN "${CMAKE_CURRENT_BINARY_DIR}/en/_doctrees")
set(SPHINX_HTML_DIR_EN "${CMAKE_CURRENT_BINARY_DIR}/en/html")
set(INDEX_NAME_EN "index_en.rst")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${BINARY_BUILD_DIR_EN}/conf.py"
@ONLY)
sphinx_add_target(paddle_docs
html
${BINARY_BUILD_DIR_EN}
${SPHINX_CACHE_DIR_EN}
${CMAKE_CURRENT_SOURCE_DIR}
${SPHINX_HTML_DIR_EN}
${INDEX_NAME_EN})
add_dependencies(paddle_docs
gen_proto_py)
-----------------------------------------------------
set(BINARY_BUILD_DIR_CN "${CMAKE_CURRENT_BINARY_DIR}/cn/_build")
set(SPHINX_CACHE_DIR_CN "${CMAKE_CURRENT_BINARY_DIR}/cn/_doctrees")
set(SPHINX_HTML_DIR_CN "${CMAKE_CURRENT_BINARY_DIR}/cn/html")
set(INDEX_NAME_CN "index_cn.rst")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${BINARY_BUILD_DIR_CN}/conf.py"
@ONLY)
sphinx_add_target(paddle_docs_cn
html
${BINARY_BUILD_DIR_CN}
${SPHINX_CACHE_DIR_CN}
${CMAKE_CURRENT_SOURCE_DIR}
${SPHINX_HTML_DIR_CN}
${INDEX_NAME_CN})
add_dependencies(paddle_docs_cn
gen_proto_py)