如何将目录(TOC)从index.rst链接到README.rst?

发布于 2025-01-10 06:31:49 字数 325 浏览 3 评论 0原文

我的 docs/ 文件夹中有一些 sphinx 文档。在那里我有一些手写的和从代码(Python)动态生成的文档的典型结构。我希望为打开存储库的人提供一个非常简单的 README.rst 。在那个 README.rst 中,我希望显示 Sphinx 文档的整个目录。它看起来像这样:


About section etc.
==================

blah blah blah

For more check out the documentation

.. here the automatically imported TOC tree

我该怎么做?

I have some sphinx documentation inside my docs/ folder. There I have a typical structure of some handwritten and dynamically generated documentation from code (Python). I would like to have a very simple README.rst for people opening the repo. In that README.rst I would like to have the whole TOC displayed of the Sphinx documentation. It would look something like that:


About section etc.
==================

blah blah blah

For more check out the documentation

.. here the automatically imported TOC tree

How can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩物 2025-01-17 06:31:50

对于 Sphinx 中的目录,您应该使用 toctree

.. toctree::
   :maxdepth: 2

   doc1
   doc2
   etc..

如果您生成所有文档,那么最好使用“globbing”自动包含所有内容:

.. toctree::
   :maxdepth: 2
   :glob:

   *

有关更多详细信息,请查看 关于 toc 的文档


这是一个cython 文档 中的示例

在此处输入图像描述

这是一个index.rst 文件
输入图片此处描述

For a table of contents in Sphinx you should use toctree:

.. toctree::
   :maxdepth: 2

   doc1
   doc2
   etc..

And if you generate all docs, then it's nice to use "globbing" to include everything automatically:

.. toctree::
   :maxdepth: 2
   :glob:

   *

For more details look into the docs about toc


here's an example in cython docs

enter image description here

and here's an index.rst file
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文