Allow automatic toc to be disabled

In some cases, a user may want to disable the automatic table of
contents generation in the body of the page. This patch adds
a ``display_toc`` option into the theme options list that will
disable the automatic TOC in the documentation body.

Closes-Bug: 1613761

Change-Id: I508b46c5ba6a022ee4ad2687cb4e44ed449ca4fe
This commit is contained in:
Major Hayden 2016-08-16 10:10:37 -05:00
parent 70f6ed6a41
commit 59072440ab
3 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,4 @@
{%- if theme_sidebar_mode == 'toctree' %} {%- if theme_sidebar_mode == 'toctree' and theme_display_toc %}
{%- if display_toc %}
<h5><a href="{{ pathto(master_doc) }}">Contents</a></h5> <h5><a href="{{ pathto(master_doc) }}">Contents</a></h5>
{{ toc }} {{ toc }}
{%- endif %} {%- endif %}
{%- endif %}

View File

@ -6,3 +6,4 @@ pygments_style = native
[options] [options]
analytics_tracking_code = UA-17511903-1 analytics_tracking_code = UA-17511903-1
sidebar_mode = toctree sidebar_mode = toctree
display_toc = True

View File

@ -0,0 +1,14 @@
---
features:
- |
The automatic table of contents that appears in the body of the
documentation can be disabled by setting ``display_toc`` to ``False`` in
the ``html_theme_options`` option in ``conf.py``.
For example:
.. code-block:: python
html_theme_options = {
"display_toc": False,
}