首页 > 解决方案 > 狮身人面像雪花石膏主题目录未显示在所有页面中

问题描述

我试图让 TOC 出现在我的所有页面中。我的设置非常简单。在 index.rst 中,我有

Installation
============

Scripting
=========


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

class ASAT
""""""""""
.. toctree::
    :maxdepth: 2

    asat

    more class ...

在其他页面中,我有:

class asat.SomeClass
"""""""""""""""""""""
.. autoclass:: modeule.SomeClass
    :members:

    .. automethod:: __init__

为了让 TOC 出现,我改为conf.py反映:

html_sidebars = {
    '**': [
        'globaltoc.html',
        'relations.html',
        'searchbox.html'
    ]
}

但这样做时,index.rst任何 TOC 中都不会出现任何嵌套内容。这是它的截图:

伊姆古尔

如何从雪花石膏中获取原始/正常 TOC 以显示在我的所有页面中?

标签: python-sphinxsidebarnavigationbartoctree

解决方案


根据安装文档,您需要添加navigation.html到设置中。

html_sidebars = {
    '**': [
        'about.html',
        'navigation.html',
        'relations.html',
        'searchbox.html',
        'donate.html',
    ]
}

如果您使用的是 Alabaster 的变体,请查阅他们的文档。

编辑:

我刚刚注意到您的 reStructuredText 语法不正确。您需要缩进toctree.

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

推荐阅读