我正在为包含模块的平台构建文档。我想让文档存在于这些模块存储库中,并使用 include 命令将它们包含在“主”文档中。
我尝试了以下方法:
.. include:: https://github.com/12rambau/sepal_ui_template/blob/master/doc/en.rst
但没有向文件中添加任何内容
是否可以在include
命令中使用绝对链接?
答案 0 :(得分:1)
答案 1 :(得分:0)
我的主要目标不是使用 include
命令,而是避免代码重复并使用网络上可用的文件。根据 @Steve piercy 的回答,我想出了这个解决方案:
在conf.py文件中我从github复制文件内容
<块引用>小心并使用 raw.githubusercontent.com
链接避免导入 html
# [...]
# -- Copy the modules documentation ------------------------------------------
from urllib.request import urlretrieve
urlretrieve (
"https://raw.githubusercontent.com/12rambau/sepal_ui_template/master/doc/en.rst",
"modules/sepal_ui_template.rst"
)
在我的文档中的 modules/sepal_ui_template.rst
下创建文件后,我可以安全地访问它。
每次我重建文档时都会重新下载。