Check for stylistic and formal issues in .rst and .py files included in the documentation.
Project description
Sphinx Lint
Sphinx Lint is based on rstlint.py from CPython.
What is Sphinx Lint, what is it not?
Sphinx Lint should:
- be reasonably fast so it's comfortable to use as a linter in your editor.
- be usable on a single file.
- not give any false positives (probably a utopia, but let's try).
- not spend too much effort finding errors that sphinx-build already finds (or can easily find).
- focus on finding errors that are not visible to sphinx-build.
Using Sphinx Lint
Here are some example invocations of Sphinx Lint from the command line:
sphinx-lint # check all dirs and files
sphinx-lint file.rst # check a single file
sphinx-lint docs # check a directory
sphinx-lint -i venv # ignore a file/directory
sphinx-lint -h # for more options
Sphinx Lint can also be used via pre-commit. We recommend using a configuration like this:
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: LATEST_SPHINXLINT_RELEASE_TAG
hooks:
- id: sphinx-lint
Known issues
Currently Sphinx Lint can't work with tables, there's no understanding
of how linesplit
works in tables, like:
+-----------------------------------------+-----------------------------+---------------+
| Method | Checks that | New in |
+=========================================+=============================+===============+
| :meth:`assertEqual(a, b) | ``a == b`` | |
| <TestCase.assertEqual>` | | |
+-----------------------------------------+-----------------------------+---------------+
as Sphinx Lint works line by line it will inevitably think the :meth:
role is not closed properly.
To avoid false positives, some rules are skipped if we're in a table.
Contributing
A quick way to test if some syntax is valid from a pure
reStructuredText point of view, one case use docutils
's pseudoxml
writer, like:
$ docutils --writer=pseudoxml tests/fixtures/xpass/role-in-code-sample.rst
<document source="tests/fixtures/xpass/role-in-code-sample.rst">
<paragraph>
Found in the pandas documentation, this is valid:
<bullet_list bullet="*">
<list_item>
<paragraph>
A pandas class (in the form
<literal>
:class:`pandas.Series`
)
<list_item>
<paragraph>
A pandas method (in the form
<literal>
:meth:`pandas.Series.sum`
)
<list_item>
<paragraph>
A pandas function (in the form
<literal>
:func:`pandas.to_datetime`
)
<paragraph>
it's documenting roles using code samples (double backticks).
Releasing
-
Make sure that the CI tests pass and optionally double-check locally with "friends projects" by running:
sh download-more-tests.sh python -m pytest
-
Go on the Releases page
-
Click "Draft a new release"
-
Click "Choose a tag"
-
Type the next vX.Y.Z version and select "Create new tag: vX.Y.Z on publish"
-
Leave the "Release title" blank (it will be autofilled)
-
Click "Generate release notes" and amend as required
-
Click "Publish release"
-
Check the tagged GitHub Actions build has deployed to PyPI
License
As this script was in the CPython repository the license is the Python Software Foundation Licence Version 2, see the LICENSE file for a full version.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sphinx_lint-1.0.0.tar.gz
.
File metadata
- Download URL: sphinx_lint-1.0.0.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eafdb44172ce526f405bf36c713eb246f1340ec2d667e7298e2487ed76decd2 |
|
MD5 | 3864c119e5a3f719de818f4187b2c76c |
|
BLAKE2b-256 | cf46f2dad36a4076e9ce88498b25b3f0de82eb7d341ea0ef715cd6c48005bcef |
File details
Details for the file sphinx_lint-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: sphinx_lint-1.0.0-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6117a0f340b2dc73eadfc57db7531d4477e0929f92a0c1a2f61e6edbc272f0bc |
|
MD5 | ef0a63dce0e4e63ff152ddb09507d6e2 |
|
BLAKE2b-256 | 31d2a130ffba531af7cbbb0e7ad24c7d577d3de0b797437f61d3a7234ed6d836 |