Fix #2189: next sibling link has broken if the file was appeared twice or more

This commit is contained in:
Takeshi KOMIYA 2015-12-26 21:43:54 +09:00
parent 9fc83df2de
commit 222a51e0cf
10 changed files with 75 additions and 3 deletions

View File

@ -1987,9 +1987,16 @@ class BuildEnvironment:
# else the grandparent's sibling, if present, and so forth
for parname, parindex in parents:
parincs = getinc(parname)
if parincs and parindex + 1 < len(parincs):
next = parincs[parindex+1]
break
if parincs:
for parinc in parincs[parindex + 1:]:
if parinc in relations or parinc == docname:
pass
else:
next = parinc
break
if next:
break
# else it will stay None
# same for children
if includes:

View File

@ -0,0 +1,4 @@
Bar-1
=====
bar

View File

@ -0,0 +1,4 @@
Bar-2
=====
bar

View File

@ -0,0 +1,4 @@
Bar-3
=====
bar

View File

@ -0,0 +1,7 @@
Bar
===
.. toctree::
:glob:
*

View File

@ -0,0 +1,4 @@
Baz
===
baz

View File

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
master_doc = 'index'
html_theme = 'classic'

View File

@ -0,0 +1,4 @@
Foo
===
foo

View File

@ -0,0 +1,10 @@
test-toctree-glob
=================
.. toctree::
:glob:
foo
bar/index
bar/*
baz

24
tests/test_toctree.py Normal file
View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
test_toctree
~~~~~~~~~~~~
Test the HTML builder and check output against XPath.
:copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from util import with_app
@with_app(testroot='toctree-glob')
def test_relations(app, status, warning):
app.builder.build_all()
assert app.builder.relations['index'] == [None, None, 'foo']
assert app.builder.relations['foo'] == ['index', 'index', 'bar/index']
assert app.builder.relations['bar/index'] == ['index', 'foo', 'bar/bar_1']
assert app.builder.relations['bar/bar_1'] == ['bar/index', 'bar/index', 'bar/bar_2']
assert app.builder.relations['bar/bar_2'] == ['bar/index', 'bar/bar_1', 'bar/bar_3']
assert app.builder.relations['bar/bar_3'] == ['bar/index', 'bar/bar_2', 'baz']
assert app.builder.relations['baz'] == ['index', 'bar/bar_3', None]