FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-127833: Use `productionlist` nodes to implement the `grammar-snippet` directive by AA-Turner · Pull Request #130376 · python/cpython · GitHub

Repository navigation

gh-127833: Use productionlist nodes to implement the grammar-snippet directive - #130376

Merged
AA-Turner merged 18 commits into
python:mainfrom
AA-Turner:docs/productionlist-grammar
Mar 20, 2025
Merged

AA-Turner merged 18 commits into
python:mainfrom
AA-Turner:docs/productionlist-grammar

Conversation

AA-Turner commented Feb 20, 2025 •
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

Split into individual commits for readability. I contend that productionlist nodes are semantically the right thing to use here, the only reason we didn't before was due to a limitation in Sphinx.

A


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

encukou left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you! This looks like the way to go. I left a few notes inline.

conf.py still has needs_sphinx = '8.1.3', and I got a very worrying result with that version: the entire reference directory was missing, without any error message I could see. Is that something you want to look into?

Comment thread Doc/tools/extensions/grammar_snippet.py Outdated

encukou commented Feb 26, 2025

Copy link
Copy Markdown
Member

The extension defines two directives, one with the new syntax but also a CompatProductionList that overrides Sphinx's .. productionlist::. We have syntax highlighting in existing productionlists too.

I added code to merge the lines of each multi-line production into a single production node.
Upstream Sphinx might need a similar change.

Comment thread Doc/tools/extensions/grammar_snippet.py Outdated

encukou commented Mar 5, 2025

Copy link
Copy Markdown
Member

OK, now each production should should have complete rawsource.

Copy link
Copy Markdown
Member Author

Sorry for the delay on my part. I've refactored to split the parsing of content lines into individual productions into its own method, as I think it is sufficiently complex to warrant a dedicated function (and this massively simplifies the creation of the actual production node).

One open question is if group_dict is the right representation, as my understanding is that each dict must have exactly one key -- perhaps an enum would be a better fit? I'm not sure though, and we mustn't let perfect be the enemy of the good.

A

encukou commented Mar 17, 2025

Copy link
Copy Markdown
Member

Don't worry about delays; I've had more important things to deal with too :)

Do you think a (type, content) tuple makes it clearer? Like this: AA-Turner/cpython@docs/productionlist-grammar...encukou:cpython:docs/productionlist-grammar

I think Enum would be overengineering; we'd need to duplicate the names from the regex (unless we build the regex from the enum -- more overengineering).

encukou commented Mar 19, 2025

Copy link
Copy Markdown
Member

I've pushed this change to the PR, and updated the branch to fix a conflict.

Copy link
Copy Markdown
Member Author

@encukou I don't see any new commits...

encukou commented Mar 20, 2025

Copy link
Copy Markdown
Member

I think that was a GitHub glitch.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL