Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usability of Sphinx Lint with pre-commit #94

Merged
merged 5 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 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
name: Sphinx Lint
description: 'Searches for common typos in sphinx-flavored rst files.'
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
files: '\.rst$'
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
# Defer to pre-commit on the best way to delegate resources across available cores
args: [--jobs=1]
entry: sphinx-lint
language: python

12 changes: 2 additions & 10 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,9 @@ We recommend using a configuration like this:
rev: LATEST_SPHINXLINT_RELEASE_TAG
hooks:
- id: sphinx-lint
args: [--jobs=1]
types: [rst]
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
```

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