Skip to content

Infra: Add a Sphinx extension to highlight custom keywords - #5084

Open
ZeroIntensity wants to merge 1 commit into
python:mainfrom
ZeroIntensity:highlighting
Open

Infra: Add a Sphinx extension to highlight custom keywords#5084
ZeroIntensity wants to merge 1 commit into
python:mainfrom
ZeroIntensity:highlighting

Conversation

@ZeroIntensity

Copy link
Copy Markdown
Member

Follow-up to #5077.

In PEPs that change syntax, new keywords aren't highlighted as such in code blocks. This makes examples look very foreign, which arguably affects the reception of the PEP.

As a solution, this PR introduces a Sphinx extension that adds special code blocks that allow adding new keywords. For example:

.. code-block:: python+soft-keywords:new_keyword,other_new_keyword

    use the new keyword(s) here

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 pep-previews | 🛠️ Build #33951506 | 📁 Comparing 171126e against latest (87d12a9)

  🔍 Preview build  

1 file changed
± pep-0842/index.html

from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment

_LANG_PREFIX = "python+soft-keywords:"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why “soft”? Aren't they always highlighted as keywords?

@hugovk hugovk added the infra Core infrastructure for building and rendering PEPs label Aug 7, 2026
@hugovk hugovk changed the title Add a Sphinx extension to highlight custom keywords Infra: Add a Sphinx extension to highlight custom keywords Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra Core infrastructure for building and rendering PEPs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants