Skip to content

Commit

Permalink
Improve usability of Sphinx Lint with pre-commit (#94)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo van Kemenade <[email protected]>
  • Loading branch information
AlexWaygood and hugovk authored Oct 15, 2023
1 parent 84d17a7 commit dbccac0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
- id: sphinx-lint
name: Sphinx lint
description: 'Searches for common typos in sphinx-flavored rst files.'
files: '\.rst$'
name: Sphinx Lint
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]
entry: sphinx-lint
language: python

13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 invocations of Sphinx Lint from the command line:

```sh
sphinx-lint # check all dirs and files
Expand All @@ -41,17 +41,8 @@ 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
Expand Down

0 comments on commit dbccac0

Please sign in to comment.