3
我的手寫文檔/用戶指南(用Sphinx編寫在ReStructuredText中)已經變得相當大,所以我開始在子目錄中組織我的.rst文件。如何在sphinx項目中正確包含其他ReST文件?
在index.rst
我包括每個子目錄的subindex.rst
,其本身包括其他.rst
文件的其他子目錄。
index.rst
:
.. include:: subdir1/subindex.rst
.. include:: subdir2/subindex.rst
subdir1/subindex.rst
:
.. include:: file1.rst
.. include:: file2.rst
原則上這個運作良好,除了那個獅身人面像遞歸尋找它試圖解析.rst
-files。而無需更改當前工作目錄。因此,在subdir1
內看到include:: file1.rst
時失敗。
我正在通過設置exclude_pattern
來解決此問題,以忽略我的子目錄。這似乎是不正確的。
什麼是包含.rst
子文件的正確方法?
請閱讀有關'toctree'指令的信息:http://www.sphinx-doc.org/en/stable/markup/toctree.html – Paebbels
如果您將subindex.rst中的include指令更改爲' .. include ::/subdir1/file1.rst'和'.. include ::/subdir1/file2.rst'。 – mzjn