Skip to content

Commit 8e258c0

Browse files
committed
Merge branch '3.5.x' into 3.x
2 parents 3ac1c60 + 64b69ad commit 8e258c0

File tree

7 files changed

+196
-166
lines changed

7 files changed

+196
-166
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
coverage: "--cov ./ --cov-append --cov-config setup.cfg"
3030
- name: py310-dev
3131
python: 3.10-dev
32-
docutils: du16
32+
docutils: du17
3333
os: ubuntu-latest # required
3434
env:
3535
PYTEST_ADDOPTS: ${{ matrix.coverage }}

tests/test_build_html.py

Lines changed: 71 additions & 117 deletions
Large diffs are not rendered by default.

tests/test_ext_autosummary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_mangle_signature():
7474

7575

7676
def test_extract_summary(capsys):
77-
settings = Mock(language_code='',
77+
settings = Mock(language_code='en',
7878
id_prefix='',
7979
auto_id_prefix='',
8080
pep_reference=False,

tests/test_ext_graphviz.py

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import pytest
1414

1515
from sphinx.ext.graphviz import ClickableMapDefinition
16+
from sphinx.util import docutils
1617

1718

1819
@pytest.mark.sphinx('html', testroot='ext-graphviz')
@@ -21,9 +22,15 @@ def test_graphviz_png_html(app, status, warning):
2122
app.builder.build_all()
2223

2324
content = (app.outdir / 'index.html').read_text()
24-
html = (r'<div class="figure align-default" .*?>\s*'
25-
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
26-
r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>')
25+
if docutils.__version_info__ < (0, 17):
26+
html = (r'<div class="figure align-default" .*?>\s*'
27+
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
28+
r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>')
29+
else:
30+
html = (r'<figure class="align-default" .*?>\s*'
31+
r'<div class="graphviz"><img .*?/></div>\s*<figcaption>\s*'
32+
r'<p><span class="caption-text">caption of graph</span>.*</p>\s*'
33+
r'</figcaption>\s*</figure>')
2734
assert re.search(html, content, re.S)
2835

2936
html = 'Hello <div class="graphviz"><img .*?/></div>\n graphviz world'
@@ -33,9 +40,15 @@ def test_graphviz_png_html(app, status, warning):
3340
'class="graphviz neato-graph" />')
3441
assert re.search(html, content, re.S)
3542

36-
html = (r'<div class="figure align-right" .*?>\s*'
37-
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
38-
r'<span class="caption-text">on <em>right</em></span>.*</p>\s*</div>')
43+
if docutils.__version_info__ < (0, 17):
44+
html = (r'<div class="figure align-right" .*?>\s*'
45+
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
46+
r'<span class="caption-text">on <em>right</em></span>.*</p>\s*</div>')
47+
else:
48+
html = (r'<figure class="align-right" .*?>\s*'
49+
r'<div class="graphviz"><img .*?/></div>\s*<figcaption>\s*'
50+
r'<p><span class="caption-text">on <em>right</em></span>.*</p>\s*'
51+
r'</figcaption>\s*</figure>')
3952
assert re.search(html, content, re.S)
4053

4154
html = (r'<div align=\"center\" class=\"align-center\">'
@@ -53,28 +66,50 @@ def test_graphviz_svg_html(app, status, warning):
5366

5467
content = (app.outdir / 'index.html').read_text()
5568

56-
html = (r'<div class=\"figure align-default\" .*?>\n'
57-
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
58-
r'\s*<p class=\"warning\">digraph foo {\n'
59-
r'bar -&gt; baz\n'
60-
r'}</p></object></div>\n'
61-
r'<p class=\"caption\"><span class=\"caption-text\">'
62-
r'caption of graph</span>.*</p>\n</div>')
69+
if docutils.__version_info__ < (0, 17):
70+
html = (r'<div class=\"figure align-default\" .*?>\n'
71+
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
72+
r'\s*<p class=\"warning\">digraph foo {\n'
73+
r'bar -&gt; baz\n'
74+
r'}</p></object></div>\n'
75+
r'<p class=\"caption\"><span class=\"caption-text\">'
76+
r'caption of graph</span>.*</p>\n</div>')
77+
else:
78+
html = (r'<figure class=\"align-default\" .*?>\n'
79+
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
80+
r'\s*<p class=\"warning\">digraph foo {\n'
81+
r'bar -&gt; baz\n'
82+
r'}</p></object></div>\n'
83+
r'<figcaption>\n'
84+
r'<p><span class=\"caption-text\">caption of graph</span>.*</p>\n'
85+
r'</figcaption>\n'
86+
r'</figure>')
6387
assert re.search(html, content, re.S)
6488

6589
html = (r'Hello <div class="graphviz"><object.*>\n'
6690
r'\s*<p class=\"warning\">graph</p></object></div>\n'
6791
r' graphviz world')
6892
assert re.search(html, content, re.S)
6993

70-
html = (r'<div class=\"figure align-right\" .*\>\n'
71-
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
72-
r'\s*<p class=\"warning\">digraph bar {\n'
73-
r'foo -&gt; bar\n'
74-
r'}</p></object></div>\n'
75-
r'<p class=\"caption\"><span class=\"caption-text\">'
76-
r'on <em>right</em></span>.*</p>\n'
77-
r'</div>')
94+
if docutils.__version_info__ < (0, 17):
95+
html = (r'<div class=\"figure align-right\" .*\>\n'
96+
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
97+
r'\s*<p class=\"warning\">digraph bar {\n'
98+
r'foo -&gt; bar\n'
99+
r'}</p></object></div>\n'
100+
r'<p class=\"caption\"><span class=\"caption-text\">'
101+
r'on <em>right</em></span>.*</p>\n'
102+
r'</div>')
103+
else:
104+
html = (r'<figure class=\"align-right\" .*\>\n'
105+
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
106+
r'\s*<p class=\"warning\">digraph bar {\n'
107+
r'foo -&gt; bar\n'
108+
r'}</p></object></div>\n'
109+
r'<figcaption>\n'
110+
r'<p><span class=\"caption-text\">on <em>right</em></span>.*</p>\n'
111+
r'</figcaption>\n'
112+
r'</figure>')
78113
assert re.search(html, content, re.S)
79114

80115
html = (r'<div align=\"center\" class=\"align-center\">'

tests/test_ext_inheritance_diagram.py

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from sphinx.ext.inheritance_diagram import (InheritanceDiagram, InheritanceException,
1818
import_classes)
19+
from sphinx.util import docutils
1920

2021

2122
@pytest.mark.sphinx(buildername="html", testroot="inheritance")
@@ -147,12 +148,20 @@ def test_inheritance_diagram_png_html(app, status, warning):
147148

148149
content = (app.outdir / 'index.html').read_text()
149150

150-
pattern = ('<div class="figure align-default" id="id1">\n'
151-
'<div class="graphviz">'
152-
'<img src="_images/inheritance-\\w+.png" alt="Inheritance diagram of test.Foo" '
153-
'class="inheritance graphviz" /></div>\n<p class="caption">'
154-
'<span class="caption-text">Test Foo!</span><a class="headerlink" href="#id1" '
155-
'title="Permalink to this image">\xb6</a></p>')
151+
if docutils.__version_info__ < (0, 17):
152+
pattern = ('<div class="figure align-default" id="id1">\n'
153+
'<div class="graphviz">'
154+
'<img src="_images/inheritance-\\w+.png" alt="Inheritance diagram of test.Foo" '
155+
'class="inheritance graphviz" /></div>\n<p class="caption">'
156+
'<span class="caption-text">Test Foo!</span><a class="headerlink" href="#id1" '
157+
'title="Permalink to this image">\xb6</a></p>\n</div>\n')
158+
else:
159+
pattern = ('<figure class="align-default" id="id1">\n'
160+
'<div class="graphviz">'
161+
'<img src="_images/inheritance-\\w+.png" alt="Inheritance diagram of test.Foo" '
162+
'class="inheritance graphviz" /></div>\n<figcaption>\n<p>'
163+
'<span class="caption-text">Test Foo!</span><a class="headerlink" href="#id1" '
164+
'title="Permalink to this image">\xb6</a></p>\n</figcaption>\n</figure>\n')
156165
assert re.search(pattern, content, re.M)
157166

158167

@@ -164,14 +173,25 @@ def test_inheritance_diagram_svg_html(app, status, warning):
164173

165174
content = (app.outdir / 'index.html').read_text()
166175

167-
pattern = ('<div class="figure align-default" id="id1">\n'
168-
'<div class="graphviz">'
169-
'<object data="_images/inheritance-\\w+.svg" '
170-
'type="image/svg\\+xml" class="inheritance graphviz">\n'
171-
'<p class=\"warning\">Inheritance diagram of test.Foo</p>'
172-
'</object></div>\n<p class="caption"><span class="caption-text">'
173-
'Test Foo!</span><a class="headerlink" href="#id1" '
174-
'title="Permalink to this image">\xb6</a></p>')
176+
if docutils.__version_info__ < (0, 17):
177+
pattern = ('<div class="figure align-default" id="id1">\n'
178+
'<div class="graphviz">'
179+
'<object data="_images/inheritance-\\w+.svg" '
180+
'type="image/svg\\+xml" class="inheritance graphviz">\n'
181+
'<p class=\"warning\">Inheritance diagram of test.Foo</p>'
182+
'</object></div>\n<p class="caption"><span class="caption-text">'
183+
'Test Foo!</span><a class="headerlink" href="#id1" '
184+
'title="Permalink to this image">\xb6</a></p>\n</div>\n')
185+
else:
186+
pattern = ('<figure class="align-default" id="id1">\n'
187+
'<div class="graphviz">'
188+
'<object data="_images/inheritance-\\w+.svg" '
189+
'type="image/svg\\+xml" class="inheritance graphviz">\n'
190+
'<p class=\"warning\">Inheritance diagram of test.Foo</p>'
191+
'</object></div>\n<figcaption>\n<p><span class="caption-text">'
192+
'Test Foo!</span><a class="headerlink" href="#id1" '
193+
'title="Permalink to this image">\xb6</a></p>\n</figcaption>\n</figure>\n')
194+
175195
assert re.search(pattern, content, re.M)
176196

177197

@@ -204,12 +224,20 @@ def test_inheritance_diagram_latex_alias(app, status, warning):
204224

205225
content = (app.outdir / 'index.html').read_text()
206226

207-
pattern = ('<div class="figure align-default" id="id1">\n'
208-
'<div class="graphviz">'
209-
'<img src="_images/inheritance-\\w+.png" alt="Inheritance diagram of test.Foo" '
210-
'class="inheritance graphviz" /></div>\n<p class="caption">'
211-
'<span class="caption-text">Test Foo!</span><a class="headerlink" href="#id1" '
212-
'title="Permalink to this image">\xb6</a></p>')
227+
if docutils.__version_info__ < (0, 17):
228+
pattern = ('<div class="figure align-default" id="id1">\n'
229+
'<div class="graphviz">'
230+
'<img src="_images/inheritance-\\w+.png" alt="Inheritance diagram of test.Foo" '
231+
'class="inheritance graphviz" /></div>\n<p class="caption">'
232+
'<span class="caption-text">Test Foo!</span><a class="headerlink" href="#id1" '
233+
'title="Permalink to this image">\xb6</a></p>\n</div>\n')
234+
else:
235+
pattern = ('<figure class="align-default" id="id1">\n'
236+
'<div class="graphviz">'
237+
'<img src="_images/inheritance-\\w+.png" alt="Inheritance diagram of test.Foo" '
238+
'class="inheritance graphviz" /></div>\n<figcaption>\n<p>'
239+
'<span class="caption-text">Test Foo!</span><a class="headerlink" href="#id1" '
240+
'title="Permalink to this image">\xb6</a></p>\n</figcaption>\n</figure>\n')
213241
assert re.search(pattern, content, re.M)
214242

215243

tests/test_intl.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from sphinx import locale
2121
from sphinx.testing.util import (assert_node, assert_not_re_search, assert_re_search,
2222
assert_startswith, etree_parse, path, strip_escseq)
23+
from sphinx.util import docutils
2324

2425
sphinx_intl = pytest.mark.sphinx(
2526
testroot='intl',
@@ -621,8 +622,11 @@ def test_html_meta(app):
621622
assert expected_expr in result
622623
expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />'
623624
assert expected_expr in result
624-
expected_expr = '<p class="caption"><span class="caption-text">HIDDEN TOC</span></p>'
625-
assert expected_expr in result
625+
if docutils.__version_info__ < (0, 17):
626+
expected_expr = '<p class="caption"><span class="caption-text">HIDDEN TOC</span></p>'
627+
assert expected_expr in result
628+
else:
629+
expected_expr = '<p><span class="caption-text">HIDDEN TOC</span></p>'
626630

627631

628632
@sphinx_intl
@@ -1083,8 +1087,12 @@ def test_additional_targets_should_not_be_translated(app):
10831087
result = (app.outdir / 'raw.html').read_text()
10841088

10851089
# raw block should not be translated
1086-
expected_expr = """<iframe src="http://sphinx-doc.org"></iframe></div>"""
1087-
assert_count(expected_expr, result, 1)
1090+
if docutils.__version_info__ < (0, 17):
1091+
expected_expr = """<iframe src="http://sphinx-doc.org"></iframe></div>"""
1092+
assert_count(expected_expr, result, 1)
1093+
else:
1094+
expected_expr = """<iframe src="http://sphinx-doc.org"></iframe></section>"""
1095+
assert_count(expected_expr, result, 1)
10881096

10891097
# [figure.txt]
10901098

@@ -1157,8 +1165,12 @@ def test_additional_targets_should_be_translated(app):
11571165
result = (app.outdir / 'raw.html').read_text()
11581166

11591167
# raw block should be translated
1160-
expected_expr = """<iframe src="HTTP://SPHINX-DOC.ORG"></iframe></div>"""
1161-
assert_count(expected_expr, result, 1)
1168+
if docutils.__version_info__ < (0, 17):
1169+
expected_expr = """<iframe src="HTTP://SPHINX-DOC.ORG"></iframe></div>"""
1170+
assert_count(expected_expr, result, 1)
1171+
else:
1172+
expected_expr = """<iframe src="HTTP://SPHINX-DOC.ORG"></iframe></section>"""
1173+
assert_count(expected_expr, result, 1)
11621174

11631175
# [figure.txt]
11641176

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ deps =
2222
du14: docutils==0.14
2323
du15: docutils==0.15
2424
du16: docutils==0.16
25+
du17: docutils==0.17
2526
extras =
2627
test
2728
setenv =

0 commit comments

Comments
 (0)