【发布时间】:2017-02-07 15:38:06
【问题描述】:
我可以通过两种方式创建目录:
.. contents::
:local:
depth: 1
或作为
.. toctree::
:maxdepth: 1
index
有什么区别?我应该在哪里使用目录树以及内容在哪里?
【问题讨论】:
标签: python python-sphinx tableofcontents toctree
我可以通过两种方式创建目录:
.. contents::
:local:
depth: 1
或作为
.. toctree::
:maxdepth: 1
index
有什么区别?我应该在哪里使用目录树以及内容在哪里?
【问题讨论】:
标签: python python-sphinx tableofcontents toctree
.. 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 没有。
【讨论】: