【问题标题】:Include toctree from subdirectory in Index toctree在索引目录树中包含子目录的目录树
【发布时间】:2016-08-11 19:30:11
【问题描述】:

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

/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

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

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

【问题讨论】:

    标签: python-sphinx subdirectory toctree


    【解决方案1】:

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

    内容:

    .. toctree::
       :maxdepth: 2
    
        a/doc
        a/doc2
        b/doc3
        b/doc4
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-29
      • 2015-06-07
      • 1970-01-01
      • 2011-06-04
      相关资源
      最近更新 更多