Skip to content

Commit

Permalink
⬆️ Support python>=3.10, sphinx >=7,<9, docutils>=0.19,<0.22 (#952)
Browse files Browse the repository at this point in the history
dropping support for lower versions
  • Loading branch information
chrisjsewell authored Aug 2, 2024
1 parent d3d7fbb commit 401e08c
Show file tree
Hide file tree
Showing 30 changed files with 175 additions and 229 deletions.
47 changes: 23 additions & 24 deletions .github/workflows/test-formats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -43,34 +43,33 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[linkify,rtd]
- name: Build docs
run: |
sphinx-build -nW --keep-going -b ${{ matrix.format }} docs/ docs/_build/${{ matrix.format }}
# TODO https://github.com/sphinx-doc/sphinx/issues/12594
# - name: Make PDF
# uses: xu-cheng/latex-action@v2
# with:
# working_directory: docs/_build/latex
# root_file: "mystparser.tex"
# # https://github.com/marketplace/actions/github-action-for-latex#it-fails-due-to-xindy-cannot-be-found
# pre_compile: |
# ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/xindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/xindy
# ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/texindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/texindy
# wget https://sourceforge.net/projects/xindy/files/xindy-source-components/2.4/xindy-kernel-3.0.tar.gz
# tar xf xindy-kernel-3.0.tar.gz
# cd xindy-kernel-3.0/src
# apk add make
# apk add clisp --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
# make
# cp -f xindy.mem /opt/texlive/texdir/bin/x86_64-linuxmusl/
# cd ../../
# env:
# XINDYOPTS: -L english -C utf8 -M sphinx.xdy
- name: Make PDF
uses: xu-cheng/latex-action@v2
with:
working_directory: docs/_build/latex
root_file: "mystparser.tex"
# https://github.com/marketplace/actions/github-action-for-latex#it-fails-due-to-xindy-cannot-be-found
pre_compile: |
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/xindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/xindy
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/texindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/texindy
wget https://sourceforge.net/projects/xindy/files/xindy-source-components/2.4/xindy-kernel-3.0.tar.gz
tar xf xindy-kernel-3.0.tar.gz
cd xindy-kernel-3.0/src
apk add make
apk add clisp --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
make
cp -f xindy.mem /opt/texlive/texdir/bin/x86_64-linuxmusl/
cd ../../
env:
XINDYOPTS: -L english -C utf8 -M sphinx.xdy
34 changes: 18 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,32 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"
- uses: pre-commit/action@v3.0.1

tests:

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
sphinx: [">=7,<8"]
python-version: ["3.10", "3.11", "3.12"]
sphinx: [">=8,<9"]
os: [ubuntu-latest]
include:
- os: ubuntu-latest
python-version: "3.8"
sphinx: ">=6,<7"
python-version: "3.10"
sphinx: ">=7,<8"
- os: windows-latest
python-version: "3.8"
sphinx: ">=6,<7"
python-version: "3.10"
sphinx: ">=7,<8"

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

name: "pytest: py${{ matrix.python-version }}, sphinx${{ matrix.sphinx }}, on ${{ matrix.os }}"

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -53,7 +55,7 @@ jobs:
pytest --cov=myst_parser --cov-report=xml --cov-report=term-missing
coverage xml
- name: Upload to Codecov
if: github.repository == 'executablebooks/MyST-Parser' && matrix.python-version == 3.8 && matrix.os == 'ubuntu-latest'
if: github.repository == 'executablebooks/MyST-Parser' && matrix.python-version == 3.10 && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -70,15 +72,15 @@ jobs:
strategy:
fail-fast: false
matrix:
docutils-version: ["0.18", "0.19", "0.20", "0.21"]
docutils-version: ["0.19", "0.20", "0.21"]

steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"
- name: Install setup
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -130,10 +132,10 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: install flit
run: |
pip install flit~=3.4
Expand All @@ -153,10 +155,10 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: install flit and tomlkit
run: |
pip install flit~=3.4 tomlkit
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
rev: v0.5.5
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
rev: v1.11.1
hooks:
- id: mypy
args: [--config-file=pyproject.toml]
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.10"

python:
install:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ with some minor changes to parsing behaviour:
* No significant changes, see <https://docutils.sourceforge.io/RELEASE-NOTES.html#release-0-20-2023-05-04>

* ⬆️ UPGRADE: Add support for `sphinx` v7, and remove v5 support (<gh-pr:776>)
* No significant changes, see <https://www.sphinx-doc.org/en/master/changes.html>
* No significant changes, see <https://www.sphinx-doc.org/en/master/changes/index.html>

* ⬆️ UPGRADE: Remove Python 3.7 support and add testing for Python 3.11 (<gh-pr:772>)

Expand Down
16 changes: 1 addition & 15 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import hashlib
from datetime import date
from pathlib import Path

from sphinx.application import Sphinx

Expand Down Expand Up @@ -56,7 +54,7 @@
suppress_warnings = ["myst.strikethrough"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3.7", None),
"python": ("https://docs.python.org/3.10", None),
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
"markdown_it": ("https://markdown-it-py.readthedocs.io/en/latest", None),
}
Expand Down Expand Up @@ -234,16 +232,4 @@ def setup(app: Sphinx):
app.add_directive("myst-to-html", MystToHTMLDirective)
app.add_post_transform(StripUnsupportedLatex)
app.add_post_transform(NumberSections)
app.connect("html-page-context", add_version_to_css)
app.add_lexer("myst", MystLexer)


def add_version_to_css(app: Sphinx, pagename, templatename, context, doctree):
"""Add the version number to the local.css file, to bust the cache for changes."""
if app.builder.name != "html":
return
if "_static/local.css" in context.get("css_files", {}):
css = Path(app.srcdir, "_static/local.css").read_text("utf8")
hashed = hashlib.sha256(css.encode("utf-8")).hexdigest()
index = context["css_files"].index("_static/local.css")
context["css_files"][index] = f"_static/local.css?hash={hashed}"
13 changes: 0 additions & 13 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,6 @@ to modify parsing behaviour and access extended syntax features.
[Convert existing ReStructuredText files to Markdown][rst-to-myst]
: Use the [rst-to-myst] CLI or [the MySTyc interactive web interface](https://astrojuanlu.github.io/mystyc/).

[MyST-NB](https://myst-nb.readthedocs.io)
: A Sphinx and Docutils extension for compiling Jupyter Notebooks into high quality documentation formats, built on top of the MyST-Parser.

[Jupyter Book](https://jupyterbook.org)
: An open source project for building beautiful, publication-quality books and documents from computational material, built on top of the MyST-Parser and MyST-NB.

[The Jupyter Book gallery](https://executablebooks.org/en/latest/gallery)
: Examples of documents built with MyST.

[Javascript MyST parser][mystjs]
: The [mystjs] Javascript parser, allows you to parse MyST in websites.

[markdown-it-py]
: A CommonMark-compliant and extensible Markdown parser, used by MyST-Parser to parse source text to tokens.

Expand Down Expand Up @@ -182,4 +170,3 @@ apidocs/index.rst
[markdown-it-py]: https://markdown-it-py.readthedocs.io/
[markdown-it]: https://markdown-it.github.io/
[rst-to-myst]: https://rst-to-myst.readthedocs.io
[mystjs]: https://github.com/executablebooks/mystjs
2 changes: 1 addition & 1 deletion myst_parser/_compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Helpers for cross compatibility across dependency versions."""

from typing import Callable, Iterable
from collections.abc import Callable, Iterable

from docutils.nodes import Element

Expand Down
7 changes: 4 additions & 3 deletions myst_parser/_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import contextlib
import io
from typing import Sequence, Union, get_args, get_origin
from collections.abc import Sequence
from typing import Union, get_args, get_origin

from docutils import nodes
from docutils.core import Publisher
Expand All @@ -28,7 +29,7 @@ class StripUnsupportedLatex(SphinxPostTransform):

default_priority = 900

def run(self):
def run(self, **kwargs):
if self.app.builder.format != "latex":
return
from docutils import nodes
Expand All @@ -46,7 +47,7 @@ class NumberSections(SphinxPostTransform):
default_priority = 710 # same as docutils.SectNum
formats = ("html",)

def run(self):
def run(self, **kwargs):
min_heading_level = 2
max_heading_level = 3
stack: list[tuple[list[int], nodes.Element]] = [([], self.document)]
Expand Down
3 changes: 2 additions & 1 deletion myst_parser/config/dc_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from __future__ import annotations

import dataclasses as dc
from typing import Any, Protocol, Sequence
from collections.abc import Sequence
from typing import Any, Protocol


def validate_field(inst: Any, field: dc.Field, value: Any) -> None:
Expand Down
Loading

0 comments on commit 401e08c

Please sign in to comment.