Set side bar content to be configurable

Sometimes (e.g. for the api-ref pages) the TOC should be in the side bar.
This allows this to be set as a theme option, but defaulting to
current behaviour - the new TOC will only be set
if a project sets the "sidebar_mode" option to "toc".

Change-Id: I9b93b671d4c32f5b237b0d79ae2be39059402d72
This commit is contained in:
Graham Hayes 2016-05-29 00:00:12 +02:00
parent c8ccaa796c
commit 7388b01c15
3 changed files with 7 additions and 0 deletions

View File

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

View File

@ -25,7 +25,11 @@
<div class="docs-sidebar-toc">
<div class="docs-sidebar-section" id="table-of-contents">
<a href="{{ pathto(master_doc) }}" class="docs-sidebar-section-title"><h4>{{ _('Contents') }}</h4></a>
{%- if theme_sidebar_mode == 'toc' %}
{{ toc }}
{%- elif theme_sidebar_mode == 'toctree' %}
{{ toctree(maxdepth=2) }}
{%- endif %}
</div>
</div>
</div>

View File

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