mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
1
tests/js/documentation_options.js
Normal file
1
tests/js/documentation_options.js
Normal file
@@ -0,0 +1 @@
|
||||
const DOCUMENTATION_OPTIONS = {};
|
||||
@@ -1,5 +1,3 @@
|
||||
const DOCUMENTATION_OPTIONS = {};
|
||||
|
||||
describe('highlightText', function() {
|
||||
|
||||
const cyrillicTerm = 'шеллы';
|
||||
4
tests/roots/test-environment-record-dependencies/api.rst
Normal file
4
tests/roots/test-environment-record-dependencies/api.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
API
|
||||
===
|
||||
|
||||
.. automodule:: example_module
|
||||
5
tests/roots/test-environment-record-dependencies/conf.py
Normal file
5
tests/roots/test-environment-record-dependencies/conf.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
extensions = ['sphinx.ext.autodoc']
|
||||
@@ -0,0 +1,2 @@
|
||||
def example_function():
|
||||
return 42
|
||||
@@ -0,0 +1,3 @@
|
||||
.. toctree::
|
||||
|
||||
api
|
||||
@@ -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)
|
||||
|
||||
10
tests/test_environment_record_dependencies.py
Normal file
10
tests/test_environment_record_dependencies.py
Normal 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'}
|
||||
@@ -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():
|
||||
|
||||
@@ -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">"Hello sphinx world"</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">"Hello sphinx world"</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">"Hello sphinx world"</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)
|
||||
|
||||
Reference in New Issue
Block a user