mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #2189: next sibling link has broken if the file was appeared twice or more
This commit is contained in:
parent
9fc83df2de
commit
222a51e0cf
@ -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:
|
||||
|
4
tests/roots/test-toctree-glob/bar/bar_1.rst
Normal file
4
tests/roots/test-toctree-glob/bar/bar_1.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Bar-1
|
||||
=====
|
||||
|
||||
bar
|
4
tests/roots/test-toctree-glob/bar/bar_2.rst
Normal file
4
tests/roots/test-toctree-glob/bar/bar_2.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Bar-2
|
||||
=====
|
||||
|
||||
bar
|
4
tests/roots/test-toctree-glob/bar/bar_3.rst
Normal file
4
tests/roots/test-toctree-glob/bar/bar_3.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Bar-3
|
||||
=====
|
||||
|
||||
bar
|
7
tests/roots/test-toctree-glob/bar/index.rst
Normal file
7
tests/roots/test-toctree-glob/bar/index.rst
Normal file
@ -0,0 +1,7 @@
|
||||
Bar
|
||||
===
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
*
|
4
tests/roots/test-toctree-glob/baz.rst
Normal file
4
tests/roots/test-toctree-glob/baz.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Baz
|
||||
===
|
||||
|
||||
baz
|
4
tests/roots/test-toctree-glob/conf.py
Normal file
4
tests/roots/test-toctree-glob/conf.py
Normal file
@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
||||
html_theme = 'classic'
|
4
tests/roots/test-toctree-glob/foo.rst
Normal file
4
tests/roots/test-toctree-glob/foo.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Foo
|
||||
===
|
||||
|
||||
foo
|
10
tests/roots/test-toctree-glob/index.rst
Normal file
10
tests/roots/test-toctree-glob/index.rst
Normal file
@ -0,0 +1,10 @@
|
||||
test-toctree-glob
|
||||
=================
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
foo
|
||||
bar/index
|
||||
bar/*
|
||||
baz
|
24
tests/test_toctree.py
Normal file
24
tests/test_toctree.py
Normal 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]
|
Loading…
Reference in New Issue
Block a user