Commits

Takayuki Shimizukawa  committed 48a41f1

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

  • Participants
  • Parent commits 7391c56

Comments (0)

Files changed (3)

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

File sphinx/environment.py

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

File tests/test_build_html.py

     pygments = None
 
 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
 
 
             yield check_xpath, etree, fname, path, check
 
     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()
+