Python sphinx 如何在sphinx项目中正确包含其他ReST文件?
我的手写文档/用户指南(使用sphinx以StructuredText编写)变得相当大,因此我开始在子目录中组织我的.rst文件 在Python sphinx 如何在sphinx项目中正确包含其他ReST文件?,python-sphinx,restructuredtext,Python Sphinx,Restructuredtext,我的手写文档/用户指南(使用sphinx以StructuredText编写)变得相当大,因此我开始在子目录中组织我的.rst文件 在index.rst中,我包含了每个子目录的subindex.rst,它本身包括其他.rst-文件,用于进一步的子目录 index.rst: .. include:: subdir1/subindex.rst .. include:: subdir2/subindex.rst .. include:: file1.rst .. include:: file2.rst
index.rst
中,我包含了每个子目录的subindex.rst
,它本身包括其他.rst
-文件,用于进一步的子目录
index.rst
:
.. include:: subdir1/subindex.rst
.. include:: subdir2/subindex.rst
.. include:: file1.rst
.. include:: file2.rst
subdir1/subindex.rst
:
.. include:: subdir1/subindex.rst
.. include:: subdir2/subindex.rst
.. include:: file1.rst
.. include:: file2.rst
原则上,除了sphinx递归地查找它试图解析的.rst
-文件之外,这一切都很好。不更改当前工作目录。因此,当看到include::file1.rst
内部subdir1
时,它会失败
我正在通过设置exclude\u pattern
忽略我的子目录来解决这个问题。这似乎不对
包含子目录的.rst
-文件的正确方法是什么?应该做您想要做的事情
.. toctree::
:glob:
subdir1/*
subdir2/*
glob*
将按字母顺序对子目录中的文件进行排序。为了避免排序,可以指定顺序而不进行全局搜索
.. toctree::
:maxdepth: 2
subdir1/file2
subdir1/file1
subdir2/file1
subdir2/file2
如果您不想要单独的页面而是一个巨大的页面,您可以调用。请阅读toctree
指令的相关内容:如果您将subindex.rst中的include指令更改为,该指令应该会起作用。。包括::/subdir1/file1.rst
和。。包括::/subdir1/file2.rst
。如何添加外部目录?比如。/subdir1/*