Skip to main content

Check for stylistic and formal issues in .rst and .py files included in the documentation.

Project description

Sphinx Lint

PyPI Monthly downloads Supported Python Version GitHub Workflow Status

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx-lint-0.6.8.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

sphinx_lint-0.6.8-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file sphinx-lint-0.6.8.tar.gz.

File metadata

  • Download URL: sphinx-lint-0.6.8.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for sphinx-lint-0.6.8.tar.gz
Algorithm Hash digest
SHA256 8c51ab6f5a959362ddb40c5821206bb00987fe978caf46ef5362869022a4f1a2
MD5 ddb160e4f693d5e37b5d3c5cb3c5010c
BLAKE2b-256 4c868a7677dc193a61c136beac8206c8587215f355bd97985f50d5a1c3a633b9

See more details on using hashes here.

Provenance

File details

Details for the file sphinx_lint-0.6.8-py3-none-any.whl.

File metadata

  • Download URL: sphinx_lint-0.6.8-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for sphinx_lint-0.6.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3f65e6d86cd5e1270493fb0d969ecafa409b580f9f2ca53869a77a1f1727db15
MD5 6b73d07ca4e6f7b7977504507e1ef281
BLAKE2b-256 97723e8e2434f7b2ceeba1a408168f9270760212ea23096d738f0cd6ca400a62

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page