How to hide the sidebar using Sphinx RTD theme when making htmlhelp

时间:2017-11-13 06:17:21

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

Is it possible to hide the sidebar when using Sphinx with the ReadTheDocs theme?

Extending the question a bit more, can I have it include the sidebar when issuing a command:

$ make html

and not include it issuing a command:

$ make htmlhelp

without altering code? Maybe add something in the layout.html.

3 个答案:

答案 0 :(得分:2)

First of all, it is poor form to ask two questions in one post. Next time, create a separate question.

For your first question, I am not sure what the option collapse_navigation actually does, but its name implies that it does what you seek. The default value is False, so toggle it to True and see what happens. See other Read the Docs theme configuration options.

For your second question, there are at least two methods.

You can use the -D option of sphinx-build and override settings in your conf.py.

You can have multiple conf.py files (named as you see fit), and use the -c option to select the appropriate file for the output you want.

答案 1 :(得分:1)

alabaster主题中,我可以通过将以下内容添加到我的conf.py文件中来删除目录/边栏:

html_theme_options = {
    # Disable showing the sidebar. Defaults to 'false'
    'nosidebar': True,
}

我在sphinx_rtd_theme中对此进行了测试,但没有成功。但是,我将其添加为答案,因为这可能对其他尝试删除其他主题中的侧边栏的人有所帮助(对我而言就是如此)。

答案 2 :(得分:0)

对于构建matlab文档(我相信它类似于HTMLHelp),我发现可以使用其他CSS隐藏侧边栏:

.wy-nav-side {
  display: none;
}

.wy-nav-content-wrap {
  margin-left: 0;
}

然后在conf.py文件中添加CSS文件:

html_static_path = ['_static']

html_css_files = [
    'css/matlabdoc.css',
]

这不会删除侧边栏,但至少将其隐藏。可能会有帮助。

浏览RTD主题,也可能会删除侧栏 通过更改search.html中的localtoc.htmlconf.py默认文件 通过使用html_sidebars = {}设置它们。