Skip to main content

A Sphinx extension to omit needless links

Project description

Linklint is a Sphinx extension that removes links from excessive references.

It also can be used as command-line linter to find or correct those references in .rst files.

Checks

Linklint has two different checks:

  • self: find references that link to their own section. For example, in the description of a class, use :class: referring to itself. These should not be links since they will not take you someplace new.

  • paradup: find multiple identical references within a single paragraph. The first should be a link, but subsequent references don’t need to be links, they are just distractions.

Sphinx extension

To use linklint as a Sphinx extension, add it to the extensions list in your conf.py file:

extensions = [
    # .. probably other extensions are already here..
    "linklint.ext",
]

During the build process, linklint will run its checks and remove links from references it considers excessive. No changes are made to the source files.

Command-line use

You can use linklint as a command-line linter:

% linklint --help
usage: linklint [-h] [--check CHECK] [--fix] files [files ...]

positional arguments:
  files          RST files to lint

options:
  -h, --help     show this help message and exit
  --check CHECK  comma-separated checks to run (self, paradup, all)
  --fix          Fix the issues in place

This can be useful to see what linklint considers excessive, or to modify .rst files to unlink excessive references. Where it can, Linklint unlinks references by changing :func:`foo` to :func:`!foo`.

If you agree with linklint’s decisions, the Sphinx extension is a better option, since it doesn’t require changing the source files, and doesn’t hard-code the decisions.

Testing on CPython

To try local changes in the CPython docs:

cd python/cpython/Docs
make clean venv html
mv build build0
sed -i '' "/linklint/s@.*@-e $HOME/linklint@" requirements.txt
make clean venv
uv pip install -r requirements.txt
make html
meld build0/html build/html
# or
diff -I 'Last updated on' -r build0/html build/html

Changes

v1.0.1 (2026-06-09)

Fix: references that are fully qualified when they don’t need to be are now recognized and will be unlinked.

Fix: references to functions that incorrectly use the :meth: role are recognized by Sphinx anyway, so now linklint also recognizes and unlinks them. Fixes issue 13.

These fixes change the CPython docs build from 1579 self-references unlinked to 1649.

v1.0.0 (2026-05-02)

Fix: the :noindex: directive was ignored, so sections marked as such were considered targets when they shouldn’t have been. This is now fixed.

v0.4.1 (2026-03-27)

Linklint v0.4.0 required Sphinx 9.x, which prevented it from being used by the CPython docs. Now linklint will work with Sphinx 8.x as well.

v0.4.0 (2026-03-10)

A number of roles (:ref:, :doc: and others) were being unlinked when they seemed excessive, but shouldn’t have been. They are explicit references to other parts of the documentation, so should never be removed. This is now fixed.

v0.3.1 (2026-03-01)

Published to PyPI.

v0.3.0 (2026-02-28)

Methods are associated with classes properly in a number of ways.

The Sphinx extension now displays the number of references that were unlinked. The CPython docs report 3612 references unlinked.

v0.2.0 (2026-02-22)

Now available as a Sphinx extension. Instead of changing .rst source files, the excessive links are automatically unlinked in the generated documentation.

v0.1.0 (2026-02-21)

First version: works as a linter with --check and --fix to change .rst source files.

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

linklint-1.0.1.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linklint-1.0.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file linklint-1.0.1.tar.gz.

File metadata

  • Download URL: linklint-1.0.1.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for linklint-1.0.1.tar.gz
Algorithm Hash digest
SHA256 10201b4366edecfbeb3281883aff857dbe77d40bb56f16f212d372f597342d5f
MD5 8ef29fa88bbd96a286f1be8d95eec7c5
BLAKE2b-256 6222c65a97b2192c3c317c472058bf52d7ca88e421998fa8d5c183b2280ab5d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for linklint-1.0.1.tar.gz:

Publisher: publish.yml on nedbat/linklint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file linklint-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: linklint-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for linklint-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c931f110482f1d17808aa2df78b116adc44d7a14e9e79922c57bf9a7cba40a2d
MD5 8dddfe2fca9630033748282299a51caa
BLAKE2b-256 7bd8b2f1708f55f4dd5358b48d28be07ff8e0dadd6d23e41ead2ed1424e90256

See more details on using hashes here.

Provenance

The following attestation bundles were made for linklint-1.0.1-py3-none-any.whl:

Publisher: publish.yml on nedbat/linklint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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