【问题标题】:Sphinx toctree in sidebar ONLY仅侧边栏中的 Sphinx 目录树
【发布时间】:2019-01-24 14:29:43
【问题描述】:

我是 Sphinx 的新手,并且一直在寻找这个问题的解决方案。

我的索引页面由 index.rst 组成,其中包含一个目录树。该页面在正文和侧边栏中显示 TOC。我只想在侧边栏上显示目录,而不是在每个页面正文中输入一些文本。特别是主要的“Welcome to My Place”,目前index.html和index.rst应该只是一段blurb而不是TOC。

我试过这个:

Welcome to My Place
==================

.. toctree::
   :hidden:
   :maxdepth: 2
   :caption: Contents:

但这会从页面和侧边栏中删除目录。 我怎样才能让它工作?

编辑: 这是它的显示方式,我希望 TOC 只出现在侧边栏中。 Screen shot

【问题讨论】:

标签: python-sphinx sidebar toctree


【解决方案1】:

您可以通过为 toctree 包含一个单独的文件并将 conf.py 中的变量 master_doc 指向该文件来做到这一点。


conf.py

# ...
master_doc = "contents"
# ...rest of the document

contents.rst

.. toctree::

   example

index.rst

# Landing Page
 Welcome!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-06
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    • 2015-02-24
    • 2017-05-29
    • 1970-01-01
    相关资源
    最近更新 更多