Revert "Fix problem triggered by unconditional toctree call and empty toctree" (#507)

Fixes #374
This commit is contained in:
Aaron Carlisle 2021-03-11 09:59:21 -05:00 committed by GitHub
parent 894aef556e
commit de76c03824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 16 deletions

View File

@ -155,18 +155,12 @@
{%- block navigation %}
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="{{ _('Main') }}">
{%- block menu %}
{#-
The singlehtml builder doesn't handle this toctree call when the
toctree is empty. Skip building this for now.
#}
{%- if 'singlehtml' not in builder %}
{%- set global_toc = toctree(maxdepth=theme_navigation_depth|int,
collapse=theme_collapse_navigation|tobool,
includehidden=theme_includehidden|tobool,
titles_only=theme_titles_only|tobool) %}
{%- endif %}
{%- if global_toc %}
{{ global_toc }}
{%- set toctree = toctree(maxdepth=theme_navigation_depth|int,
collapse=theme_collapse_navigation|tobool,
includehidden=theme_includehidden|tobool,
titles_only=theme_titles_only|tobool) %}
{%- if toctree %}
{{ toctree }}
{%- else %}
<!-- Local TOC -->
<div class="local-toc">{{ toc }}</div>

View File

@ -30,12 +30,9 @@ def test_basic():
assert search in content
elif isinstance(app.builder, SingleFileHTMLBuilder):
search = (
'<div class="local-toc"><ul>\n'
'<ul>\n'
'<li class="toctree-l1">'
'<a class="reference internal" href="index.html#document-foo">foo</a>'
'<ul>\n'
'<li class="toctree-l2">'
'<a class="reference internal" href="index.html#document-bar">bar</a>'
'</li>\n'
'</ul>'
)