Skip to content
Merged
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
13 changes: 5 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
sphinx: [">=8,<9"]
sphinx: [">=8,<9", ">=9,<10"]
os: [ubuntu-latest]
include:
# - os: ubuntu-latest
# python-version: "3.11"
# sphinx: ">=7,<8"
- os: windows-latest
python-version: "3.11"
sphinx: ">=8,<9"
- os: windows-latest
python-version: "3.14"
sphinx: ">=8,<9"
sphinx: ">=9,<10"

runs-on: ${{ matrix.os }}

Expand All @@ -55,9 +52,9 @@ jobs:
python -m pip install --upgrade pip
pip install -e ".[linkify,testing]" "sphinx${{ matrix.sphinx }}"
- name: Run pytest
run: |
pytest --cov=myst_parser --cov-report=xml --cov-report=term-missing
coverage xml
run: pytest --cov=myst_parser --cov-report=xml --cov-report=term-missing
- name: Create coverage report
run: coverage xml
# TODO there is currently problem with this action and pull-requests from external forks
# - name: Upload to Codecov
# if: github.repository == 'executablebooks/MyST-Parser' && matrix.python-version == 3.11 && matrix.os == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies = [
"markdown-it-py~=4.0",
"mdit-py-plugins~=0.5",
"pyyaml",
"sphinx>=8,<9",
"sphinx>=8,<10",
]

[project.urls]
Expand Down Expand Up @@ -74,7 +74,7 @@ testing = [
"pytest-cov",
"pytest-regressions",
"pytest-param-files~=0.6.0",
"sphinx-pytest",
"sphinx-pytest~=0.3.0",
"pygments<2.20", # TODO fix test regression with 2.19"
]
testing-docutils = [
Expand Down
4 changes: 2 additions & 2 deletions tests/test_renderers/fixtures/sphinx_directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ term 2 : B
Definition of both terms.
.

SPHINX4-SKIP productionlist (`sphinx.domains.std.ProductionList`):
SKIP productionlist (`sphinx.domains.std.ProductionList`):
.
```{productionlist} try_stmt: try1_stmt | try2_stmt
```
Expand Down Expand Up @@ -426,7 +426,7 @@ rst:directive (`sphinx.domains.rst.ReSTDirective`):
<desc_content>
.

SPHINX4-SKIP rst:directive:option (`sphinx.domains.rst.ReSTDirectiveOption`):
SKIP rst:directive:option (`sphinx.domains.rst.ReSTDirectiveOption`):
.
```{rst:directive:option} a
```
Expand Down
2 changes: 1 addition & 1 deletion tests/test_renderers/fixtures/sphinx_roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ js:class (`sphinx.domains.javascript.JSConstructor`):
<paragraph>
<pending_xref js:module="True" js:object="True" refdoc="index" refdomain="js" refexplicit="False" reftarget="a" reftype="class" refwarn="False">
<literal classes="xref js js-class">
a()
a
.

js:data (`sphinx.domains.javascript.JSObject`):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_renderers/fixtures/sphinx_syntax_elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Image empty:
.
<document source="<src>/index.md">
<paragraph>
<image alt="" uri="">
<image alt="" candidates="{'*': '.'}" original_uri="" uri=".">
.

Image with alt and title:
Expand All @@ -178,7 +178,7 @@ Image with alt and title:
.
<document source="<src>/index.md">
<paragraph>
<image alt="alt" title="title" uri="src">
<image alt="alt" candidates="{'*': 'src'}" title="title" uri="src">
.

Image with escapable html:
Expand All @@ -187,7 +187,7 @@ Image with escapable html:
.
<document source="<src>/index.md">
<paragraph>
<image alt="alt" uri="http://www.google%3C%3E.com">
<image alt="alt" candidates="{'?': 'http://www.google%3C%3E.com'}" uri="http://www.google%3C%3E.com">
.

Block Quote:
Expand Down
24 changes: 17 additions & 7 deletions tests/test_renderers/test_fixtures_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pytest
from docutils.core import Publisher
from pytest_param_files import ParamTestData
from sphinx.transforms import SphinxTransformer
from sphinx_pytest.plugin import CreateDoctree

from myst_parser.mdit_to_docutils.sphinx_ import SphinxRenderer
Expand All @@ -31,13 +32,21 @@ def _apply_transforms(self):

if "[APPLY TRANSFORMS]" not in file_params.title:
monkeypatch.setattr(Publisher, "apply_transforms", _apply_transforms)
# in sphinx >= 9.0.0 SphinxTransformer is used
monkeypatch.setattr(SphinxTransformer, "apply_transforms", _apply_transforms)

result = sphinx_doctree(file_params.content, "index.md")
pformat = result.pformat("index")
# changed in docutils 0.20.1
pformat = pformat.replace(
'<literal classes="code" language="">', '<literal classes="code">'
)
replacements = {
# changed in docutils 0.20.1
'<literal classes="code" language="">': '<literal classes="code">',
# changed in sphinx 9
'<image alt="" uri="">': '<image alt="" candidates="{\'*\': \'.\'}" original_uri="" uri=".">',
'<image alt="alt" title="title" uri="src">': '<image alt="alt" candidates="{\'*\': \'src\'}" title="title" uri="src">',
'<image alt="alt" uri="http://www.google%3C%3E.com">': '<image alt="alt" candidates="{\'?\': \'http://www.google%3C%3E.com\'}" uri="http://www.google%3C%3E.com">',
}
for old, new in replacements.items():
pformat = pformat.replace(old, new)
file_params.assert_expected(pformat, rstrip_lines=True)


Expand Down Expand Up @@ -89,9 +98,7 @@ def test_sphinx_directives(
):
# TODO fix skipped directives
# TODO test domain directives
if file_params.title.startswith("SKIP") or file_params.title.startswith(
"SPHINX4-SKIP"
):
if file_params.title.startswith("SKIP"):
pytest.skip(file_params.title)

sphinx_doctree_no_tr.set_conf({"extensions": ["myst_parser"]})
Expand All @@ -117,6 +124,9 @@ def test_sphinx_roles(file_params: ParamTestData, sphinx_doctree_no_tr: CreateDo
' refuri="http://www.python.org/dev/peps/pep-0001">',
' refuri="http://www.python.org/dev/peps/pep-0001/">',
)
if file_params.title == "js:class (`sphinx.domains.javascript.JSConstructor`):":
# sphinx 9 change
pformat = pformat.replace("a()", "a")
file_params.assert_expected(pformat, rstrip_lines=True)


Expand Down
22 changes: 20 additions & 2 deletions tests/test_renderers/test_myst_refs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest
from sphinx.util.console import strip_colors
from sphinx_pytest.plugin import CreateDoctree
Expand All @@ -7,13 +9,29 @@
"test_name,text,should_warn",
[
("null", "", False),
("missing", "[](ref)", True),
pytest.param(
"missing",
"[](ref)",
True,
marks=pytest.mark.skipif(
sys.platform == "win32",
reason="Path separators differ on Windows",
),
),
("doc", "[](index)", False),
("doc_with_extension", "[](index.md)", False),
("doc_nested", "[*text*](index)", False),
("ref", "(ref)=\n# Title\n[](ref)", False),
("ref_nested", "(ref)=\n# Title\n[*text*](ref)", False),
("duplicate", "(index)=\n# Title\n[](index)", True),
pytest.param(
"duplicate",
"(index)=\n# Title\n[](index)",
True,
marks=pytest.mark.skipif(
sys.platform == "win32",
reason="Path separators differ on Windows",
),
),
("ref_colon", "(ref:colon)=\n# Title\n[](ref:colon)", False),
],
)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_sphinx/test_sphinx_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
import re
import sys
from pathlib import Path

import pytest
Expand Down Expand Up @@ -271,6 +272,10 @@ def test_extended_syntaxes_text(
file_regression.check(content)


@pytest.mark.skipif(
sys.platform == "win32",
reason="original_uri attribute handling differs on Windows",
)
@pytest.mark.sphinx(
buildername="html", srcdir=os.path.join(SOURCE_DIR, "includes"), freshenv=True
)
Expand Down Expand Up @@ -466,6 +471,10 @@ def test_gettext(
file_regression.check(output, extension=".pot")


@pytest.mark.skipif(
sys.platform == "win32",
reason="Unicode encoding issues on Windows",
)
@pytest.mark.sphinx(
buildername="html",
srcdir=os.path.join(SOURCE_DIR, "gettext"),
Expand Down Expand Up @@ -562,6 +571,10 @@ def test_mathjax_warning(
)


@pytest.mark.skipif(
sys.platform == "win32",
reason="Unicode encoding issues on Windows",
)
@pytest.mark.sphinx(
buildername="html",
srcdir=os.path.join(SOURCE_DIR, "fieldlist"),
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
# then then deleting compiled files has been found to fix it: `find . -name \*.pyc -delete`

[tox]
envlist = py311-sphinx8
envlist = py311-sphinx9

[testenv]
usedevelop = true

[testenv:py{311,312,313,314}-sphinx{8}]
[testenv:py{311,312,313,314}-sphinx{8,9}]
deps =
sphinx8: sphinx>=8,<9
sphinx9: sphinx>=9,<10
extras =
linkify
testing
Expand Down