Display the toctree conditionally

The `singlehtml` builder for sphinx doesn't produce a toctree, and was throwing
an exception on these builds. This makes use of the `display_toc` context
variable, used back to at least `sphinx==1.1`.
This commit is contained in:
Anthony Johnson 2017-03-03 11:38:10 -08:00
parent 20747b6551
commit 398636c366
No known key found for this signature in database
GPG Key ID: C5C79D82F922D604

View File

@ -121,12 +121,14 @@
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
{% block menu %}
{% set toctree = toctree(maxdepth=theme_navigation_depth|int, collapse=theme_collapse_navigation, includehidden=True) %}
{% if toctree %}
{{ toctree }}
{% else %}
<!-- Local TOC -->
<div class="local-toc">{{ toc }}</div>
{% if display_toc %}
{% set toctree = toctree(maxdepth=theme_navigation_depth|int, collapse=theme_collapse_navigation, includehidden=True) %}
{% if toctree %}
{{ toctree }}
{% else %}
<!-- Local TOC -->
<div class="local-toc">{{ toc }}</div>
{% endif %}
{% endif %}
{% endblock %}
</div>