Skip to content

Commit d307de2

Browse files
authored
Docs: update sphinx (#11711)
We were pinning sphinx because of readthedocs/sphinx-multiproject#9 but that's solved now.
1 parent 02d38e4 commit d307de2

File tree

7 files changed

+119
-34
lines changed

7 files changed

+119
-34
lines changed

readthedocs/embed/v3/tests/test_external_pages.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
from unittest import mock
2+
13
import docutils
24
import pytest
35
import sphinx
46
from django.core.cache import cache
57
from django.urls import reverse
68
from packaging.version import Version
79

8-
from .utils import get_anchor_link_title, srcdir
10+
from .utils import compare_content_without_blank_lines, get_anchor_link_title, srcdir
911

1012

1113
@pytest.mark.django_db
@@ -40,16 +42,49 @@ def test_default_main_section(self, app, client, requests_mock):
4042
# The output is different because docutils is outputting this,
4143
# and we're not sanitizing it, but just passing it through.
4244
if Version(docutils.__version__) >= Version("0.17"):
43-
content = f'<div class="body" role="main">\n \n <section id="title">\n<h1>Title<a class="headerlink" href="https://docs.project.com#title" title="{title}">¶</a></h1>\n<p>This is an example page used to test EmbedAPI parsing features.</p>\n<section id="sub-title">\n<h2>Sub-title<a class="headerlink" href="https://docs.project.com#sub-title" title="{title}">¶</a></h2>\n<p>This is a reference to <a class="reference internal" href="https://docs.project.com#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>\n</section>\n<section id="manual-reference-section">\n<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://docs.project.com#manual-reference-section" title="{title}">¶</a></h2>\n<p>This is a reference to a manual reference <a class="reference internal" href="https://docs.project.com#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>\n</section>\n</section>\n\n\n </div>'
45+
content = f"""
46+
<div class="body" role="main">
47+
<section id="title">
48+
<h1>Title<a class="headerlink" href="https://docs.project.com#title" title="{title}">¶</a></h1>
49+
<p>This is an example page used to test EmbedAPI parsing features.</p>
50+
<section id="sub-title">
51+
<h2>Sub-title<a class="headerlink" href="https://docs.project.com#sub-title" title="{title}">¶</a></h2>
52+
<p>This is a reference to <a class="reference internal" href="https://docs.project.com#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>
53+
</section>
54+
<section id="manual-reference-section">
55+
<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://docs.project.com#manual-reference-section" title="{title}">¶</a></h2>
56+
<p>This is a reference to a manual reference <a class="reference internal" href="https://docs.project.com#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>
57+
</section>
58+
</section>
59+
<div class="clearer"></div>
60+
</div>
61+
"""
4462
else:
45-
content = f'<div class="body" role="main">\n \n <div class="section" id="title">\n<h1>Title<a class="headerlink" href="https://docs.project.com#title" title="{title}">¶</a></h1>\n<p>This is an example page used to test EmbedAPI parsing features.</p>\n<div class="section" id="sub-title">\n<h2>Sub-title<a class="headerlink" href="https://docs.project.com#sub-title" title="{title}">¶</a></h2>\n<p>This is a reference to <a class="reference internal" href="https://docs.project.com#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>\n</div>\n<div class="section" id="manual-reference-section">\n<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://docs.project.com#manual-reference-section" title="{title}">¶</a></h2>\n<p>This is a reference to a manual reference <a class="reference internal" href="https://docs.project.com#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>\n</div>\n</div>\n\n\n </div>'
46-
47-
assert response.json() == {
63+
content = """
64+
<div class="body" role="main">
65+
<div class="section" id="title">
66+
<h1>Title<a class="headerlink" href="https://docs.project.com#title" title="{title}">¶</a></h1>
67+
<p>This is an example page used to test EmbedAPI parsing features.</p>
68+
<div class="section" id="sub-title">
69+
<h2>Sub-title<a class="headerlink" href="https://docs.project.com#sub-title" title="{title}">¶</a></h2>
70+
<p>This is a reference to <a class="reference internal" href="https://docs.project.com#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>
71+
</div>
72+
<div class="section" id="manual-reference-section">
73+
<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://docs.project.com#manual-reference-section" title="{title}">¶</a></h2>
74+
<p>This is a reference to a manual reference <a class="reference internal" href="https://docs.project.com#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>
75+
</div>
76+
</div>
77+
</div>
78+
"""
79+
80+
json_response = response.json()
81+
assert json_response == {
4882
"url": "https://docs.project.com",
4983
"fragment": None,
50-
"content": content,
84+
"content": mock.ANY,
5185
"external": True,
5286
}
87+
compare_content_without_blank_lines(json_response["content"], content)
5388

5489
@pytest.mark.sphinx("html", srcdir=srcdir, freshenv=True)
5590
def test_specific_identifier(self, app, client, requests_mock):

readthedocs/embed/v3/tests/test_internal_pages.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from readthedocs.subscriptions.constants import TYPE_EMBED_API
1313
from readthedocs.subscriptions.products import RTDProductFeature
1414

15-
from .utils import get_anchor_link_title, srcdir
15+
from .utils import compare_content_without_blank_lines, get_anchor_link_title, srcdir
1616

1717

1818
@pytest.mark.django_db
@@ -64,16 +64,49 @@ def test_default_main_section(self, storage_exists, storage_open, app, client):
6464

6565
# Note the difference between `<section>` and `<div class="section">`
6666
if Version(docutils.__version__) >= Version("0.17"):
67-
content = f'<div class="body" role="main">\n \n <section id="title">\n<h1>Title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#title" title="{title}">¶</a></h1>\n<p>This is an example page used to test EmbedAPI parsing features.</p>\n<section id="sub-title">\n<h2>Sub-title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#sub-title" title="{title}">¶</a></h2>\n<p>This is a reference to <a class="reference internal" href="https://project.readthedocs.io/en/latest/#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>\n</section>\n<section id="manual-reference-section">\n<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://project.readthedocs.io/en/latest/#manual-reference-section" title="{title}">¶</a></h2>\n<p>This is a reference to a manual reference <a class="reference internal" href="https://project.readthedocs.io/en/latest/#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>\n</section>\n</section>\n\n\n </div>'
67+
content = f"""
68+
<div class="body" role="main">
69+
<section id="title">
70+
<h1>Title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#title" title="{title}">¶</a></h1>
71+
<p>This is an example page used to test EmbedAPI parsing features.</p>
72+
<section id="sub-title">
73+
<h2>Sub-title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#sub-title" title="{title}">¶</a></h2>
74+
<p>This is a reference to <a class="reference internal" href="https://project.readthedocs.io/en/latest/#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>
75+
</section>
76+
<section id="manual-reference-section">
77+
<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://project.readthedocs.io/en/latest/#manual-reference-section" title="{title}">¶</a></h2>
78+
<p>This is a reference to a manual reference <a class="reference internal" href="https://project.readthedocs.io/en/latest/#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>
79+
</section>
80+
</section>
81+
<div class="clearer"></div>
82+
</div>
83+
"""
6884
else:
69-
content = f'<div class="body" role="main">\n \n <div class="section" id="title">\n<h1>Title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#title" title="{title}">¶</a></h1>\n<p>This is an example page used to test EmbedAPI parsing features.</p>\n<div class="section" id="sub-title">\n<h2>Sub-title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#sub-title" title="{title}">¶</a></h2>\n<p>This is a reference to <a class="reference internal" href="https://project.readthedocs.io/en/latest/#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>\n</div>\n<div class="section" id="manual-reference-section">\n<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://project.readthedocs.io/en/latest/#manual-reference-section" title="{title}">¶</a></h2>\n<p>This is a reference to a manual reference <a class="reference internal" href="https://project.readthedocs.io/en/latest/#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>\n</div>\n</div>\n\n\n </div>'
70-
71-
assert response.json() == {
85+
content = """
86+
<div class="body" role="main">
87+
<div class="section" id="title">
88+
<h1>Title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#title" title="{title}">¶</a></h1>
89+
<p>This is an example page used to test EmbedAPI parsing features.</p>
90+
<div class="section" id="sub-title">
91+
<h2>Sub-title<a class="headerlink" href="https://project.readthedocs.io/en/latest/#sub-title" title="{title}">¶</a></h2>
92+
<p>This is a reference to <a class="reference internal" href="https://project.readthedocs.io/en/latest/#sub-title"><span class="std std-ref">Sub-title</span></a>.</p>
93+
</div>
94+
<div class="section" id="manual-reference-section">
95+
<span id="manual-reference"></span><h2>Manual Reference Section<a class="headerlink" href="https://project.readthedocs.io/en/latest/#manual-reference-section" title="{title}">¶</a></h2>
96+
<p>This is a reference to a manual reference <a class="reference internal" href="https://project.readthedocs.io/en/latest/#manual-reference"><span class="std std-ref">Manual Reference Section</span></a>.</p>
97+
</div>
98+
</div>
99+
</div>
100+
"""
101+
102+
json_response = response.json()
103+
assert json_response == {
72104
"url": "https://project.readthedocs.io/en/latest/",
73105
"fragment": None,
74-
"content": content,
106+
"content": mock.ANY,
75107
"external": False,
76108
}
109+
compare_content_without_blank_lines(json_response["content"], content)
77110

78111
@pytest.mark.sphinx("html", srcdir=srcdir, freshenv=False)
79112
@mock.patch("readthedocs.embed.v3.views.build_media_storage.open")

readthedocs/embed/v3/tests/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,18 @@ def get_anchor_link_title(thing):
2121
else:
2222
title = f"Permalink to this {thing}"
2323
return title
24+
25+
26+
def compare_content_without_blank_lines(text_a, text_b):
27+
lines_a = _split_lines_without_blank_lines(text_a)
28+
lines_b = _split_lines_without_blank_lines(text_b)
29+
assert lines_a == lines_b
30+
31+
32+
def _split_lines_without_blank_lines(text):
33+
lines = []
34+
for line in text.split("\n"):
35+
line = line.strip()
36+
if line:
37+
lines.append(line)
38+
return lines

requirements/docs.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Packages required to build docs, independent of application dependencies
22

3-
# There is an error when copying assets
4-
# TypeError: unsupported operand type(s) for /: 'str' and 'str'
5-
sphinx<8
3+
sphinx
64

75
matplotlib # opengraph social cards
86

requirements/docs.txt

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#
55
# pip-compile --output-file=requirements/docs.txt requirements/docs.in
66
#
7-
alabaster==0.7.16
7+
alabaster==1.0.0
88
# via sphinx
9-
anyio==4.6.0
9+
anyio==4.6.2.post1
1010
# via
1111
# starlette
1212
# watchfiles
@@ -15,8 +15,10 @@ babel==2.16.0
1515
# sphinx
1616
# sphinx-intl
1717
certifi==2024.8.30
18-
# via requests
19-
charset-normalizer==3.3.2
18+
# via
19+
# requests
20+
# sphinx-prompt
21+
charset-normalizer==3.4.0
2022
# via requests
2123
click==8.1.7
2224
# via
@@ -45,6 +47,7 @@ idna==3.10
4547
# via
4648
# anyio
4749
# requests
50+
# sphinx-prompt
4851
imagesize==1.4.1
4952
# via sphinx
5053
jinja2==3.1.4
@@ -57,7 +60,7 @@ markdown-it-py==3.0.0
5760
# via
5861
# mdit-py-plugins
5962
# myst-parser
60-
markupsafe==2.1.5
63+
markupsafe==3.0.2
6164
# via jinja2
6265
matplotlib==3.9.2
6366
# via -r requirements/docs.in
@@ -77,14 +80,14 @@ packaging==24.1
7780
# sphinx
7881
pbr==6.1.0
7982
# via sphinxcontrib-video
80-
pillow==10.4.0
83+
pillow==11.0.0
8184
# via matplotlib
8285
pygments==2.18.0
8386
# via
8487
# sphinx
8588
# sphinx-prompt
8689
# sphinx-tabs
87-
pyparsing==3.1.4
90+
pyparsing==3.2.0
8891
# via matplotlib
8992
python-dateutil==2.9.0.post0
9093
# via matplotlib
@@ -100,7 +103,7 @@ sniffio==1.3.1
100103
# via anyio
101104
snowballstemmer==2.2.0
102105
# via sphinx
103-
sphinx==7.4.7
106+
sphinx==8.1.3
104107
# via
105108
# -r requirements/docs.in
106109
# myst-parser
@@ -127,15 +130,15 @@ sphinx-hoverxref==1.4.1
127130
# via -r requirements/docs.in
128131
sphinx-intl==2.2.0
129132
# via -r requirements/docs.in
130-
sphinx-multiproject==1.0.0rc1
133+
sphinx-multiproject==1.0.0
131134
# via -r requirements/docs.in
132135
sphinx-notfound-page==1.0.4
133136
# via -r requirements/docs.in
134-
sphinx-prompt==1.8.0
137+
sphinx-prompt==1.9.0
135138
# via -r requirements/docs.in
136-
sphinx-rtd-theme==3.0.0
139+
sphinx-rtd-theme==3.0.1
137140
# via -r requirements/docs.in
138-
sphinx-tabs==3.4.5
141+
sphinx-tabs==3.4.7
139142
# via -r requirements/docs.in
140143
sphinxcontrib-applehelp==2.0.0
141144
# via sphinx
@@ -161,7 +164,7 @@ sphinxemoji==0.3.1
161164
# via -r requirements/docs.in
162165
sphinxext-opengraph==0.9.1
163166
# via -r requirements/docs.in
164-
starlette==0.39.2
167+
starlette==0.41.0
165168
# via sphinx-autobuild
166169
tomli==2.0.2
167170
# via sphinx
@@ -170,8 +173,10 @@ typing-extensions==4.12.2
170173
# anyio
171174
# uvicorn
172175
urllib3==2.2.3
173-
# via requests
174-
uvicorn==0.31.0
176+
# via
177+
# requests
178+
# sphinx-prompt
179+
uvicorn==0.32.0
175180
# via sphinx-autobuild
176181
watchfiles==0.24.0
177182
# via sphinx-autobuild

requirements/testing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ slumber==0.7.1
408408
# via -r requirements/pip.txt
409409
snowballstemmer==2.2.0
410410
# via sphinx
411-
sphinx[test]==8.0.2
411+
sphinx[test]==8.1.3
412412
# via -r requirements/testing.in
413413
sphinxcontrib-applehelp==2.0.0
414414
# via sphinx

tox.embedapi.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ install_command =
1717
# Install requirements in multiple steps because we don't want to install
1818
# Sphinx from `requirements/pip.txt` but from the `deps=` field.
1919
sh -c ' \
20-
cat {toxinidir}/requirements/pip.txt | grep -v "Sphinx" > {toxinidir}/requirements/embedapi.txt; \
21-
sed {toxinidir}/requirements/testing.txt -e "s|pip.txt|embedapi.txt|g" > {toxinidir}/requirements/testing.embedapi.txt; \
22-
pip install -r {toxinidir}/requirements/testing.embedapi.txt; \
20+
cat {toxinidir}/requirements/testing.txt | grep -v "Sphinx" > {toxinidir}/requirements/embedapi.txt; \
21+
pip install -r {toxinidir}/requirements/embedapi.txt; \
2322
pip install $*;' -- {opts} {packages}
2423
deps =
2524
sphinx-24: Sphinx~=2.4.0

0 commit comments

Comments
 (0)