【问题标题】:Toctree Activates Current Page and Main Page on SidebarToctree 激活侧边栏上的当前页面和主页
【发布时间】:2018-07-22 08:06:16
【问题描述】:

deindex.rst上没有问题,如下图:

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

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

我的conf.py 仅通过查找READTHEDOCS 环境变量来使用html_theme,如下所示:

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,我只有它下面的部分。

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

HereSteve Piercy要求的文档的源目录。


环境

  • Python 3.5
  • 狮身人面像 1.7.6
  • sphinx-rtd-theme 0.4.0

【问题讨论】:

  • 请发布一个MCVE,最好是一个repo,但至少是你的文档目录树和conf.pyindex.rstannotation-module.rst的完整内容。
  • 按要求添加了相关分支的目录。

标签: python python-sphinx sidebar read-the-docs toctree


【解决方案1】:

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

每次我更新我的文档并使用nodehttp-server 提供它时,我都会使用make html

同时在 index.rst 中引用 index 会产生警告:

WARNING: self referenced toctree found. Ignored.

所以,从 toctree 中删除 index 暂时解决了我的问题。

【讨论】:

    【解决方案2】:

    我尝试将index 替换为self

    示例(index.rst):

    Welcome to exceptive's documentation!
    =====================================
    
    .. toctree::
       :maxdepth: 2
       :caption: Contents:
    
       self
       annotation-module
    
    Here I have some introductory text.
    
     
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-29
      • 1970-01-01
      • 1970-01-01
      • 2014-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多