【问题标题】:How can i include the `genindex` in a Sphinx TOC?如何在 Sphinx TOC 中包含“genindex”?
【发布时间】:2016-07-14 03:10:56
【问题描述】:

Sphinx 在构建文档时会生成一个名为 genindex 的索引,因此会生成一个名为 forbids to use that name for a document 的索引。现在,如何在目录中包含指向该索引的链接?

我试过了:

.. toctree::
   :maxdepth: 2

   genindex
   api


Indices and tables
==================

* :ref:`genindex`

虽然最后一行确实在文档中创建了指向该索引的链接,但构建在创建 TOC 时并不知道引用:

WARNING: toctree contains reference to nonexisting document 'genindex'

【问题讨论】:

标签: python-sphinx toctree


【解决方案1】:

使用以下内容创建文件genindex.rst

Index
=====

在你的index.rst 添加:

.. toctree::
   :hidden:

   genindex

如果您还想在网站上拥有链接和文本“索引”,而不仅仅是在左侧导航中,请删除 :hidden:

【讨论】:

  • 这很有趣,docs 明确声明不要使用该名称创建文件。
  • 你是对的。这可能会导致问题。我有一个项目,除非我不删除“genindex.rst”-Hack,否则使用 rst2pdf 创建 PDF 不起作用。
  • 这不太好笑。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-03
  • 2020-03-18
  • 1970-01-01
  • 2018-07-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多