Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Co-authored-by: Blaise Pabon <blaise@gmail.com>Co-authored-by: William Ferreira <wqferr@gmail.com>
to conserve the productionlist usage in the docs.
Co-Authored-By: bswck <bartoszpiotrslawecki@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this 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...
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
- Add a module docstring- Use the snake_case convention for node classes- Make :group: a required option- declare parallel_write_safe = True
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this 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
58a4357
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…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>
GH-129689 is a backport of this pull request to the3.13 branch. |
…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>
GH-129690 is a backport of this pull request to the3.12 branch. |
…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>
…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>
Uh oh!
There was an error while loading.Please reload this page.
As a first step to what's proposed in the issue, this overrides the ReST
productionlist
directive to::
instead of the::=
symbolAll 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/