Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-127833: Docs: Add agrammar-snippet directive & replaceproductionlist#127835

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
encukou merged 20 commits intopython:mainfromencukou:doc-grammar-snippets
Feb 5, 2025

Conversation

encukou
Copy link
Member

@encukouencukou commentedDec 11, 2024
edited
Loading

As a first step to what's proposed in the issue, this overrides the ReSTproductionlist directive to:

  • use: instead of the::= symbol
  • add syntax highlighting for strings (the implementation is preliminary; I intend to later add a proper class to the theme instead of borrowing a Pygments class.)

All links and link targets should be preserved. (Unfortunately, this reaches into some Sphinx internals; I don't see a better way to do exactly what Sphinx does.)

This also adds a new directive,grammar-snippet, which formats the snippet almost exactly like what's in the source, modulo syntax highlighting and keeping the backtick character to mark links to other rules.
This will allow formatting the snippets as in the grammar file (most importantly: to remove the the indentation that Sphinx adds to align the text).

I'd appreciate if a Sphinx expert could take a look to see if there's a better way to do something :) cc@AA-Turner


📚 Documentation preview 📚:https://cpython-previews--127835.org.readthedocs.build/

willingc reacted with hooray emoji
encukouand others added6 commitsNovember 20, 2024 17:55
Copy link
Member

@AA-TurnerAA-Turner left a comment

Choose a reason for hiding this comment

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

A few initial notes. The targets problem is annoying, Sphinx doesn't make it easy...

encukou reacted with thumbs up emoji
Copy link
Member

@AA-TurnerAA-Turner left a comment

Choose a reason for hiding this comment

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

I'm happy with this as it stands, thank you@encukou for the discussion. As discussed, I've pushed a commit to add type annotations. I've included some other minor changes and left a self-review for a brief explanation -- feel free to revert any you disagree with.

A

encukou reacted with heart emoji
@AA-TurnerAA-Turner added docsDocumentation in the Doc dir needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes labelsJan 29, 2025
@encukouencukou merged commit58a4357 intopython:mainFeb 5, 2025
33 checks passed
@miss-islington-app
Copy link

Thanks@encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@encukouencukou deleted the doc-grammar-snippets branchFebruary 5, 2025 15:12
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 5, 2025
…roductionlist` (pythonGH-127835)As a first step toward aligning the grammar documentation with Python's actualgrammar, this overrides the ReST `productionlist` directive to:- use `:` instead of the `::=` symbol- add syntax highlighting for strings (using a Pygments highlighting class)All links and link targets should be preserved. (Unfortunately, this reachesinto some Sphinx internals; I don't see a better way to do exactly whatSphinx does.)This also adds a new directive, `grammar-snippet`, which formats the snippetalmost exactly like what's in the source, modulo syntax highlighting andkeeping the backtick character to mark links to other rules.This will allow formatting the snippets as in the grammar file(file:///home/encukou/dev/cpython/Doc/build/html/reference/grammar.html).The new directive is applied to two simple rules in toplevel_components.rst---------(cherry picked from commit58a4357)Co-authored-by: Petr Viktorin <encukou@gmail.com>Co-authored-by: Blaise Pabon <blaise@gmail.com>Co-authored-by: William Ferreira <wqferr@gmail.com>Co-authored-by: bswck <bartoszpiotrslawecki@gmail.com>Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
@bedevere-app
Copy link

GH-129689 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelFeb 5, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 5, 2025
…roductionlist` (pythonGH-127835)As a first step toward aligning the grammar documentation with Python's actualgrammar, this overrides the ReST `productionlist` directive to:- use `:` instead of the `::=` symbol- add syntax highlighting for strings (using a Pygments highlighting class)All links and link targets should be preserved. (Unfortunately, this reachesinto some Sphinx internals; I don't see a better way to do exactly whatSphinx does.)This also adds a new directive, `grammar-snippet`, which formats the snippetalmost exactly like what's in the source, modulo syntax highlighting andkeeping the backtick character to mark links to other rules.This will allow formatting the snippets as in the grammar file(file:///home/encukou/dev/cpython/Doc/build/html/reference/grammar.html).The new directive is applied to two simple rules in toplevel_components.rst---------(cherry picked from commit58a4357)Co-authored-by: Petr Viktorin <encukou@gmail.com>Co-authored-by: Blaise Pabon <blaise@gmail.com>Co-authored-by: William Ferreira <wqferr@gmail.com>Co-authored-by: bswck <bartoszpiotrslawecki@gmail.com>Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
@bedevere-app
Copy link

GH-129690 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelFeb 5, 2025
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull requestFeb 7, 2025
…roductionlist` (pythonGH-127835)As a first step toward aligning the grammar documentation with Python's actualgrammar, this overrides the ReST `productionlist` directive to:- use `:` instead of the `::=` symbol- add syntax highlighting for strings (using a Pygments highlighting class)All links and link targets should be preserved. (Unfortunately, this reachesinto some Sphinx internals; I don't see a better way to do exactly whatSphinx does.)This also adds a new directive, `grammar-snippet`, which formats the snippetalmost exactly like what's in the source, modulo syntax highlighting andkeeping the backtick character to mark links to other rules.This will allow formatting the snippets as in the grammar file(file:///home/encukou/dev/cpython/Doc/build/html/reference/grammar.html).The new directive is applied to two simple rules in toplevel_components.rst---------Co-authored-by: Blaise Pabon <blaise@gmail.com>Co-authored-by: William Ferreira <wqferr@gmail.com>Co-authored-by: bswck <bartoszpiotrslawecki@gmail.com>Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
cmaloney pushed a commit to cmaloney/cpython that referenced this pull requestFeb 8, 2025
…roductionlist` (pythonGH-127835)As a first step toward aligning the grammar documentation with Python's actualgrammar, this overrides the ReST `productionlist` directive to:- use `:` instead of the `::=` symbol- add syntax highlighting for strings (using a Pygments highlighting class)All links and link targets should be preserved. (Unfortunately, this reachesinto some Sphinx internals; I don't see a better way to do exactly whatSphinx does.)This also adds a new directive, `grammar-snippet`, which formats the snippetalmost exactly like what's in the source, modulo syntax highlighting andkeeping the backtick character to mark links to other rules.This will allow formatting the snippets as in the grammar file(file:///home/encukou/dev/cpython/Doc/build/html/reference/grammar.html).The new directive is applied to two simple rules in toplevel_components.rst---------Co-authored-by: Blaise Pabon <blaise@gmail.com>Co-authored-by: William Ferreira <wqferr@gmail.com>Co-authored-by: bswck <bartoszpiotrslawecki@gmail.com>Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AA-TurnerAA-TurnerAA-Turner approved these changes

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

@hugovkhugovkAwaiting requested review from hugovkhugovk is a code owner

Assignees
No one assigned
Labels
docsDocumentation in the Doc dirskip news
Projects
Status: Done
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@encukou@hugovk@AA-Turner@blaisep

[8]ページ先頭

©2009-2025 Movatter.jp