首页 > 解决方案 > Toctree 激活侧边栏上的当前页面和主页

问题描述

de上没有问题,index.rst如下所示:

Sphinx RTD 文档主页

但是,当我转到另一个页面时,在我的情况下是annotation-module.rst,侧边栏会选择并同时显示indexannotation-module,如下所示:

Sphinx RTD 侧边栏显示两个菜单

但是,我只想激活注释模块页面并显示其子部分。

conf.py唯一的用途html_theme是通过查找READTHEDOCS如下环境变量:

if not on_rtd:  # only import and set the theme if we're building docs locally
    try:
        import sphinx_rtd_theme

        html_theme = "sphinx_rtd_theme"
        html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
    except Exception:
        pass

我的index.rst

Welcome to exceptive's documentation!
=====================================

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

   index
   annotation-module

Here I have some introductory text.

annotation-module.rst甚至不包括任何,我toctree只有它下面的部分。

那么,如何仅激活侧边栏上的当前文档部分?

Steve Piercy要求的文档源目录。


环境

标签: pythonpython-sphinxsidebarread-the-docstoctree

解决方案


所以,我有点解决了这个问题。问题出在sphinx-autobuild某种程度上,我在问题中没有提到。

make html每次我更新我的文档并使用node's提供它时,我都会简单地使用它http-server

还引用indexinindex.rst创建警告:

WARNING: self referenced toctree found. Ignored.

所以,indextoctree现在解决我的问题。


推荐阅读