diff --git a/sphinx/environment.py b/sphinx/environment.py index a7ce8d5a6..23a138e22 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -1229,8 +1229,9 @@ class BuildEnvironment: anchorname=anchorname, *nodetext) para = addnodes.compact_paragraph('', '', reference) item = nodes.list_item('', para) + sub_item = build_toc(sectionnode, depth + 1) if maxdepth == 0 or depth < maxdepth: - item += build_toc(sectionnode, depth+1) + item += sub_item entries.append(item) if entries: return nodes.bullet_list('', *entries)