Fix: Combination of 'globaltoc.html' and hidden toctree cause exception. Closes #1157

This commit is contained in:
Takayuki Shimizukawa 2013-04-30 23:36:27 +09:00
parent 1006011528
commit 59d655c435
3 changed files with 19 additions and 2 deletions

View File

@ -9,6 +9,7 @@ Features added
Bugs fixed Bugs fixed
---------- ----------
* #1157: Combination of 'globaltoc.html' and hidden toctree cause exception.
* Fix: 'make gettext' cause UnicodeDecodeError when templates contain utf-8 * Fix: 'make gettext' cause UnicodeDecodeError when templates contain utf-8
encoded string. encoded string.

View File

@ -1049,7 +1049,8 @@ class BuildEnvironment:
for toctreenode in doctree.traverse(addnodes.toctree): for toctreenode in doctree.traverse(addnodes.toctree):
toctree = self.resolve_toctree(docname, builder, toctreenode, toctree = self.resolve_toctree(docname, builder, toctreenode,
prune=True, **kwds) prune=True, **kwds)
toctrees.append(toctree) if toctree:
toctrees.append(toctree)
if not toctrees: if not toctrees:
return None return None
result = toctrees[0] result = toctrees[0]

View File

@ -21,7 +21,7 @@ except ImportError:
pygments = None pygments = None
from sphinx import __version__ from sphinx import __version__
from util import test_root, remove_unicode_literals, gen_with_app from util import test_root, remove_unicode_literals, gen_with_app, with_app
from etree13 import ElementTree as ET from etree13 import ElementTree as ET
@ -344,3 +344,18 @@ def test_html(app):
yield check_xpath, etree, fname, path, check yield check_xpath, etree, fname, path, check
check_static_entries(app.builder.outdir) check_static_entries(app.builder.outdir)
@with_app(buildername='html', srcdir='(empty)',
confoverrides={'html_sidebars': {'*': ['globaltoc.html']}},
)
def test_html_with_globaltoc_and_hidden_toctree(app):
# issue #1157: combination of 'globaltoc.html' and hidden toctree cause
# exception.
(app.srcdir / 'contents.rst').write_text(
'\n.. toctree::'
'\n'
'\n.. toctree::'
'\n :hidden:'
'\n')
app.builder.build_all()