Lint RST on GitHub Actions #1802
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New version of #1668, main difference is the linter has been updated so the
rst-backticks
skips code blocks (lines beginning with four spaces).Lint rules
This PR adds two reStructuredText lint rules and runs them on the CI using GitHub Actions. Example run.
Detect single backticks, which should be double in RST for inline code, e.g. stuff fixed in Fix RST backticks #1554.
Detect inline code touching normal text, e.g. stuff fixed in Fix incorrect backticks #1560.
make lint
It adds a standalone
make
command to lint locally:The pre-commit dependency is installed if needed.
Optional git pre-commit hook
This uses the pre-commit tool for linting. It's possible, but completely optional, to use it locally and it'll check your changes when you're committing, and fail before commit if something is found.
Optional local set up (run once):
pip install -U pre-commit && pre-commit install
Then make changes and commit as normal:
git commit -m "PEP XXX: etc"
Lint all files:
pre-commit run --all-files # Or this does the same thing make lint
The very first run takes a little while to set things up, after that it's quick.
But again, local use of pre-commit is completely optional for those who aren't keen, and the CI will run the checks anyway.
And
make lint
can be used completely independently of the git pre-commit hook.