From 1be8e3e2e0649fc01daad860c43ff5acb8bcda40 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 15 Oct 2023 12:36:20 +0200 Subject: [PATCH 1/5] Improve usability of Sphinx Lint with pre-commit --- .pre-commit-hooks.yaml | 5 +++-- README.md | 12 ++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 8fda5eb14..c32ee6a2d 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,7 +1,8 @@ - id: sphinx-lint - name: Sphinx lint + name: Sphinx Lint description: 'Searches for common typos in sphinx-flavored rst files.' files: '\.rst$' + # Defer to pre-commit on the best way to delegate resources across available cores + args: [--jobs=1] entry: sphinx-lint language: python - diff --git a/README.md b/README.md index dd8352119..c1bf07378 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ CPython](https://github.com/python/cpython/blob/e0433c1e7/Doc/tools/rstlint.py). ## What is Sphinx Lint, what is it not? -`sphinx-lint` should: +Sphinx Lint should: - be reasonably fast so it's comfortable to use as a linter in your editor. - be usable on a single file. @@ -23,7 +23,7 @@ CPython](https://github.com/python/cpython/blob/e0433c1e7/Doc/tools/rstlint.py). ## Using Sphinx Lint -To use Sphinx Lint, run: +Here are some example invocationsn of Sphinx Lint from the command line: ```sh sphinx-lint # check all dirs and files @@ -41,17 +41,9 @@ We recommend using a configuration like this: rev: LATEST_SPHINXLINT_RELEASE_TAG hooks: - id: sphinx-lint - args: [--jobs=1] types: [rst] ``` -In particular, note that the `--jobs=1` flag is recommended for use with pre-commit. -By default, Sphinx Lint uses `multiprocessing` to lint multiple files simultaneously, -but this interacts poorly with pre-commit, which also attempts to use multiprocessing, -leading to resource contention. Adding `--jobs=1` tells Sphinx Lint not to use -multiprocessing itself, deferring to pre-commit on the best way to delegate resources -across available cores. - ## Known issues From 42113581dbe1333de85f63192788b0247cc25029 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 15 Oct 2023 12:38:29 +0200 Subject: [PATCH 2/5] . --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1bf07378..3225ec8b7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Sphinx Lint should: ## Using Sphinx Lint -Here are some example invocationsn of Sphinx Lint from the command line: +Here are some example invocations of Sphinx Lint from the command line: ```sh sphinx-lint # check all dirs and files From df084de942270a6095c34f3d42144c36872ef590 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 15 Oct 2023 13:49:42 +0200 Subject: [PATCH 3/5] Apply suggestions from code review --- .pre-commit-hooks.yaml | 1 + README.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index c32ee6a2d..9a3634dea 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -2,6 +2,7 @@ name: Sphinx Lint description: 'Searches for common typos in sphinx-flavored rst files.' files: '\.rst$' + types: [rst] # Defer to pre-commit on the best way to delegate resources across available cores args: [--jobs=1] entry: sphinx-lint diff --git a/README.md b/README.md index 3225ec8b7..afb5200ee 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ We recommend using a configuration like this: rev: LATEST_SPHINXLINT_RELEASE_TAG hooks: - id: sphinx-lint - types: [rst] ``` From f77b765b833ad7084c8c78ff8aa2d21ec660719d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 15 Oct 2023 17:25:10 +0100 Subject: [PATCH 4/5] Update .pre-commit-hooks.yaml --- .pre-commit-hooks.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 9a3634dea..91e7455eb 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,7 +1,6 @@ - id: sphinx-lint name: Sphinx Lint description: 'Searches for common typos in sphinx-flavored rst files.' - files: '\.rst$' types: [rst] # Defer to pre-commit on the best way to delegate resources across available cores args: [--jobs=1] From dc1702a137fd8a1e1f358dbadcc426c404eaae78 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 15 Oct 2023 17:45:16 +0100 Subject: [PATCH 5/5] Update .pre-commit-hooks.yaml Co-authored-by: Hugo van Kemenade --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 91e7455eb..61bc67b71 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,6 +1,6 @@ - id: sphinx-lint name: Sphinx Lint - description: 'Searches for common typos in sphinx-flavored rst files.' + description: 'Searches for common problems in Sphinx-flavored reST files' types: [rst] # Defer to pre-commit on the best way to delegate resources across available cores args: [--jobs=1]