【问题标题】:Sphinx - what is different between toctree and content?Sphinx - 目录树和内容有什么不同?
【发布时间】:2017-02-07 15:38:06
【问题描述】:

我可以通过两种方式创建目录:

.. contents::
   :local:
   depth: 1

或作为

.. toctree::
    :maxdepth: 1

    index

有什么区别?我应该在哪里使用目录树以及内容在哪里?

【问题讨论】:

    标签: python python-sphinx tableofcontents toctree


    【解决方案1】:

    .. contents 是一个 doctutils 指令(定义 ReST 和相关实用程序的底层库),自动根据当前主题的标题生成目录。

    .. toctree 是 Sphinx 定义的指令,您可以在其中明确列出文档,其 TOC 将被列出。

    例如,您可以在文档中使用.. contents 来生成页面内容的概览,例如:

    ===================
    Curing World Hunger
    ===================
    
    .. contents::
       :depth: 1
    
    Abstract
    ========
    
    …
    
    Problem description
    ===================
    
    …
    

    您将在基本上不包含其他内容的索引文档中使用.. toctree

    =================
    Scientific papers
    =================
    
    Below is a list of papers published here:
    
    .. toctree::
       :maxdepth: 2
    
       curing_hunger
       …
    

    .. toctree 获取要处理的文档列表,.. contents 没有。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-17
      • 1970-01-01
      • 2020-04-11
      • 2013-02-06
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多