From 0f431aeeb13821df6b9ff4b6c0187d53dde88ecb Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 13 Jun 2023 22:02:29 +0300 Subject: [PATCH 1/2] Docs: move sphinx-lint to pre-commit --- .github/workflows/reusable-docs.yml | 4 ---- .pre-commit-config.yaml | 8 ++++++++ Doc/Makefile | 8 +++----- Doc/constraints.txt | 4 ---- Doc/requirements.txt | 1 - 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 9c1ed2788080dc..f8e166b780b3ed 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -26,8 +26,6 @@ jobs: cache-dependency-path: 'Doc/requirements.txt' - name: 'Install build dependencies' run: make -C Doc/ venv - - name: 'Check documentation' - run: make -C Doc/ check - name: 'Build HTML documentation' run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html - name: 'Upload' @@ -37,8 +35,6 @@ jobs: path: Doc/build/html # This build doesn't use problem matchers or check annotations - # It also does not run 'make check', as sphinx-lint is not installed into the - # environment. build_doc_oldest_supported_sphinx: name: 'Docs (Oldest Sphinx)' runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 808622f19a3dbf..adf28b9081a152 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,3 +5,11 @@ repos: - id: check-yaml - id: trailing-whitespace types_or: [c, python, rst] + + - repo: https://github.com/sphinx-contrib/sphinx-lint + rev: v0.6.8 + hooks: + - id: sphinx-lint + args: [--enable=default-role] + files: ^Doc/ + types: [rst] diff --git a/Doc/Makefile b/Doc/Makefile index 918814140f45cb..55be2b2dc5c1e6 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -214,11 +214,9 @@ dist: rm -r dist/python-$(DISTVERSION)-docs-texinfo rm dist/python-$(DISTVERSION)-docs-texinfo.tar -check: - # Check the docs and NEWS files with sphinx-lint. - # Ignore the tools and venv dirs and check that the default role is not used. - $(SPHINXLINT) -i tools -i $(VENVDIR) --enable default-role - $(SPHINXLINT) --enable default-role ../Misc/NEWS.d/next/ +check: venv + $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit + $(VENVDIR)/bin/python3 -m pre_commit run --all-files serve: @echo "The serve target was removed, use htmlview instead (see bpo-36329)" diff --git a/Doc/constraints.txt b/Doc/constraints.txt index 66c748eb092d83..54888eaab242ee 100644 --- a/Doc/constraints.txt +++ b/Doc/constraints.txt @@ -23,7 +23,3 @@ sphinxcontrib-serializinghtml<1.2 # Direct dependencies of Jinja2 (Jinja is a dependency of Sphinx, see above) MarkupSafe<2.2 - -# Direct dependencies of sphinx-lint -polib<1.3 -regex<2024 diff --git a/Doc/requirements.txt b/Doc/requirements.txt index 3c0e0a7733673e..df79ae63840471 100644 --- a/Doc/requirements.txt +++ b/Doc/requirements.txt @@ -10,7 +10,6 @@ sphinx==4.5.0 blurb -sphinx-lint==0.6.7 sphinxext-opengraph>=0.7.1 # The theme used by the documentation is stored separately, so we need From e1aa16e00785c95454ba9ac5f756af51d201417b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 21 Aug 2023 14:52:02 +0300 Subject: [PATCH 2/2] Run sphinx-lint on Misc/NEWS.d/next/ --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index adf28b9081a152..889bd8502a10ea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,5 +11,5 @@ repos: hooks: - id: sphinx-lint args: [--enable=default-role] - files: ^Doc/ + files: ^Doc/|^Misc/NEWS.d/next/ types: [rst]