Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lexer examples. #2451

Merged
merged 2 commits into from
Jun 10, 2023
Merged

Add support for lexer examples. #2451

merged 2 commits into from
Jun 10, 2023

Conversation

Anteru
Copy link
Collaborator

@Anteru Anteru commented Jun 8, 2023

This adds support for a new attribute _example which, if present, will
load the file under tests/examplefiles pointed to by _example and
show it as part of the lexer documentation. This allows us to have
unit-tested files show up as small code snippets in the documentation,
without having to worry that the documentation output contains possibly
incorrectly highlighted code.

This would allow #2442 to use this machinery instead of embedding the snippets as "plain code" into the doc string.

This adds support for a new attribute `_example` which, if present, will
load the file under `tests/examplefiles` pointed to by `_example` and
show it as part of the lexer documentation. This allows us to have
unit-tested files show up as small code snippets in the documentation,
without having to worry that the documentation output contains possibly
incorrectly highlighted code.
@Anteru Anteru requested a review from jeanas June 8, 2023 16:18
pygments/sphinxext.py Outdated Show resolved Hide resolved
Also tweak the style a bit so code snippets in admonitions look
acceptable.
@Anteru Anteru merged commit 644da24 into master Jun 10, 2023
30 checks passed
@Anteru Anteru deleted the anteru/lexer-examples branch June 10, 2023 10:16
@Anteru Anteru added the A-docs area: changes to documentation/docstrings label Jun 10, 2023
@Anteru Anteru added this to the 2.16.0 milestone Jun 10, 2023
@Anteru Anteru self-assigned this Jun 10, 2023
@birkenfeld
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs area: changes to documentation/docstrings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants