From 52dba0718e4986db51867c5fefd65322dc57d046 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 23 May 2021 01:08:07 +0900 Subject: [PATCH 01/26] Bump version --- CHANGES | 4 ++++ sphinxcontrib/serializinghtml/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 0a9bec6..68bcf58 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +Release 1.1.6 (unreleased) +========================== + + Release 1.1.5 (2021-05-23) ========================== diff --git a/sphinxcontrib/serializinghtml/version.py b/sphinxcontrib/serializinghtml/version.py index dc92d0a..a69a9e7 100644 --- a/sphinxcontrib/serializinghtml/version.py +++ b/sphinxcontrib/serializinghtml/version.py @@ -6,5 +6,5 @@ :license: BSD, see LICENSE for details. """ -__version__ = '1.1.5' +__version__ = '1.1.6' __version_info__ = tuple(map(int, __version__.split('.'))) From 4da97500eba78f3b61fe8232cdaedd0ac5072609 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 17 Mar 2023 00:16:48 +0000 Subject: [PATCH 02/26] git mv setup.py pyproject.toml --- setup.py => pyproject.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename setup.py => pyproject.toml (100%) diff --git a/setup.py b/pyproject.toml similarity index 100% rename from setup.py rename to pyproject.toml From 09c46744259e5a41a00c11652bd0ec27137ac02e Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 17 Mar 2023 00:25:42 +0000 Subject: [PATCH 03/26] Use modern ``pyproject`` based packaging --- pyproject.toml | 135 +++++++++++----------- setup.cfg | 13 --- sphinxcontrib/__init__.py | 15 --- sphinxcontrib/serializinghtml/__init__.py | 4 +- sphinxcontrib/serializinghtml/version.py | 10 -- 5 files changed, 73 insertions(+), 104 deletions(-) delete mode 100644 sphinxcontrib/__init__.py delete mode 100644 sphinxcontrib/serializinghtml/version.py diff --git a/pyproject.toml b/pyproject.toml index 8f1b614..36bc2fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,71 +1,76 @@ -# -*- coding: utf-8 -*- -import os -from setuptools import setup, find_packages +[build-system] +requires = ["flit_core>=3.7"] +build-backend = "flit_core.buildapi" -long_desc = ''' -sphinxcontrib-serializinghtml is a sphinx extension which outputs -"serialized" HTML files (json and pickle). -''' +# project metadata +[project] +name = "sphinxcontrib-serializinghtml" +description = """sphinxcontrib-serializinghtml is a sphinx extension which \ +outputs "serialized" HTML files (json and pickle)""" +readme = "README.rst" +urls.Changelog = "https://www.sphinx-doc.org/en/master/changes.html" +urls.Code = "https://github.com/sphinx-doc/sphinxcontrib-serializinghtml" +urls.Download = "https://pypi.org/project/sphinxcontrib-serializinghtml/" +urls.Homepage = "https://www.sphinx-doc.org/" +urls."Issue tracker" = "https://github.com/sphinx-doc/sphinx/issues" +license.text = "BSD-2-Clause" +requires-python = ">=3.5" -extras_require = { - 'test': [ - 'pytest', - ], - 'lint': [ - 'flake8', - 'mypy', - 'docutils-stubs', - ], -} +# Classifiers list: https://pypi.org/classifiers/ +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "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", + "Framework :: Sphinx", + "Framework :: Sphinx :: Extension", + "Topic :: Documentation", + "Topic :: Documentation :: Sphinx", + "Topic :: Text Processing", + "Topic :: Utilities", +] +dependencies = [] +dynamic = ["version"] +[project.optional-dependencies] +test = [ + "pytest", +] +lint = [ + "flake8", + "mypy", + "docutils-stubs", +] -def get_version(): - """Get version number of the package from version.py without importing core module.""" - package_dir = os.path.abspath(os.path.dirname(__file__)) - version_file = os.path.join(package_dir, 'sphinxcontrib/serializinghtml/version.py') +[[project.authors]] +name = "Georg Brandl" +email = "georg@python.org" - namespace = {} - with open(version_file, 'rt') as f: - exec(f.read(), namespace) +[tool.flit.module] +name = "sphinxcontrib.serializinghtml" - return namespace['__version__'] - - -setup( - name='sphinxcontrib-serializinghtml', - version=get_version(), - url='http://sphinx-doc.org/', - download_url='https://pypi.org/project/sphinxcontrib-serializinghtml/', - license='BSD', - author='Georg Brandl', - author_email='georg@python.org', - description=long_desc.strip().replace('\n', ' '), - long_description=long_desc, - zip_safe=False, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Framework :: Sphinx', - 'Framework :: Sphinx :: Extension', - 'Topic :: Documentation', - 'Topic :: Documentation :: Sphinx', - 'Topic :: Text Processing', - 'Topic :: Utilities', - ], - platforms='any', - python_requires=">=3.5", - packages=find_packages(exclude=['tests']), - include_package_data=True, - extras_require=extras_require, - namespace_packages=['sphinxcontrib'], -) +[tool.flit.sdist] +include = [ + "CHANGES", + "LICENSE", + # Tests + "tests/", + "tox.ini", +] +exclude = [ + "doc/_build", +] diff --git a/setup.cfg b/setup.cfg index f346323..dcf63c9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,3 @@ -[egg_info] -tag_build = .dev -tag_date = true - -[aliases] -release = egg_info -Db '' - [extract_messages] output_file = sphinxcontrib/serializinghtml/locales/sphinxcontrib.serializinghtml.pot keywords = _ __ @@ -14,12 +7,6 @@ domain = sphinxcontrib.serializinghtml directory = sphinxcontrib/serializinghtml/locales/ use_fuzzy = true -[bdist_wheel] -universal = 1 - -[metadata] -license_file = LICENSE - [flake8] max-line-length = 95 ignore = E116,E241,E251 diff --git a/sphinxcontrib/__init__.py b/sphinxcontrib/__init__.py deleted file mode 100644 index c10210a..0000000 --- a/sphinxcontrib/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -""" - sphinxcontrib - ~~~~~~~~~~~~~ - - This package is a namespace package that contains all extensions - distributed in the ``sphinx-contrib`` distribution. - - :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" - -import pkg_resources - - -pkg_resources.declare_namespace(__name__) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index c247656..ff800a0 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -17,12 +17,14 @@ from sphinx.util.osutil import SEP, copyfile, ensuredir, os_path from sphinxcontrib.serializinghtml import jsonimpl -from sphinxcontrib.serializinghtml.version import __version__ if False: # For type annotation from typing import Any, Dict, Tuple # NOQA +__version__ = '1.1.6' +__version_info__ = (1, 1, 6) + package_dir = path.abspath(path.dirname(__file__)) __ = get_translation(__name__, 'console') diff --git a/sphinxcontrib/serializinghtml/version.py b/sphinxcontrib/serializinghtml/version.py deleted file mode 100644 index a69a9e7..0000000 --- a/sphinxcontrib/serializinghtml/version.py +++ /dev/null @@ -1,10 +0,0 @@ -""" - sphinxcontrib.serializinghtml.version - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - :copyright: Copyright 2007-2019 by the Sphinx team, see README. - :license: BSD, see LICENSE for details. -""" - -__version__ = '1.1.6' -__version_info__ = tuple(map(int, __version__.split('.'))) From 4b94ea930bf9ab7720b437e96981d1c7f129a01b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 17 Mar 2023 00:27:20 +0000 Subject: [PATCH 04/26] Move tool configuration to individual files --- .flake8 | 4 ++++ setup.cfg => babel.cfg | 9 --------- pyproject.toml | 3 +++ 3 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 .flake8 rename setup.cfg => babel.cfg (63%) diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..5af0a95 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 95 +ignore = E116,E241,E251 +exclude = .git,.tox,.venv diff --git a/setup.cfg b/babel.cfg similarity index 63% rename from setup.cfg rename to babel.cfg index dcf63c9..fb9cc94 100644 --- a/setup.cfg +++ b/babel.cfg @@ -6,12 +6,3 @@ keywords = _ __ domain = sphinxcontrib.serializinghtml directory = sphinxcontrib/serializinghtml/locales/ use_fuzzy = true - -[flake8] -max-line-length = 95 -ignore = E116,E241,E251 -exclude = .git,.tox,.venv - -[mypy] -ignore_missing_imports = True -strict_optional = False diff --git a/pyproject.toml b/pyproject.toml index 36bc2fd..f56c7d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,3 +74,6 @@ include = [ exclude = [ "doc/_build", ] + +[tool.mypy] +ignore_missing_imports = true From 4ae674533ed62a2da64e7d69d5be50baa35bc16d Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 16:45:26 +0100 Subject: [PATCH 05/26] Support Python 3.9 and later --- .github/workflows/test.yml | 73 +++++++++++++++----------------------- CHANGES | 2 ++ MANIFEST.in | 8 ----- pyproject.toml | 11 +++--- tox.ini | 12 ++----- 5 files changed, 39 insertions(+), 67 deletions(-) delete mode 100644 MANIFEST.in diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f6f9a8..fe363d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,50 +1,39 @@ name: Test -on: [push, pull_request] +on: + push: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: tests: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev] - max-parallel: 1 + python: + - "3.9" + - "3.10" + - "3.11" + - "3.12-dev" + - "3.13-dev" + fail-fast: false steps: - - name: Print github context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo $GITHUB_CONTEXT - - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: pycache - uses: actions/cache@v2 - id: pycache - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Setup python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - if: "!endsWith(matrix.python-version, '-dev')" - with: - python-version: ${{ matrix.python-version }} - - - name: Setup python ${{ matrix.python-version }} (via deadsnakes) - uses: deadsnakes/action@v2.1.1 - if: "endsWith(matrix.python-version, '-dev')" + - uses: actions/checkout@v3 + - name: Setup Python ${{ matrix.python }} + uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} - - - name: Install tox and test related + python-version: ${{ matrix.python }} + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox tox-gh-actions + python -m pip install --upgrade tox - name: Run tox run: | @@ -58,20 +47,16 @@ jobs: env: [flake8, mypy] steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 1 - + - uses: actions/checkout@v3 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3" - - name: Install tox and any other dependencies for test + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox tox-gh-actions + python -m pip install --upgrade tox - name: Run tox run: tox -e ${{ matrix.env }} diff --git a/CHANGES b/CHANGES index 68bcf58..9be4999 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release 1.1.6 (unreleased) ========================== +* Drop support for Python 3.5, 3.6, 3.7, and 3.8 +* Raise minimum required Sphinx version to 5.0 Release 1.1.5 (2021-05-23) ========================== diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index d4b2097..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -include README.rst -include LICENSE -include CHANGES - -include tox.ini - -recursive-include sphinxcontrib/serializinghtml/locales * -recursive-include tests * diff --git a/pyproject.toml b/pyproject.toml index f56c7d4..8c39008 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ urls.Download = "https://pypi.org/project/sphinxcontrib-serializinghtml/" urls.Homepage = "https://www.sphinx-doc.org/" urls."Issue tracker" = "https://github.com/sphinx-doc/sphinx/issues" license.text = "BSD-2-Clause" -requires-python = ">=3.5" +requires-python = ">=3.9" # Classifiers list: https://pypi.org/classifiers/ classifiers = [ @@ -28,14 +28,11 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "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 :: 3.13", "Framework :: Sphinx", "Framework :: Sphinx :: Extension", "Topic :: Documentation", @@ -43,7 +40,9 @@ classifiers = [ "Topic :: Text Processing", "Topic :: Utilities", ] -dependencies = [] +dependencies = [ + "Sphinx>=5", +] dynamic = ["version"] [project.optional-dependencies] diff --git a/tox.ini b/tox.ini index 83a34fd..0cacfb2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,10 @@ [tox] +minversion = 2.4.0 envlist = - py{36,37,38,39,310-dev}, + py{39,310,311,312,313}, flake8, mypy - -[gh-actions] -python = - 3.6: py36 - 3.7: py37 - 3.8: py38 - 3.9: py39 - 3.10: py310-dev +isolated_build = True [testenv] usedevelop = true From 4d353d2ba3db7da96fe5250c9edf476f7601c946 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 16:46:28 +0100 Subject: [PATCH 06/26] Add GHA release workflow --- .github/workflows/create-release.yml | 90 ++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/create-release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..4599734 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,90 @@ +name: Create release + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish-pypi: + runs-on: ubuntu-latest + name: PyPI Release + environment: release + permissions: + id-token: write # for PyPI trusted publishing + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3 + cache: pip + cache-dependency-path: pyproject.toml + + - name: Install build dependencies (pypa/build, twine) + run: | + pip install -U pip + pip install build twine + + - name: Build distribution + run: python -m build + + - name: Mint PyPI API token + id: mint-token + uses: actions/github-script@v6 + with: + # language=JavaScript + script: | + // retrieve the ambient OIDC token + const oidc_request_token = process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN; + const oidc_request_url = process.env.ACTIONS_ID_TOKEN_REQUEST_URL; + const oidc_resp = await fetch(`${oidc_request_url}&audience=pypi`, { + headers: {Authorization: `bearer ${oidc_request_token}`}, + }); + const oidc_token = (await oidc_resp.json()).value; + + // exchange the OIDC token for an API token + const mint_resp = await fetch('https://pypi.org/_/oidc/github/mint-token', { + method: 'post', + body: `{"token": "${oidc_token}"}` , + headers: {'Content-Type': 'application/json'}, + }); + const api_token = (await mint_resp.json()).token; + + // mask the newly minted API token, so that we don't accidentally leak it + core.setSecret(api_token) + core.setOutput('api-token', api_token) + + - name: Upload to PyPI + env: + TWINE_NON_INTERACTIVE: "true" + TWINE_USERNAME: "__token__" + TWINE_PASSWORD: "${{ steps.mint-token.outputs.api-token }}" + run: | + twine check dist/* + twine upload dist/* + + github-release: + runs-on: ubuntu-latest + name: GitHub release + environment: release + permissions: + contents: write # for softprops/action-gh-release to create GitHub release + steps: + - uses: actions/checkout@v3 + - name: Get release version + id: get_version + uses: actions/github-script@v6 + with: + script: core.setOutput('version', context.ref.replace("refs/tags/v", "")) + + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + name: "sphinxcontrib-serializinghtml ${{ steps.get_version.outputs.version }}" + body: "Changelog: https://www.sphinx-doc.org/en/master/changes.html" From 1fd871586272d5ca886719e780d260c8b572857b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 17:01:37 +0100 Subject: [PATCH 07/26] Invoke pytest directly --- .github/workflows/test.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe363d4..b974e1f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,11 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +env: + FORCE_COLOR: "1" + PYTHONDEVMODE: "1" # -X dev + PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding + jobs: tests: runs-on: ubuntu-latest @@ -33,12 +38,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install --upgrade tox + python -m pip install --upgrade pytest + python -m pip install --upgrade Sphinx @ git+https://github.com/sphinx-doc/sphinx - - name: Run tox - run: | - python -V - tox -- -v --durations=25 + - name: Test with pytest + run: python -m pytest --durations 25 lint: runs-on: ubuntu-latest From 36c1f44dbded564ac9e3e4da701b0cf5debbc410 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 17:05:33 +0100 Subject: [PATCH 08/26] Fix the quoting for installation from git --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b974e1f..54dc417 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade pytest - python -m pip install --upgrade Sphinx @ git+https://github.com/sphinx-doc/sphinx + python -m pip install "Sphinx @ git+https://github.com/sphinx-doc/sphinx" - name: Test with pytest run: python -m pytest --durations 25 From 4f9aaab918d001400a31d4b22aa3042594a9b4fa Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 18:09:02 +0100 Subject: [PATCH 09/26] Fix test failures --- .github/workflows/test.yml | 10 ++++++++-- sphinxcontrib/serializinghtml/__init__.py | 1 + tests/conftest.py | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54dc417..082f9ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,14 +31,20 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Python ${{ matrix.python }} + - name: Set up Python ${{ matrix.python }} uses: actions/setup-python@v4 + if: "!endsWith(matrix.python, '-dev')" + with: + python-version: ${{ matrix.python }} + - name: Set up Python ${{ matrix.python }} (deadsnakes) + uses: deadsnakes/action@v2.1.1 + if: "endsWith(matrix.python, '-dev')" with: python-version: ${{ matrix.python }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install --upgrade pytest + python -m pip install .[test] python -m pip install "Sphinx @ git+https://github.com/sphinx-doc/sphinx" - name: Test with pytest diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index ff800a0..1da7fad 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -86,6 +86,7 @@ def handle_page(self, pagename, ctx, templatename='page.html', outfilename=None, event_arg=None): # type: (str, Dict, str, str, Any) -> None ctx['current_page_name'] = pagename + ctx.setdefault('pathto', lambda p: p) self.add_sidebars(pagename, ctx) if not outfilename: diff --git a/tests/conftest.py b/tests/conftest.py index ae725dc..c80a172 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,13 +6,13 @@ :license: BSD, see LICENSE for details. """ -import pytest +from pathlib import Path -from sphinx.testing.path import path +import pytest pytest_plugins = 'sphinx.testing.fixtures' @pytest.fixture(scope='session') def rootdir(): - return path(__file__).parent.abspath() / 'roots' + return Path(__file__).resolve().parent / 'roots' From 14b29318ea3b011149f61c7d6b3ac8bb5287cf13 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 18:54:06 +0100 Subject: [PATCH 10/26] Fix mypy errors --- sphinxcontrib/serializinghtml/__init__.py | 10 +++++----- tox.ini | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 1da7fad..f29887a 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -56,9 +56,9 @@ def init(self): # type: () -> None self.build_info = BuildInfo(self.config, self.tags) self.imagedir = '_images' - self.current_docname = None - self.theme = None # no theme necessary - self.templates = None # no template bridge necessary + self.current_docname = '' + self.theme = None # type: ignore[assignment] # no theme necessary + self.templates = None # no template bridge necessary self.init_templates() self.init_highlighter() self.init_css_files() @@ -66,7 +66,7 @@ def init(self): self.use_index = self.get_builder_config('use_index', 'html') def get_target_uri(self, docname, typ=None): - # type: (str, str) -> str + # type: (str, str | None) -> str if docname == 'index': return '' if docname.endswith(SEP + 'index'): @@ -84,7 +84,7 @@ def dump_context(self, context, filename): def handle_page(self, pagename, ctx, templatename='page.html', outfilename=None, event_arg=None): - # type: (str, Dict, str, str, Any) -> None + # type: (str, Dict, str, str | None, Any) -> None ctx['current_page_name'] = pagename ctx.setdefault('pathto', lambda p: p) self.add_sidebars(pagename, ctx) diff --git a/tox.ini b/tox.ini index 0cacfb2..9ad9f73 100644 --- a/tox.ini +++ b/tox.ini @@ -34,4 +34,4 @@ extras = test lint commands= - mypy sphinxcontrib/ + mypy sphinxcontrib/ --explicit-package-bases From 2dc77711a162723bed196a747cbbbf710300a84c Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:17:51 +0100 Subject: [PATCH 11/26] Convert type comments to annotations --- sphinxcontrib/serializinghtml/__init__.py | 33 +++++++++-------------- sphinxcontrib/serializinghtml/jsonimpl.py | 22 ++++++--------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index f29887a..e710527 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -6,10 +6,12 @@ :license: BSD, see LICENSE for details. """ +from __future__ import annotations + import pickle import types from os import path -from typing import Any, Dict +from typing import Any from sphinx.application import ENV_PICKLE_FILENAME, Sphinx from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder @@ -18,10 +20,6 @@ from sphinxcontrib.serializinghtml import jsonimpl -if False: - # For type annotation - from typing import Any, Dict, Tuple # NOQA - __version__ = '1.1.6' __version_info__ = (1, 1, 6) @@ -41,19 +39,18 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder): #: the serializing implementation to use. Set this to a module that #: implements a `dump`, `load`, `dumps` and `loads` functions #: (pickle, simplejson etc.) - implementation = None # type: Any + implementation: Any = None implementation_dumps_unicode = False #: additional arguments for dump() - additional_dump_args = () # type: Tuple + additional_dump_args = () #: the filename for the global context file - globalcontext_filename = None # type: str + globalcontext_filename: str | None = None supported_image_types = ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg'] - def init(self): - # type: () -> None + def init(self) -> None: self.build_info = BuildInfo(self.config, self.tags) self.imagedir = '_images' self.current_docname = '' @@ -65,16 +62,14 @@ def init(self): self.init_js_files() self.use_index = self.get_builder_config('use_index', 'html') - def get_target_uri(self, docname, typ=None): - # type: (str, str | None) -> str + def get_target_uri(self, docname: str, typ: str | None = None) -> str: if docname == 'index': return '' if docname.endswith(SEP + 'index'): return docname[:-5] # up to sep return docname + SEP - def dump_context(self, context, filename): - # type: (Dict, str) -> None + def dump_context(self, context: dict, filename: str) -> None: if self.implementation_dumps_unicode: with open(filename, 'w', encoding='utf-8') as ft: self.implementation.dump(context, ft, *self.additional_dump_args) @@ -82,9 +77,8 @@ def dump_context(self, context, filename): with open(filename, 'wb') as fb: self.implementation.dump(context, fb, *self.additional_dump_args) - def handle_page(self, pagename, ctx, templatename='page.html', - outfilename=None, event_arg=None): - # type: (str, Dict, str, str | None, Any) -> None + def handle_page(self, pagename: str, ctx: dict, templatename: str = 'page.html', + outfilename: str | None = None, event_arg: Any = None) -> None: ctx['current_page_name'] = pagename ctx.setdefault('pathto', lambda p: p) self.add_sidebars(pagename, ctx) @@ -113,8 +107,7 @@ def handle_page(self, pagename, ctx, templatename='page.html', ensuredir(path.dirname(source_name)) copyfile(self.env.doc2path(pagename), source_name) - def handle_finish(self): - # type: () -> None + def handle_finish(self) -> None: # dump the global context outfilename = path.join(self.outdir, self.globalcontext_filename) self.dump_context(self.globalcontext, outfilename) @@ -165,7 +158,7 @@ class JSONHTMLBuilder(SerializingHTMLBuilder): searchindex_filename = 'searchindex.json' -def setup(app: Sphinx) -> Dict[str, Any]: +def setup(app: Sphinx) -> dict[str, Any]: app.setup_extension('sphinx.builders.html') app.add_builder(JSONHTMLBuilder) app.add_builder(PickleHTMLBuilder) diff --git a/sphinxcontrib/serializinghtml/jsonimpl.py b/sphinxcontrib/serializinghtml/jsonimpl.py index ecb0b79..8c14cca 100644 --- a/sphinxcontrib/serializinghtml/jsonimpl.py +++ b/sphinxcontrib/serializinghtml/jsonimpl.py @@ -8,40 +8,34 @@ :license: BSD, see LICENSE for details. """ +from __future__ import annotations + import json from collections import UserString - -if False: - # For type annotation - from typing import Any, IO # NOQA +from typing import Any, IO class SphinxJSONEncoder(json.JSONEncoder): """JSONEncoder subclass that forces translation proxies.""" - def default(self, obj): - # type: (Any) -> str + def default(self, obj: Any) -> str: if isinstance(obj, UserString): return str(obj) return super().default(obj) -def dump(obj, fp, *args, **kwds): - # type: (Any, IO, Any, Any) -> None +def dump(obj: Any, fp: IO, *args: Any, **kwds: Any) -> None: kwds['cls'] = SphinxJSONEncoder json.dump(obj, fp, *args, **kwds) -def dumps(obj, *args, **kwds): - # type: (Any, Any, Any) -> str +def dumps(obj: Any, *args: Any, **kwds: Any) -> str: kwds['cls'] = SphinxJSONEncoder return json.dumps(obj, *args, **kwds) -def load(*args, **kwds): - # type: (Any, Any) -> Any +def load(*args: Any, **kwds: Any) -> Any: return json.load(*args, **kwds) -def loads(*args, **kwds): - # type: (Any, Any) -> Any +def loads(*args: Any, **kwds: Any) -> Any: return json.loads(*args, **kwds) From 91f89bd6b2433222e659b912222b7a892d0a4572 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:26:55 +0100 Subject: [PATCH 12/26] fixup! Convert type comments to annotations --- sphinxcontrib/serializinghtml/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index e710527..bf1d0f4 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -8,6 +8,7 @@ from __future__ import annotations +import os import pickle import types from os import path @@ -42,10 +43,10 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder): implementation: Any = None implementation_dumps_unicode = False #: additional arguments for dump() - additional_dump_args = () + additional_dump_args: tuple = () #: the filename for the global context file - globalcontext_filename: str | None = None + globalcontext_filename: str = '' supported_image_types = ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg'] @@ -69,7 +70,7 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str: return docname[:-5] # up to sep return docname + SEP - def dump_context(self, context: dict, filename: str) -> None: + def dump_context(self, context: dict, filename: str | os.PathLike[str]) -> None: if self.implementation_dumps_unicode: with open(filename, 'w', encoding='utf-8') as ft: self.implementation.dump(context, ft, *self.additional_dump_args) @@ -109,7 +110,7 @@ def handle_page(self, pagename: str, ctx: dict, templatename: str = 'page.html', def handle_finish(self) -> None: # dump the global context - outfilename = path.join(self.outdir, self.globalcontext_filename) + outfilename = self.outdir / self.globalcontext_filename self.dump_context(self.globalcontext, outfilename) # super here to dump the search index From 1ab1f8ca9b2df2745ba94150ba8ffd99533f0546 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:47:10 +0100 Subject: [PATCH 13/26] Remove module titles in docstrings --- sphinxcontrib/serializinghtml/__init__.py | 8 -------- sphinxcontrib/serializinghtml/jsonimpl.py | 10 +--------- tests/conftest.py | 8 -------- tests/test_serializinghtml.py | 10 +--------- 4 files changed, 2 insertions(+), 34 deletions(-) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index bf1d0f4..6f2c8b8 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -1,11 +1,3 @@ -""" - sphinxcontrib.serializinghtml - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - :copyright: Copyright 2007-2019 by the Sphinx team, see README. - :license: BSD, see LICENSE for details. -""" - from __future__ import annotations import os diff --git a/sphinxcontrib/serializinghtml/jsonimpl.py b/sphinxcontrib/serializinghtml/jsonimpl.py index 8c14cca..e80c047 100644 --- a/sphinxcontrib/serializinghtml/jsonimpl.py +++ b/sphinxcontrib/serializinghtml/jsonimpl.py @@ -1,12 +1,4 @@ -""" - sphinx.util.jsonimpl - ~~~~~~~~~~~~~~~~~~~~ - - JSON serializer implementation wrapper. - - :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" +"""JSON serializer implementation wrapper.""" from __future__ import annotations diff --git a/tests/conftest.py b/tests/conftest.py index c80a172..bad18f1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,3 @@ -""" - pytest config for sphinx extensions - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" - from pathlib import Path import pytest diff --git a/tests/test_serializinghtml.py b/tests/test_serializinghtml.py index e04a201..b6f6380 100644 --- a/tests/test_serializinghtml.py +++ b/tests/test_serializinghtml.py @@ -1,12 +1,4 @@ -""" - test_serializinghtml - ~~~~~~~~~~~~~~~~~~~~ - - Test for serializinghtml extension. - - :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" +"""Test for serializinghtml extension.""" import pytest From dc42c86e7dd1291f6dc8a4eea77270ed62833637 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:58:05 +0100 Subject: [PATCH 14/26] Add a workflow to synchronisation translations --- .github/transifex.yml | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/transifex.yml diff --git a/.github/transifex.yml b/.github/transifex.yml new file mode 100644 index 0000000..b0427ac --- /dev/null +++ b/.github/transifex.yml @@ -0,0 +1,75 @@ +name: Synchronise translations + +on: + schedule: + # 22:38 GMT, every Sunday. Chosen to be a random time. + - cron: "38 22 * * SUN" + workflow_dispatch: + +permissions: + contents: read + +jobs: + push: + if: github.repository_owner == 'sphinx-doc' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3 + - name: Install transifex client + run: | + mkdir -p /tmp/tx_cli && cd $_ + curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash + shell: bash + - name: Install dependencies + run: pip install --upgrade babel jinja2 + - name: Extract translations from source code + run: python utils/babel_runner.py extract + - name: Push translations to transifex.com + run: | + cd sphinxcontrib/serializinghtml/locales + /tmp/tx_cli/tx push --source --use-git-timestamps --workers 10 + env: + TX_TOKEN: ${{ secrets.TX_TOKEN }} + + pull: + permissions: + contents: write # for peter-evans/create-pull-request to create branch + pull-requests: write # for peter-evans/create-pull-request to create a PR + if: github.repository_owner == 'sphinx-doc' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3 + - name: Install transifex client + run: | + mkdir -p /tmp/tx_cli && cd $_ + curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash + shell: bash + - name: Install dependencies + run: pip install --upgrade babel jinja2 + - name: Extract translations from source code + run: python utils/babel_runner.py extract + - name: Pull translations from transifex.com + run: | + cd sphinxcontrib/serializinghtml/locales + /tmp/tx_cli/tx pull --translations --all --force --use-git-timestamps --workers 10 + env: + TX_TOKEN: ${{ secrets.TX_TOKEN }} + - name: Compile message catalogs + run: python utils/babel_runner.py compile + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + commit-message: "[internationalisation] Update translations" + branch: bot/pull-translations + title: "[bot]: Update message catalogues" + labels: "internals:internationalisation" From de983ce7af7f9d6c086c2f9497090d745cfce343 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 20:00:11 +0100 Subject: [PATCH 15/26] Remove outdated sections from README --- README.rst | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/README.rst b/README.rst index c37d036..d9ed40a 100644 --- a/README.rst +++ b/README.rst @@ -14,23 +14,6 @@ Install from PyPI:: pip install -U sphinxcontrib-serializinghtml -Release signatures -================== - -Releases are signed with following keys: - -* `498D6B9E `_ -* `5EBA0E07 `_ - -Testing -======= - -To run the tests with the interpreter available as ``python``, use:: - - tox - -Continuous testing runs on travis: https://travis-ci.org/sphinx-doc/sphinxcontrib-serializinghtml - Contributing ============ From a79c223995f9f6a7039e916378bf6e877ac77e6d Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 20:10:27 +0100 Subject: [PATCH 16/26] Fix tag pattern --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 4599734..df853e7 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -3,7 +3,7 @@ name: Create release on: push: tags: - - "v*.*.*" + - "*.*.*" workflow_dispatch: permissions: From 9ad2844331739f18e59177dce02c749459f08e18 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 20:03:26 +0100 Subject: [PATCH 17/26] Bump to 1.1.6 final --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 9be4999..0c534dc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -Release 1.1.6 (unreleased) +Release 1.1.6 (2023-08-07) ========================== * Drop support for Python 3.5, 3.6, 3.7, and 3.8 From 5b964aed7db1368cc203fbfcb618b655cb2177b1 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 20:39:52 +0100 Subject: [PATCH 18/26] Fix GitHub Release workflow --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index df853e7..857607f 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -80,7 +80,7 @@ jobs: id: get_version uses: actions/github-script@v6 with: - script: core.setOutput('version', context.ref.replace("refs/tags/v", "")) + script: core.setOutput('version', context.ref.replace("refs/tags/", "")) - name: Create GitHub release uses: softprops/action-gh-release@v1 From 010ed5629dd70e77c6df7cf753e6c93270254811 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:02:57 +0100 Subject: [PATCH 19/26] Test Sphinx's master branch distinctly from ordinary tests --- .github/workflows/test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 082f9ee..c459016 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,23 @@ jobs: if: "endsWith(matrix.python, '-dev')" with: python-version: ${{ matrix.python }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install .[test] + + - name: Test with pytest + run: python -m pytest --durations 25 + + test-latest-sphinx: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: "3" - name: Install dependencies run: | python -m pip install --upgrade pip From 5c00ac15e2ade99e99f36402b1f6befb1be1affa Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:08:03 +0100 Subject: [PATCH 20/26] Run pytest with ``-vv`` --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c459016..794d170 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,7 @@ jobs: python -m pip install .[test] - name: Test with pytest - run: python -m pytest --durations 25 + run: python -m pytest -vv --durations 25 test-latest-sphinx: runs-on: ubuntu-latest @@ -65,7 +65,7 @@ jobs: python -m pip install "Sphinx @ git+https://github.com/sphinx-doc/sphinx" - name: Test with pytest - run: python -m pytest --durations 25 + run: python -m pytest -vv --durations 25 lint: runs-on: ubuntu-latest From 4ba0bbc9cd166a2512d7e3a502fa8159f3669685 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:16:32 +0100 Subject: [PATCH 21/26] Restore support in tests for ``Sphinx<7.2`` --- tests/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index bad18f1..d4b08e5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,9 +2,16 @@ import pytest +import sphinx + pytest_plugins = 'sphinx.testing.fixtures' @pytest.fixture(scope='session') def rootdir(): + if sphinx.version_info[:2] < (7, 2): + from sphinx.testing.path import path + + return path(__file__).parent.abspath() / 'roots' + return Path(__file__).resolve().parent / 'roots' From 957d087692515b6cdd918ebd0c99591b7d04f76f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:11:29 +0100 Subject: [PATCH 22/26] Bump to 1.1.7 final --- CHANGES | 5 +++++ sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 0c534dc..405ed78 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Release 1.1.7 (2023-08-09) +========================== + +* Fix tests for Sphinx 7.1 and below + Release 1.1.6 (2023-08-07) ========================== diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 6f2c8b8..6a0b54e 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -13,8 +13,8 @@ from sphinxcontrib.serializinghtml import jsonimpl -__version__ = '1.1.6' -__version_info__ = (1, 1, 6) +__version__ = '1.1.7' +__version_info__ = (1, 1, 7) package_dir = path.abspath(path.dirname(__file__)) From b3ed89b4b2bf9eee553ff2272ae97fc5c0a9bc31 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:42:11 +0100 Subject: [PATCH 23/26] Use ``os.PathLike`` over ``pathlib.Path`` Sphinx 7.1 and earlier don't use ``pathlib`` internally. --- sphinxcontrib/serializinghtml/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 6a0b54e..26a5386 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -102,7 +102,7 @@ def handle_page(self, pagename: str, ctx: dict, templatename: str = 'page.html', def handle_finish(self) -> None: # dump the global context - outfilename = self.outdir / self.globalcontext_filename + outfilename = path.join(self.outdir, self.globalcontext_filename) self.dump_context(self.globalcontext, outfilename) # super here to dump the search index From fde139af6b2bfad8a6b8d20886b657a174f05c22 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 14 Aug 2023 17:09:41 +0100 Subject: [PATCH 24/26] Bump to 1.1.8 final --- CHANGES | 5 +++++ sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 405ed78..812c0fc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Release 1.1.8 (2023-08-14) +========================== + +* Use ``os.PathLike`` over ``pathlib.Path`` + Release 1.1.7 (2023-08-09) ========================== diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 26a5386..99b6fb9 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -13,8 +13,8 @@ from sphinxcontrib.serializinghtml import jsonimpl -__version__ = '1.1.7' -__version_info__ = (1, 1, 7) +__version__ = '1.1.8' +__version_info__ = (1, 1, 8) package_dir = path.abspath(path.dirname(__file__)) From 5c62ad4219698d410426e99495203e9484d77f29 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 21 Aug 2023 00:20:10 +0100 Subject: [PATCH 25/26] Properly serialise css_files and script_files --- sphinxcontrib/serializinghtml/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 99b6fb9..22836e8 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -63,6 +63,11 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str: return docname + SEP def dump_context(self, context: dict, filename: str | os.PathLike[str]) -> None: + context = context.copy() + if 'css_files' in context: + context['css_files'] = [css.filename for css in context['css_files']] + if 'script_files' in context: + context['script_files'] = [js.filename for js in context['script_files']] if self.implementation_dumps_unicode: with open(filename, 'w', encoding='utf-8') as ft: self.implementation.dump(context, ft, *self.additional_dump_args) From ff4bcae545fb6e5b923cc51cc37944c18307a49a Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 21 Aug 2023 00:26:37 +0100 Subject: [PATCH 26/26] Bump to 1.1.9 final --- CHANGES | 6 ++++++ sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 812c0fc..c91fed7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Release 1.1.9 (2023-08-20) +========================== + +* Serialise context["script_files"] and context["css_files"] as their filenames + on Sphinx 7.2.0. + Release 1.1.8 (2023-08-14) ========================== diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 22836e8..8940d80 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -13,8 +13,8 @@ from sphinxcontrib.serializinghtml import jsonimpl -__version__ = '1.1.8' -__version_info__ = (1, 1, 8) +__version__ = '1.1.9' +__version_info__ = (1, 1, 9) package_dir = path.abspath(path.dirname(__file__))