Skip to content

Commit 4cecfc7

Browse files
AlexWaygoodhugovkezio-melotti
authored
Add docs on how best to use sphinx-lint with pre-commit (#90)
Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: Ezio Melotti <[email protected]>
1 parent 881f0d5 commit 4cecfc7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,37 @@ CPython](https://github.com/python/cpython/blob/e0433c1e7/Doc/tools/rstlint.py).
2121
- focus on finding errors that are **not** visible to sphinx-build.
2222

2323

24+
## Using Sphinx Lint
25+
26+
To use Sphinx Lint, run:
27+
28+
```sh
29+
sphinx-lint # check all dirs and files
30+
sphinx-lint file.rst # check a single file
31+
sphinx-lint docs # check a directory
32+
sphinx-lint -i venv # ignore a file/directory
33+
sphinx-lint -h # for more options
34+
35+
Sphinx Lint can also be used via [pre-commit](https://pre-commit.com).
36+
We recommend using a configuration like this:
37+
38+
```yaml
39+
- repo: https://github.com/sphinx-contrib/sphinx-lint
40+
rev: LATEST_SPHINXLINT_RELEASE_TAG
41+
hooks:
42+
- id: sphinx-lint
43+
args: [--jobs=1]
44+
types: [rst]
45+
```
46+
47+
In particular, note that the `--jobs=1` flag is recommended for use with pre-commit.
48+
By default, Sphinx Lint uses `multiprocessing` to lint multiple files simultaneously,
49+
but this interacts poorly with pre-commit, which also attempts to use multiprocessing,
50+
leading to resource contention. Adding `--jobs=1` tells Sphinx Lint not to use
51+
multiprocessing itself, deferring to pre-commit on the best way to delegate resources
52+
across available cores.
53+
54+
2455
## Known issues
2556

2657
Currently Sphinx Lint can't work with tables, there's no understanding

0 commit comments

Comments
 (0)