Skip to content

Add :pylint: Sphinx role for referencing messages#10904

Open
Br1an67 wants to merge 2 commits intopylint-dev:mainfrom
Br1an67:fix/issue-10563-sphinx-pylint-role
Open

Add :pylint: Sphinx role for referencing messages#10904
Br1an67 wants to merge 2 commits intopylint-dev:mainfrom
Br1an67:fix/issue-10563-sphinx-pylint-role

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 9, 2026

Closes #10563

Type of Changes

Type
✨ New feature
📜 Docs

Description

This PR adds a custom Sphinx role :pylint: that allows easy referencing of pylint message documentation throughout the documentation. The role automatically determines the message category (error, warning, convention, refactor, information, or fatal) and generates appropriate links to the message documentation pages.

Usage

To reference a pylint message in documentation:

:pylint:`used-before-assignment`

This will create a link to the message documentation page at user_guide/messages/{category}/{message-name}.html.

Implementation Details

  • Created a new Sphinx extension doc/exts/pylint_role.py that implements the custom role
  • The role uses a cached mapping of message names to categories for performance
  • If a message name is not found, it displays a warning during the Sphinx build but still creates a text node (graceful degradation)
  • Added the extension to the list of Sphinx extensions in doc/conf.py
  • Created a changelog fragment documenting the new feature

Files Changed

  • doc/exts/pylint_role.py - New Sphinx extension implementing the :pylint: role
  • doc/conf.py - Added pylint_role to the extensions list
  • doc/whatsnew/fragments/10563.feature - Changelog entry for the new feature

Benefits

This feature makes it easier to reference pylint messages in documentation, especially useful for:

  • Changelog entries that reference specific message changes
  • Documentation that explains related messages
  • Cross-referencing between message documentation pages

root and others added 2 commits March 8, 2026 20:08
Add a custom Sphinx role that allows easy referencing of pylint message
documentation. The role automatically determines the message category
and generates appropriate links.

Usage:
    :pylint:`used-before-assignment`

This creates a link to the message documentation page at
user_guide/messages/{category}/{message-name}.html.

Closes pylint-dev#10563
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already work with :ref `message-name`

See https://github.com/pylint-dev/pylint/pull/10568/changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sphinx references to pylint messages

2 participants