如何在 ReadTheDocs 导航栏中 link 生成索引页面?
How can I link the generated index page in ReadTheDocs navigation bar?
我正在使用 Sphinx 在 ReadTheDocs 上创建我的文档,使用他们的主题。构建过程会生成一个genindex.html文件,可以通过以下方式引用:
Link to the :ref:`genindex` page.
创建:
Link to the Index page.
我无法将 genindex
添加到我的目录树中,例如:
.. toctree:
foo
bar
genindex
因为它是一个自动生成的文件,在渲染时不存在。此外,Sphinx 期望 genindex 是一个名为 genindex.rst
.
的本地文件
如何将它添加到我的目录/导航中?
由于没有人发布更好的解决方案,我将写下我的解决方法作为可行的解决方案。
Sphinx 在构建根目录中将索引创建为 denindex.html
。它不能在 toctree
指令中引用,因为该指令引用了 ReST 文件。那么如何解决呢?
所以让我们创建一个 genindex.rst
文件并从 toctree
指令中引用它。这也会在构建根目录中创建一个 genindex.html
。所有 link 都按预期创建。 genindex.html
文件需要定义一个像 "Index" 这样的标题,用作导航栏中的 link 标题。
从 ReST 文件写入所有 HTML 文件后,Sphinx 生成其索引并覆盖 genindex.html
。
源文件:
源文件index.rst
:
.. toctree::
:caption: Introduction
chapter1
chapter2
.. toctree::
:caption: Main Documentation
chapter3
chapter4
.. toctree::
:caption: Appendix
genindex
源文件genindex.rst
:
.. This file is a placeholder and will be replaced
Index
#####
导航栏截图:
我正在使用 Sphinx 在 ReadTheDocs 上创建我的文档,使用他们的主题。构建过程会生成一个genindex.html文件,可以通过以下方式引用:
Link to the :ref:`genindex` page.
创建:
Link to the Index page.
我无法将 genindex
添加到我的目录树中,例如:
.. toctree:
foo
bar
genindex
因为它是一个自动生成的文件,在渲染时不存在。此外,Sphinx 期望 genindex 是一个名为 genindex.rst
.
如何将它添加到我的目录/导航中?
由于没有人发布更好的解决方案,我将写下我的解决方法作为可行的解决方案。
Sphinx 在构建根目录中将索引创建为 denindex.html
。它不能在 toctree
指令中引用,因为该指令引用了 ReST 文件。那么如何解决呢?
所以让我们创建一个 genindex.rst
文件并从 toctree
指令中引用它。这也会在构建根目录中创建一个 genindex.html
。所有 link 都按预期创建。 genindex.html
文件需要定义一个像 "Index" 这样的标题,用作导航栏中的 link 标题。
从 ReST 文件写入所有 HTML 文件后,Sphinx 生成其索引并覆盖 genindex.html
。
源文件:
源文件index.rst
:
.. toctree::
:caption: Introduction
chapter1
chapter2
.. toctree::
:caption: Main Documentation
chapter3
chapter4
.. toctree::
:caption: Appendix
genindex
源文件genindex.rst
:
.. This file is a placeholder and will be replaced
Index
#####
导航栏截图: