From ada2b912240de6cbbc7c08b631085f948425fd38 Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 30 Aug 2021 10:10:50 +1000 Subject: [PATCH 1/7] Upgrade to support sphinx4, remove support for sphinx2 --- .github/workflows/tests.yml | 2 +- setup.cfg | 4 +- tests/conftest.py | 4 + tests/test_glue.py | 6 +- ...est_parser.xml => test_parser.sphinx3.xml} | 0 tests/test_glue/test_parser.sphinx4.xml | 169 ++++++++++++++++++ tox.ini | 4 +- 7 files changed, 183 insertions(+), 6 deletions(-) rename tests/test_glue/{test_parser.xml => test_parser.sphinx3.xml} (100%) create mode 100644 tests/test_glue/test_parser.sphinx4.xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3eb1ce80..efeed1c9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: matrix: os: [ubuntu-latest] python-version: [3.6, 3.7, 3.8, 3.9] - sphinx: [">=3,<4"] + sphinx: [">=3,<5"] include: - os: ubuntu-latest python-version: 3.8 diff --git a/setup.cfg b/setup.cfg index 02997266..9f6a723b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ project_urls = [options] packages = find: install_requires = - docutils>=0.15 + docutils>=0.15,<0.17 importlib_metadata ipython ipywidgets>=7.0.0,<8 @@ -48,7 +48,7 @@ install_requires = nbconvert>=5.6,<7 nbformat~=5.0 pyyaml - sphinx>=2,<4 + sphinx>=3.1,<5 sphinx-togglebutton~=0.2.2 python_requires = >=3.6 include_package_data = True diff --git a/tests/conftest.py b/tests/conftest.py index 9147190f..12e8353b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,7 @@ import nbformat as nbf import pytest +import sphinx from docutils.nodes import image as image_node from nbconvert.filters import strip_ansi from nbdime.diffing.notebooks import ( @@ -60,6 +61,9 @@ def __init__(self, app, filenames): self.app = app self.env = app.env self.files = [os.path.splitext(ff) for ff in filenames] + self.software_versions = ( + f".sphinx{sphinx.version_info[0]}" # software version tracking for fixtures + ) # self.nb_file = nb_file # self.nb_name = os.path.splitext(nb_file)[0] diff --git a/tests/test_glue.py b/tests/test_glue.py index 96935e3a..ffd7fbf5 100644 --- a/tests/test_glue.py +++ b/tests/test_glue.py @@ -110,7 +110,11 @@ def test_parser(sphinx_run, clean_doctree, file_regression): # print(sphinx_run.status()) assert sphinx_run.warnings() == "" doctree = clean_doctree(sphinx_run.get_resolved_doctree("with_glue")) - file_regression.check(doctree.pformat(), extension=".xml", encoding="utf8") + file_regression.check( + doctree.pformat(), + extension=f"{sphinx_run.software_versions}.xml", + encoding="utf8", + ) glue_domain = NbGlueDomain.from_env(sphinx_run.app.env) assert set(glue_domain.cache) == { "key_text1", diff --git a/tests/test_glue/test_parser.xml b/tests/test_glue/test_parser.sphinx3.xml similarity index 100% rename from tests/test_glue/test_parser.xml rename to tests/test_glue/test_parser.sphinx3.xml diff --git a/tests/test_glue/test_parser.sphinx4.xml b/tests/test_glue/test_parser.sphinx4.xml new file mode 100644 index 00000000..eff7afc6 --- /dev/null +++ b/tests/test_glue/test_parser.sphinx4.xml @@ -0,0 +1,169 @@ + +
+ + Glue Tests + <CellNode cell_type="code" classes="cell"> + <CellInputNode classes="cell_input"> + <literal_block language="ipython3" linenos="False" xml:space="preserve"> + from myst_nb import glue + <CellNode cell_type="code" classes="cell"> + <CellInputNode classes="cell_input"> + <literal_block language="ipython3" linenos="False" xml:space="preserve"> + glue("key_text1", "text1") + glue("key_float", 3.14159) + <CellOutputNode classes="cell_output"> + <literal_block classes="output text_plain" language="myst-ansi" linenos="False" xml:space="preserve"> + 'text1' + <literal_block classes="output text_plain" language="myst-ansi" linenos="False" xml:space="preserve"> + 3.14159 + <CellNode cell_type="code" classes="cell"> + <CellInputNode classes="cell_input"> + <literal_block language="ipython3" linenos="False" xml:space="preserve"> + glue("key_undisplayed", "undisplayed", display=False) + <CellOutputNode classes="cell_output"> + <CellNode cell_type="code" classes="cell"> + <CellInputNode classes="cell_input"> + <literal_block language="ipython3" linenos="False" xml:space="preserve"> + import pandas as pd + df = pd.DataFrame({"header": [1, 2, 3]}) + glue("key_df", df) + <CellOutputNode classes="cell_output"> + <raw classes="output text_html" format="html" xml:space="preserve"> + <div> + <style scoped> + .dataframe tbody tr th:only-of-type { + vertical-align: middle; + } + + .dataframe tbody tr th { + vertical-align: top; + } + + .dataframe thead th { + text-align: right; + } + </style> + <table border="1" class="dataframe"> + <thead> + <tr style="text-align: right;"> + <th></th> + <th>header</th> + </tr> + </thead> + <tbody> + <tr> + <th>0</th> + <td>1</td> + </tr> + <tr> + <th>1</th> + <td>2</td> + </tr> + <tr> + <th>2</th> + <td>3</td> + </tr> + </tbody> + </table> + </div> + <CellNode cell_type="code" classes="cell"> + <CellInputNode classes="cell_input"> + <literal_block language="ipython3" linenos="False" xml:space="preserve"> + import matplotlib.pyplot as plt + plt.plot([1, 2, 3]) + glue("key_plt", plt.gcf(), display=False) + <CellOutputNode classes="cell_output"> + <image candidates="{'*': '_build/jupyter_execute/with_glue_5_1.png'}" uri="_build/jupyter_execute/with_glue_5_1.png"> + <section ids="referencing-the-figs" names="referencing\ the\ figs"> + <title> + Referencing the figs + <paragraph> + <inline classes="pasted-inline"> + <literal classes="output text_plain" language="none"> + 'text1' + , + <inline classes="pasted-inline"> + <image candidates="{'*': '_build/jupyter_execute/with_glue_5_0.png'}" uri="_build/jupyter_execute/with_glue_5_0.png"> + <CellOutputNode classes="cell_output"> + <raw classes="output text_html" format="html" xml:space="preserve"> + <div> + <style scoped> + .dataframe tbody tr th:only-of-type { + vertical-align: middle; + } + + .dataframe tbody tr th { + vertical-align: top; + } + + .dataframe thead th { + text-align: right; + } + </style> + <table border="1" class="dataframe"> + <thead> + <tr style="text-align: right;"> + <th></th> + <th>header</th> + </tr> + </thead> + <tbody> + <tr> + <th>0</th> + <td>1</td> + </tr> + <tr> + <th>1</th> + <td>2</td> + </tr> + <tr> + <th>2</th> + <td>3</td> + </tr> + </tbody> + </table> + </div> + <paragraph> + and + <inline classes="pasted-text"> + text1 + inline… + <paragraph> + and formatted + <inline classes="pasted-text"> + 3.14 + <CellOutputNode classes="cell_output"> + <image candidates="{'*': '_build/jupyter_execute/with_glue_5_0.png'}" uri="_build/jupyter_execute/with_glue_5_0.png"> + <paragraph> + and + <inline classes="pasted-text"> + undisplayed + inline… + <figure ids="abc" names="abc"> + <CellOutputNode classes="cell_output"> + <image candidates="{'*': '_build/jupyter_execute/with_glue_5_0.png'}" uri="_build/jupyter_execute/with_glue_5_0.png"> + <caption> + A caption…. + + ```## A test title + <inline classes="pasted-inline"> + <literal classes="output text_plain" language="none"> + 'text1' + <section ids="math" names="math"> + <title> + Math + <CellNode cell_type="code" classes="cell"> + <CellInputNode classes="cell_input"> + <literal_block language="ipython3" linenos="False" xml:space="preserve"> + import sympy as sym + f = sym.Function('f') + y = sym.Function('y') + n = sym.symbols(r'\alpha') + f = y(n)-2*y(n-1/sym.pi)-5*y(n-2) + glue("sym_eq", sym.rsolve(f,y(n),[1,4])) + <CellOutputNode classes="cell_output"> + <math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve"> + \displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right) + <target refid="equation-eq-sym"> + <math_block classes="pasted-math" docname="with_glue" ids="equation-eq-sym" label="eq-sym" nowrap="False" number="1" xml:space="preserve"> + \displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right) diff --git a/tox.ini b/tox.ini index 152376ae..fa70650b 100644 --- a/tox.ini +++ b/tox.ini @@ -13,11 +13,11 @@ [tox] envlist = py37-sphinx3 -[testenv:py{36,37,38,39}-sphinx{2,3}] +[testenv:py{36,37,38,39}-sphinx{3,4}] extras = testing deps = - sphinx2: sphinx>=2,<3 sphinx3: sphinx>=3,<4 + sphinx4: sphinx>=4,<5 commands = pytest {posargs} [testenv:docs-{update,clean}] From 9460257235400835a687106efd0ac2b6479e8e97 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Mon, 30 Aug 2021 10:23:02 +1000 Subject: [PATCH 2/7] update github action tests setup --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index efeed1c9..769dc50e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,11 +27,11 @@ jobs: matrix: os: [ubuntu-latest] python-version: [3.6, 3.7, 3.8, 3.9] - sphinx: [">=3,<5"] + sphinx: [">=4,<5"] include: - os: ubuntu-latest python-version: 3.8 - sphinx: ">=2,<3" + sphinx: ">=3,<4" - os: windows-latest python-version: 3.7 sphinx: ">=3,<4" From 7d68b54f769d0ccbb61d9b8a37b89b66765f5260 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Mon, 30 Aug 2021 10:24:58 +1000 Subject: [PATCH 3/7] reconfigure to include major tests on sphinx3 and sphinx4 --- .github/workflows/tests.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 769dc50e..f257146f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,12 +26,9 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [3.6, 3.7, 3.8, 3.9] - sphinx: [">=4,<5"] + python-version: [3.7, 3.8, 3.9] + sphinx: [">=3,<4", ">=4,<5"] include: - - os: ubuntu-latest - python-version: 3.8 - sphinx: ">=3,<4" - os: windows-latest python-version: 3.7 sphinx: ">=3,<4" From c6833b02f91a1947affe64e6d88e90414a302824 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Mon, 30 Aug 2021 10:39:14 +1000 Subject: [PATCH 4/7] add back in python=3.6, add in osx-latest for py39-sphinx4 --- .github/workflows/tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f257146f..9f45a961 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,9 +26,15 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [3.7, 3.8, 3.9] - sphinx: [">=3,<4", ">=4,<5"] + python-version: [3.6, 3.7, 3.8, 3.9] + sphinx: [">=4,<5"] include: + - os : ubuntu-latest + python-version: [3.8,3.9] + sphinx: ">=3,<4" + - os: macos-latest + python-version: 3.9 + sphinx: ">=4,<5" - os: windows-latest python-version: 3.7 sphinx: ">=3,<4" From 853685c728027c29f2cd589be4e0f798f44c9d0a Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Mon, 30 Aug 2021 10:47:14 +1000 Subject: [PATCH 5/7] FIX: fix specific test runs not to include range --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9f45a961..87808c0e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,14 +30,14 @@ jobs: sphinx: [">=4,<5"] include: - os : ubuntu-latest - python-version: [3.8,3.9] + python-version: 3.8 sphinx: ">=3,<4" - - os: macos-latest - python-version: 3.9 - sphinx: ">=4,<5" - os: windows-latest python-version: 3.7 sphinx: ">=3,<4" + - os: macos-latest + python-version: 3.9 + sphinx: ">=4,<5" runs-on: ${{ matrix.os }} From 632c51e379c888d0c6860965e97f407ced4d2fba Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Mon, 30 Aug 2021 10:48:25 +1000 Subject: [PATCH 6/7] Upgrade docutils pin to include 0.17 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 9f6a723b..dfaeb482 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ project_urls = [options] packages = find: install_requires = - docutils>=0.15,<0.17 + docutils>=0.15,<0.18 importlib_metadata ipython ipywidgets>=7.0.0,<8 From 9aecefb1c9b66f2eef72a23894a51b52b80851a9 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Mon, 30 Aug 2021 10:50:54 +1000 Subject: [PATCH 7/7] restore testing all major python versions against sphinx3 and sphinx4 --- .github/workflows/tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 87808c0e..b34018a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,11 +27,8 @@ jobs: matrix: os: [ubuntu-latest] python-version: [3.6, 3.7, 3.8, 3.9] - sphinx: [">=4,<5"] + sphinx: [">=3,<4", ">=4,<5"] include: - - os : ubuntu-latest - python-version: 3.8 - sphinx: ">=3,<4" - os: windows-latest python-version: 3.7 sphinx: ">=3,<4"