在索引目录树中包含子目录中的目录树

Alm*_*das 4 subdirectory python-sphinx toctree

我要记录的项目结构如下:

/top
Index.rst
     /a
     toctree_a.rst (contains doc and doc2)
     doc.rst
     doc2.rst
     /b
     toctree_b.rst (contains doc4 and doc3)
     doc3.rst
     doc4.rst
Run Code Online (Sandbox Code Playgroud)

我想引用toctree子目录(a和b)中的s,以便项目toctree可以看到项目树中的4个文档。

当文档位于一个目录中时,我知道如何执行此操作,但如果将它们放在子目录中,我不知道如何执行此操作。我试图保持我的项目结构完整,而不必将所有文件移动到一个目录中。我做了一些研究,发现这 .. include:: directive可能是要走的路线,但我不知道如何正确使用它。

小智 7

您可以告诉 index.rst 中的 toctree 从子目录中获取文件,如下所示:

内容:

.. toctree::
   :maxdepth: 2

    a/doc
    a/doc2
    b/doc3
    b/doc4
Run Code Online (Sandbox Code Playgroud)

该方法就像它们在同一目录中一样工作