diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index c0767a3..b7414e8 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -17,8 +17,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.6, 3.7, 3.8]
- sphinx: [">=2,<3", ">=3,<4", "==4.0.0b1"]
+ python-version: [3.6, 3.7, 3.8, 3.9]
+ sphinx: [">=2,<3", ">=3,<4", ">=4,<5"]
+ pygments: ["==2.8.0", "==2.9.0", "==2.10.0"]
steps:
- uses: actions/checkout@v2
@@ -30,6 +31,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install "sphinx${{ matrix.sphinx }}"
+ pip install "pygments${{ matrix.pygments }}"
pip install .[testing]
- name: Run pytest
run: |
diff --git a/tests/conftest.py b/tests/conftest.py
index aea4aa0..6c15bd4 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -75,17 +75,19 @@ def regress_sphinx_app_output(file_regression, get_sphinx_app_output):
non-deterministic).
"""
- def read(
- app, buildername="html", filename="index.html", encoding="utf-8", replace=None
- ):
+ def read(app, buildername="html", filename="index.html", encoding="utf-8"):
content = get_sphinx_app_output(app, buildername, filename, encoding)
if buildername == "html":
soup = BeautifulSoup(content, "html.parser")
+
+ # Remove output from ``pygments``, so that test only compares HTML of surrounding tabs
+ for div in soup.find_all("div", {"class": "highlight"}):
+ div.decompose()
+
doc_div = soup.findAll("div", {"class": "documentwrapper"})[0]
doc = doc_div.prettify()
- for find, rep in (replace or {}).items():
- doc = text.replace(find, rep)
+
else:
doc = content
file_regression.check(
diff --git a/tests/roots/test-conditionalassets-policy/conf.py b/tests/roots/test-conditionalassets-policy/conf.py
new file mode 100644
index 0000000..1fc6dcb
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/conf.py
@@ -0,0 +1,5 @@
+project = "sphinx-tabs test"
+master_doc = "index"
+source_suffix = ".rst"
+extensions = ["sphinx_tabs.tabs"]
+pygments_style = "sphinx"
diff --git a/tests/roots/test-conditionalassets-policy/index.rst b/tests/roots/test-conditionalassets-policy/index.rst
new file mode 100644
index 0000000..1d1ec6e
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/index.rst
@@ -0,0 +1,130 @@
+.. toctree::
+
+ no_tabs1
+ no_tabs2
+
+Fruits
+========================================
+
+.. tabs::
+
+ .. tab:: Apples
+
+ Apples are green, or sometimes red.
+
+ .. tab:: Pears
+
+ Pears are green.
+
+ .. tab:: Oranges
+
+ Oranges are orange.
+
+Luminaries
+========================================
+
+.. tabs::
+
+ .. tab:: Sun
+
+ The sun is a star.
+
+ .. tab:: Moon
+
+ The moon is not a star.
+
+Code Tabs
+========================================
+
+.. tabs::
+
+ .. code-tab:: c
+
+ C Main Function
+
+ .. code-tab:: c++
+
+ C++ Main Function
+
+ .. code-tab:: py
+
+ Python Main Function
+
+ .. code-tab:: java
+
+ Java Main Function
+
+ .. code-tab:: julia
+
+ Julia Main Function
+
+ .. code-tab:: fortran
+
+ Fortran Main Function
+
+.. tabs::
+
+ .. code-tab:: c
+
+ int main(const int argc, const char **argv) {
+ return 0;
+ }
+
+ .. code-tab:: c++
+
+ int main(const int argc, const char **argv) {
+ return 0;
+ }
+
+ .. code-tab:: py
+
+ def main():
+ return
+
+ .. code-tab:: java
+
+ class Main {
+ public static void main(String[] args) {
+ }
+ }
+
+ .. code-tab:: julia
+
+ function main()
+ end
+
+ .. code-tab:: fortran
+
+ PROGRAM main
+ END PROGRAM main
+
+Group Tabs
+========================================
+
+.. tabs::
+
+ .. group-tab:: Linux
+
+ Linux Line 1
+
+ .. group-tab:: Mac OSX
+
+ Mac OSX Line 1
+
+ .. group-tab:: Windows
+
+ Windows Line 1
+
+.. tabs::
+
+ .. group-tab:: Linux
+
+ Linux Line 2
+
+ .. group-tab:: Mac OSX
+
+ Mac OSX Line 2
+
+ .. group-tab:: Windows
+
+ Windows Line 2
diff --git a/tests/roots/test-conditionalassets-policy/no_tabs1.rst b/tests/roots/test-conditionalassets-policy/no_tabs1.rst
new file mode 100644
index 0000000..291ccfa
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/no_tabs1.rst
@@ -0,0 +1,4 @@
+Another page without tabs
+========================================
+
+No tabs to see here
diff --git a/tests/roots/test-conditionalassets-policy/no_tabs2.rst b/tests/roots/test-conditionalassets-policy/no_tabs2.rst
new file mode 100644
index 0000000..99ef57d
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/no_tabs2.rst
@@ -0,0 +1,4 @@
+And another page without tabs
+========================================
+
+No tabs to see here either
diff --git a/tests/test_build.py b/tests/test_build.py
index 37a63bd..a44a9ef 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -27,7 +27,7 @@ def test_conditional_assets(app, docname, check_asset_links):
@pytest.mark.noautobuild
@pytest.mark.parametrize("docname", ["index", "no_tabs1", "no_tabs2"])
-@pytest.mark.sphinx(testroot="conditionalassets")
+@pytest.mark.sphinx(testroot="conditionalassets-policy")
@pytest.mark.skipif(
sphinx.version_info[:2] < (4, 1), reason="Test uses Sphinx 4.1 config"
)
diff --git a/tests/test_build/test_conditional_assets_html_assets_policy_index_.html b/tests/test_build/test_conditional_assets_html_assets_policy_index_.html
new file mode 100644
index 0000000..c9ba110
--- /dev/null
+++ b/tests/test_build/test_conditional_assets_html_assets_policy_index_.html
@@ -0,0 +1,248 @@
+
+
+
+
+
+
+ Fruits
+
+
+
+
+
+
+
+
+
+
+ Apples are green, or sometimes red.
+
+
+
+
+
+ Oranges are orange.
+
+
+
+
+
+
+ Luminaries
+
+
+
+
+
+
+
+
+
+ The sun is a star.
+
+
+
+
+ The moon is not a star.
+
+
+
+
+
+
+ Code Tabs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Group Tabs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/test_build/test_conditional_assets_html_assets_policy_index_.xml b/tests/test_build/test_conditional_assets_html_assets_policy_index_.xml
new file mode 100644
index 0000000..7fe4f8f
--- /dev/null
+++ b/tests/test_build/test_conditional_assets_html_assets_policy_index_.xml
@@ -0,0 +1,152 @@
+
+
+
+
+
+ Fruits
+
+
+