Skip to content

Commit

Permalink
Merge branch 'main' into jdsalaro-bugfix-jupyter-book-1414
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 authored Oct 29, 2023
2 parents d3f12d6 + 91d5a7e commit f6ac53e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 38 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
36 changes: 12 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,23 @@ on:

jobs:

pre-commit:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0

tests:

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
include:
- os: windows-latest
python-version: 3.8
python-version: 3.9

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -51,27 +39,27 @@ jobs:
run: |
pytest --cov=sphinx_external_toc --cov-report=xml --cov-report=term-missing
- name: Upload to Codecov
if: matrix.python-version == 3.8
uses: codecov/codecov-action@v1
if: matrix.python-version == 3.11
uses: codecov/codecov-action@v3
with:
name: pytests-py3.8
name: pytests-py3.11
flags: pytests
file: ./coverage.xml
fail_ci_if_error: true

publish:

name: Publish to PyPi
needs: [pre-commit, tests]
name: Publish to PyPI
needs: [tests]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
- name: install flit
run: |
pip install flit~=3.4
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

python:
version: 3
install:
- method: pip
path: .
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
]
keywords = ["sphinx","extension", "toc"]
requires-python = "~=3.7"
requires-python = ">=3.9"
dependencies = [
"click>=7.1,<9",
"click>=7.1",
"pyyaml",
"sphinx>=4,<6",
"sphinx>=5",
]

[project.urls]
Expand All @@ -39,14 +39,14 @@ Documentation = "https://sphinx-external-toc.readthedocs.io"
"jb.cmdline" = {toc = "sphinx_external_toc.cli:main"}

[project.optional-dependencies]
code_style = ["pre-commit~=2.12"]
code_style = ["pre-commit>=2.12"]
rtd = [
"myst-parser~=0.17.0",
"myst-parser>=1.0.0",
"sphinx-book-theme>=0.0.36",
]
testing = [
"coverage",
"pytest~=7.1",
"pytest>=7.1",
"pytest-cov",
"pytest-regressions",
]
Expand Down
2 changes: 1 addition & 1 deletion sphinx_external_toc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A sphinx extension that allows the project toctree to be defined in a single file."""

__version__ = "0.3.1"
__version__ = "1.0.0rc0"


from typing import TYPE_CHECKING
Expand Down
31 changes: 31 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
import re

import pytest

pytest_plugins = "sphinx.testing.fixtures"


# comparison files will need updating
# alternatively the resolution of https://github.com/ESSS/pytest-regressions/issues/32
@pytest.fixture()
def file_regression(file_regression):
return FileRegression(file_regression)


class FileRegression:
ignores = (
# TODO: Remove when support for Sphinx<=6 is dropped,
re.escape(" translation_progress=\"{'total': 0, 'translated': 0}\""),
# TODO: Remove when support for Sphinx<7.2 is dropped,
r"original_uri=\"[^\"]*\"\s",
)

def __init__(self, file_regression):
self.file_regression = file_regression

def check(self, data, **kwargs):
return self.file_regression.check(self._strip_ignores(data), **kwargs)

def _strip_ignores(self, data):
for ig in self.ignores:
data = re.sub(ig, "", data)
return data
13 changes: 11 additions & 2 deletions tests/test_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

import pytest
from sphinx.testing.path import path as sphinx_path
from sphinx import version_info as sphinx_version_info
from sphinx.testing.util import SphinxTestApp

from sphinx_external_toc.tools import create_site_from_toc
Expand Down Expand Up @@ -47,7 +47,16 @@ def outdir(self):
@pytest.fixture()
def sphinx_build_factory(make_app):
def _func(src_path: Path, **kwargs) -> SphinxBuild:
app = make_app(srcdir=sphinx_path(os.path.abspath(str(src_path))), **kwargs)
# For compatibility with multiple versions of sphinx, convert pathlib.Path to
# sphinx.testing.path.path here.
if sphinx_version_info >= (7, 2):
app_srcdir = src_path
else:
from sphinx.testing.path import path

app_srcdir = path(os.fspath(src_path))

app = make_app(srcdir=app_srcdir, **kwargs)
return SphinxBuild(app, src_path)

yield _func
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# then run `tox` or `tox -- {pytest args}`
# run in parallel using `tox -p`
[tox]
envlist = py38
envlist = py310

[testenv]
usedevelop = true

[testenv:py{36,37,38,39}]
[testenv:py{39,310,311,312}]
extras =
testing
commands = pytest {posargs}
Expand Down

0 comments on commit f6ac53e

Please sign in to comment.