Merge branch '5.x'

# Conflicts:
#	CHANGES
#	doc/conf.py
#	sphinx/__init__.py
#	sphinx/builders/html/__init__.py
#	sphinx/domains/python.py
#	tests/test_build_html.py
This commit is contained in:
Adam Turner
2022-09-25 21:36:30 +01:00
36 changed files with 442 additions and 273 deletions

View File

@@ -0,0 +1 @@
const DOCUMENTATION_OPTIONS = {};

View File

@@ -1,5 +1,3 @@
const DOCUMENTATION_OPTIONS = {};
describe('highlightText', function() {
const cyrillicTerm = 'шеллы';

View File

@@ -0,0 +1,4 @@
API
===
.. automodule:: example_module

View File

@@ -0,0 +1,5 @@
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
extensions = ['sphinx.ext.autodoc']

View File

@@ -0,0 +1,2 @@
def example_function():
return 42

View File

@@ -0,0 +1,3 @@
.. toctree::
api

View File

@@ -131,6 +131,16 @@ def test_html4_output(app, status, warning):
app.build()
def test_html4_deprecation(make_app, tempdir):
(tempdir / 'conf.py').write_text('', encoding='utf-8')
app = make_app(
buildername='html',
srcdir=tempdir,
confoverrides={'html4_writer': True},
)
assert 'HTML 4 output is deprecated and will be removed' in app._warning.getvalue()
@pytest.mark.parametrize("fname,expect", flat_dict({
'images.html': [
(".//img[@src='_images/img.png']", ''),
@@ -1222,7 +1232,8 @@ def test_assets_order(app):
# js_files
expected = ['_static/early.js',
'_static/doctools.js', 'https://example.com/script.js', '_static/normal.js',
'_static/doctools.js', '_static/sphinx_highlight.js',
'https://example.com/script.js', '_static/normal.js',
'_static/late.js', '_static/js/custom.js', '_static/lazy.js']
pattern = '.*'.join('src="%s"' % f for f in expected)
assert re.search(pattern, content, re.S)

View File

@@ -0,0 +1,10 @@
"""Tests for ``record_dependencies``."""
import pytest
@pytest.mark.sphinx('html', testroot='environment-record-dependencies')
def test_record_dependencies_cleared(app):
app.builder.read()
assert app.env.dependencies['index'] == set()
assert app.env.dependencies['api'] == {'example_module.py'}

View File

@@ -29,16 +29,16 @@ def test_highlight_language_default(app, status, warning):
app.build()
doctree = app.env.get_doctree('doctest')
for node in doctree.findall(nodes.literal_block):
assert node['language'] in ('python3', 'pycon3', 'none')
assert node['language'] in {'python', 'pycon', 'none'}
@pytest.mark.sphinx('dummy', testroot='ext-doctest',
confoverrides={'highlight_language': 'python'})
def test_highlight_language_python2(app, status, warning):
def test_highlight_language_python3(app, status, warning):
app.build()
doctree = app.env.get_doctree('doctest')
for node in doctree.findall(nodes.literal_block):
assert node['language'] in ('python', 'pycon', 'none')
assert node['language'] in {'python', 'pycon', 'none'}
def test_is_allowed_version():

View File

@@ -81,14 +81,23 @@ def test_default_highlight(logger):
ret = bridge.highlight_block('reST ``like`` text', 'default')
assert ret == '<div class="highlight"><pre><span></span>reST ``like`` text\n</pre></div>\n'
# python3: highlights as python3
ret = bridge.highlight_block('print "Hello sphinx world"', 'python3')
assert ret == ('<div class="highlight"><pre><span></span><span class="nb">print</span> '
'<span class="s2">&quot;Hello sphinx world&quot;</span>\n</pre></div>\n')
# python: highlights as python3
ret = bridge.highlight_block('print("Hello sphinx world")', 'python')
assert ret == ('<div class="highlight"><pre><span></span><span class="nb">print</span>'
'<span class="p">(</span>'
'<span class="s2">&quot;Hello sphinx world&quot;</span>'
'<span class="p">)</span>\n</pre></div>\n')
# python3: raises error if highlighting failed
ret = bridge.highlight_block('reST ``like`` text', 'python3')
# python3: highlights as python3
ret = bridge.highlight_block('print("Hello sphinx world")', 'python3')
assert ret == ('<div class="highlight"><pre><span></span><span class="nb">print</span>'
'<span class="p">(</span>'
'<span class="s2">&quot;Hello sphinx world&quot;</span>'
'<span class="p">)</span>\n</pre></div>\n')
# python: raises error if highlighting failed
ret = bridge.highlight_block('reST ``like`` text', 'python')
logger.warning.assert_called_with('Could not lex literal_block as "%s". '
'Highlighting skipped.', 'python3',
'Highlighting skipped.', 'python',
type='misc', subtype='highlighting_failure',
location=None)