Skip to content

Commit e7544a6

Browse files
Daltz333pradyunsg
andauthored
Sphinx 4 Support (#110)
Co-authored-by: Pradyun Gedam <3275593+pradyunsg@users.noreply.github.com>
1 parent 506e69f commit e7544a6

File tree

6 files changed

+62
-4
lines changed

6 files changed

+62
-4
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
matrix:
3232
python-version: [3.6, 3.7, 3.8]
33-
sphinx: [">=2,<3", ">=3,<4"]
33+
sphinx: [">=2,<3", ">=3,<4", "==4.0.0b1"]
3434

3535
steps:
3636
- uses: actions/checkout@v2

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_version():
2525
url="https://github.com/executablebooks/sphinx-tabs",
2626
license="MIT",
2727
python_requires="~=3.6",
28-
install_requires=["sphinx>=2,<4", "pygments"],
28+
install_requires=["sphinx>=2,<5", "pygments", "docutils~=0.16.0"],
2929
extras_require={
3030
"testing": [
3131
"coverage",

tests/test_build.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import sphinx
23
from sphinx.application import Sphinx
34

45

@@ -22,10 +23,21 @@ def test_conditional_assets(app, docname, check_asset_links):
2223

2324

2425
@pytest.mark.sphinx(testroot="linenos")
26+
@pytest.mark.skipif(
27+
sphinx.version_info[:2] >= (4, 0), reason="Test uses Sphinx 3 code blocks"
28+
)
2529
def test_other_with_assets(app, check_asset_links):
2630
check_asset_links(app)
2731

2832

33+
@pytest.mark.sphinx(testroot="linenos")
34+
@pytest.mark.skipif(
35+
sphinx.version_info[:2] <= (4, 0), reason="Test uses Sphinx 4 code blocks"
36+
)
37+
def test_other_With_assets_new_style(app, check_asset_links):
38+
check_asset_links(app)
39+
40+
2941
@pytest.mark.sphinx(testroot="nestedmarkup")
3042
def test_nested_markup(app, check_asset_links):
3143
check_asset_links(app)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="documentwrapper">
2+
<div class="bodywrapper">
3+
<div class="body" role="main">
4+
<div class="sphinx-tabs docutils container">
5+
<div aria-label="Tabbed content" class="closeable" role="tablist">
6+
<button aria-controls="panel-0-Qysr" aria-selected="true" class="sphinx-tabs-tab code-tab group-tab" id="tab-0-Qysr" name="Qysr" role="tab" tabindex="0">
7+
C++
8+
</button>
9+
<button aria-controls="panel-0-UHl0aG9u" aria-selected="false" class="sphinx-tabs-tab code-tab group-tab" id="tab-0-UHl0aG9u" name="UHl0aG9u" role="tab" tabindex="-1">
10+
Python
11+
</button>
12+
</div>
13+
<div aria-labelledby="tab-0-Qysr" class="sphinx-tabs-panel code-tab group-tab" id="panel-0-Qysr" name="Qysr" role="tabpanel" tabindex="0">
14+
<div class="highlight-c++ notranslate">
15+
<div class="highlight">
16+
<pre><span></span><span class="linenos">1</span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">"hello world"</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
17+
</pre>
18+
</div>
19+
</div>
20+
</div>
21+
<div aria-labelledby="tab-0-UHl0aG9u" class="sphinx-tabs-panel code-tab group-tab" hidden="true" id="panel-0-UHl0aG9u" name="UHl0aG9u" role="tabpanel" tabindex="0">
22+
<div class="highlight-python notranslate">
23+
<div class="highlight">
24+
<pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s1">'hello world'</span><span class="p">)</span>
25+
</pre>
26+
</div>
27+
</div>
28+
</div>
29+
</div>
30+
</div>
31+
</div>
32+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<document source="index.rst">
2+
<container classes="sphinx-tabs" type="tab-element">
3+
<div aria-label="Tabbed content" classes="closeable" role="tablist">
4+
<button aria-controls="panel-0-Qysr" aria-selected="true" classes="sphinx-tabs-tab code-tab group-tab" ids="tab-0-Qysr" name="Qysr" role="tab" tabindex="0">
5+
C++
6+
<button aria-controls="panel-0-UHl0aG9u" aria-selected="false" classes="sphinx-tabs-tab code-tab group-tab" ids="tab-0-UHl0aG9u" name="UHl0aG9u" role="tab" tabindex="-1">
7+
Python
8+
<div aria-labelledby="tab-0-Qysr" classes="sphinx-tabs-panel code-tab group-tab" ids="panel-0-Qysr" name="Qysr" role="tabpanel" tabindex="0">
9+
<literal_block force="False" highlight_args="{}" language="c++" linenos="True" xml:space="preserve">
10+
std::cout << "hello world" << std::endl;
11+
<div aria-labelledby="tab-0-UHl0aG9u" classes="sphinx-tabs-panel code-tab group-tab" hidden="true" ids="panel-0-UHl0aG9u" name="UHl0aG9u" role="tabpanel" tabindex="0">
12+
<literal_block force="False" highlight_args="{}" language="python" xml:space="preserve">
13+
print('hello world')

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
# then run `tox` or `tox -- {pytest args}`
55
# run in parallel using `tox -p`
66
[tox]
7-
envlist = py{36,37,38}-sphinx{2,3},docs
7+
envlist = py{36,37,38}-sphinx{2,3,4},docs
88

9-
[testenv:py{36,37,38}-sphinx{2,3}]
9+
[testenv:py{36,37,38}-sphinx{2,3,4}]
1010
extras = testing
1111
deps =
1212
sphinx2: sphinx>=2,<3
1313
sphinx3: sphinx>=3,<4
14+
sphinx4: sphinx>=4,<5
1415
recreate = false
1516
commands = pytest {posargs}
1617

0 commit comments

Comments
 (0)