Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAIN: Enable support for Sphinx>=4 #352

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 versions for fixtures
)

# self.nb_file = nb_file
# self.nb_name = os.path.splitext(nb_file)[0]
Expand Down
19 changes: 15 additions & 4 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@

def regress_nb_doc(file_regression, sphinx_run, check_nbs):
file_regression.check(
sphinx_run.get_nb(), check_fn=check_nbs, extension=".ipynb", encoding="utf8"
sphinx_run.get_nb(),
check_fn=check_nbs,
extension=f"{sphinx_run.software_versions}.ipynb",
encoding="utf8",
)
doctree = sphinx_run.get_doctree()
file_regression.check(doctree.pformat(), extension=".xml", encoding="utf8")
file_regression.check(
doctree.pformat(),
extension=f"{sphinx_run.software_versions}.xml",
encoding="utf8",
)


@pytest.mark.sphinx_params(
Expand Down Expand Up @@ -86,7 +93,9 @@ def test_exclude_path(sphinx_run, file_regression):
assert len(sphinx_run.app.env.nb_excluded_exec_paths) == 1
assert "Executing" not in sphinx_run.status(), sphinx_run.status()
file_regression.check(
sphinx_run.get_doctree().pformat(), extension=".xml", encoding="utf8"
sphinx_run.get_doctree().pformat(),
extension=f"{sphinx_run.software_versions}.xml",
encoding="utf8",
)


Expand Down Expand Up @@ -260,7 +269,9 @@ def test_nb_exec_table(sphinx_run, file_regression, check_nbs):
sphinx_run.build()
assert not sphinx_run.warnings()
file_regression.check(
sphinx_run.get_doctree().pformat(), extension=".xml", encoding="utf8"
sphinx_run.get_doctree().pformat(),
extension=f"{sphinx_run.software_versions}.xml",
encoding="utf8",
)
assert '<tr class="row-even"><td><p>nb_exec_table</p></td>' in sphinx_run.get_html()

Expand Down
56 changes: 56 additions & 0 deletions tests/test_execute/test_allow_errors_auto.sphinx4.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# a title\n",
"\n",
"some text\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "Exception",
"evalue": "oopsie!",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-714b2b556897>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'oopsie!'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mException\u001b[0m: oopsie!"
]
}
],
"source": [
"raise Exception('oopsie!')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"test_name": "notebook1"
},
"nbformat": 4,
"nbformat_minor": 2
}
12 changes: 12 additions & 0 deletions tests/test_execute/test_allow_errors_auto.sphinx4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<document source="basic_failing">
<section classes="tex2jax_ignore mathjax_ignore" ids="a-title" names="a\ title">
<title>
a title
<paragraph>
some text
<CellNode cell_type="code" classes="cell">
<CellInputNode classes="cell_input">
<literal_block language="ipython3" xml:space="preserve">
raise Exception('oopsie!')
<CellOutputNode classes="cell_output">
<CellOutputBundleNode output_count="1">
56 changes: 56 additions & 0 deletions tests/test_execute/test_allow_errors_cache.sphinx4.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# a title\n",
"\n",
"some text\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "Exception",
"evalue": "oopsie!",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-714b2b556897>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'oopsie!'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mException\u001b[0m: oopsie!"
]
}
],
"source": [
"raise Exception('oopsie!')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"test_name": "notebook1"
},
"nbformat": 4,
"nbformat_minor": 2
}
12 changes: 12 additions & 0 deletions tests/test_execute/test_allow_errors_cache.sphinx4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<document source="basic_failing">
<section classes="tex2jax_ignore mathjax_ignore" ids="a-title" names="a\ title">
<title>
a title
<paragraph>
some text
<CellNode cell_type="code" classes="cell">
<CellInputNode classes="cell_input">
<literal_block language="ipython3" xml:space="preserve">
raise Exception('oopsie!')
<CellOutputNode classes="cell_output">
<CellOutputBundleNode output_count="1">
56 changes: 56 additions & 0 deletions tests/test_execute/test_basic_failing_auto.sphinx4.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# a title\n",
"\n",
"some text\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "Exception",
"evalue": "oopsie!",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-714b2b556897>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'oopsie!'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mException\u001b[0m: oopsie!"
]
}
],
"source": [
"raise Exception('oopsie!')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"test_name": "notebook1"
},
"nbformat": 4,
"nbformat_minor": 2
}
12 changes: 12 additions & 0 deletions tests/test_execute/test_basic_failing_auto.sphinx4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<document source="basic_failing">
<section classes="tex2jax_ignore mathjax_ignore" ids="a-title" names="a\ title">
<title>
a title
<paragraph>
some text
<CellNode cell_type="code" classes="cell">
<CellInputNode classes="cell_input">
<literal_block language="ipython3" xml:space="preserve">
raise Exception('oopsie!')
<CellOutputNode classes="cell_output">
<CellOutputBundleNode output_count="1">
44 changes: 44 additions & 0 deletions tests/test_execute/test_basic_failing_cache.sphinx4.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# a title\n",
"\n",
"some text\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raise Exception('oopsie!')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
},
"test_name": "notebook1"
},
"nbformat": 4,
"nbformat_minor": 2
}
10 changes: 10 additions & 0 deletions tests/test_execute/test_basic_failing_cache.sphinx4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<document source="basic_failing">
<section classes="tex2jax_ignore mathjax_ignore" ids="a-title" names="a\ title">
<title>
a title
<paragraph>
some text
<CellNode cell_type="code" classes="cell">
<CellInputNode classes="cell_input">
<literal_block language="ipython3" xml:space="preserve">
raise Exception('oopsie!')
Loading