mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '1.7' into 5091_latex_curlybrace_in_index
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -29,6 +29,7 @@ Bugs fixed
|
||||
* #5019: autodoc: crashed by Form Feed Character
|
||||
* #5032: autodoc: loses the first staticmethod parameter for old styled classes
|
||||
* #5036: quickstart: Typing Ctrl-U clears the whole of line
|
||||
* #5066: html: "relations" sidebar is not shown by default
|
||||
* #5091: latex: curly braces in index entries are not handled correctly
|
||||
|
||||
Testing
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=python ../sphinx-build.py
|
||||
set SPHINXBUILD=python ../sphinx/cmd/build.py
|
||||
)
|
||||
set SOURCEDIR=.
|
||||
set BUILDDIR=_build
|
||||
|
||||
@@ -906,19 +906,27 @@ class StandaloneHTMLBuilder(Builder):
|
||||
def has_wildcard(pattern):
|
||||
# type: (unicode) -> bool
|
||||
return any(char in pattern for char in '*?[')
|
||||
sidebars = self.theme.get_config('theme', 'sidebars', None)
|
||||
sidebars = None
|
||||
matched = None
|
||||
customsidebar = None
|
||||
|
||||
# default sidebars settings for selected theme
|
||||
theme_default_sidebars = self.theme.get_config('theme', 'sidebars', None)
|
||||
if theme_default_sidebars:
|
||||
sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
|
||||
elif self.theme.name == 'alabaster':
|
||||
if self.theme.name == 'alabaster':
|
||||
# provide default settings for alabaster (for compatibility)
|
||||
# Note: this will be removed before Sphinx-2.0
|
||||
sidebars = ['about.html', 'navigation.html', 'relation.html',
|
||||
'searchbox.html', 'donate.html']
|
||||
try:
|
||||
# get default sidebars settings from alabaster (if defined)
|
||||
theme_default_sidebars = self.theme.config.get('theme', 'sidebars')
|
||||
if theme_default_sidebars:
|
||||
sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
|
||||
except Exception:
|
||||
# fallback to better default settings
|
||||
sidebars = ['about.html', 'navigation.html', 'relations.html',
|
||||
'searchbox.html', 'donate.html']
|
||||
else:
|
||||
theme_default_sidebars = self.theme.get_config('theme', 'sidebars', None)
|
||||
if theme_default_sidebars:
|
||||
sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
|
||||
|
||||
# user sidebar settings
|
||||
for pattern, patsidebars in iteritems(self.config.html_sidebars):
|
||||
|
||||
@@ -1230,21 +1230,50 @@ def test_html_remote_images(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic')
|
||||
def test_html_sidebar(app, status, warning):
|
||||
ctx = {}
|
||||
|
||||
# default for alabaster
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||
assert '<h3><a href="#">Table Of Contents</a></h3>' in result
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' in result
|
||||
assert '<h3>Navigation</h3>' in result
|
||||
assert '<h3>Related Topics</h3>' in result
|
||||
assert '<h3>This Page</h3>' in result
|
||||
assert '<h3>Quick search</h3>' in result
|
||||
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == ['about.html', 'navigation.html', 'relations.html',
|
||||
'searchbox.html', 'donate.html']
|
||||
|
||||
# only relations.html
|
||||
app.config.html_sidebars = {'**': ['relations.html']}
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||
assert '<h3>Navigation</h3>' not in result
|
||||
assert '<h3>Related Topics</h3>' in result
|
||||
assert '<h3>Quick search</h3>' not in result
|
||||
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == ['relations.html']
|
||||
|
||||
# no sidebars
|
||||
app.config.html_sidebars = {'**': []}
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||
assert '<h3><a href="#">Table Of Contents</a></h3>' not in result
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' not in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||
assert '<h3>Navigation</h3>' not in result
|
||||
assert '<h3>Related Topics</h3>' not in result
|
||||
assert '<h3>This Page</h3>' not in result
|
||||
assert '<h3>Quick search</h3>' not in result
|
||||
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fname,expect', flat_dict({
|
||||
'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),
|
||||
|
||||
Reference in New Issue
Block a user