Skip to content

Emit a warning when code-block should be pycon instead of python #11784

@LLyaudet

Description

@LLyaudet

Is your feature request related to a problem? Please describe.
This PR on the repo for the packaging.python.org guide pypa/packaging.python.org#1428 reveals an easy-to-make mistake in Sphinx and similar tools:

.. code-block:: python

   >>> some Python console session

where the lexer should be pycon instead.

This looks pretty common actually:

https://grep.app/search?q=%5C.%5C.%20code-block%3A%3A%20python%5Cn%5Cs%2A%3E%3E%3E&regexp=true

https://grep.app/search?q=%60%60%60python%5Cn%3E%3E%3E&regexp=true

Describe the solution you'd like
It would be nice if a warning could be emitted in that case at doc build.

Describe alternatives you've considered
The alternative I have found is manual check, helped by commands like:

grep -r 'code-block:: python' -A 3 .

Additional context
pypa/packaging.python.org#1428
started from a correction asked here: pypa/packaging.python.org#1424
From pypa/packaging.python.org#1428,
@jeanas reported the same problem but with a distinct solution here:
pygments/pygments#2603

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions