Check for stylistic and formal issues in .rst and .py files included in the documentation.
Project Links
Meta
Author: Georg Brandl, Julien Palard
Requires Python: >=3.8
Classifiers
Development Status
- 5 - Production/Stable
Intended Audience
- Developers
License
- OSI Approved :: Python Software Foundation License
Natural Language
- English
Programming Language
- Python :: 3
Topic
- Documentation :: Sphinx
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.
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
First test with friends projects by running:
sh download-more-tests.sh
python -m pytest
Bump the version in sphinxlint.py
, commit, tag, push:
git tag v0.6.5
git push
git push --tags
To release on PyPI run:
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*
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.
Sep 11, 2024
1.0.0
Dec 12, 2023
0.9.1
Nov 22, 2023
0.9.0
Nov 12, 2023
0.8.2
Oct 16, 2023
0.8.1
Oct 15, 2023
0.8.0
Oct 13, 2023
0.7.0
Jul 20, 2023
0.6.8
Oct 18, 2022
0.6.7
Oct 07, 2022
0.6.6
Oct 06, 2022
0.6.5
Oct 06, 2022
0.6.4
Oct 06, 2022
0.6.3
Oct 06, 2022
0.6.2
Jun 18, 2022
0.6.1
May 23, 2022
0.6
May 13, 2022
0.5
Apr 29, 2022
0.4.1
Apr 25, 2022
0.4
Apr 24, 2022
0.3
Apr 05, 2022
0.2
Feb 02, 2022
0.1