GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-127833: Use `productionlist` nodes to implement the `grammar-snippet` directive by AA-Turner · Pull Request #130376 · python/cpython

Conversation

@AA-Turner

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

Uh oh!

There was an error while loading. Please reload this page.

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

  • Issue: Align the grammar documentation with Python's actual grammar #127833

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
AA-Turner added 5 commits February 20, 2025 19:28
@AA-Turner
Extract grammar_re to class-level
21d52e1
@AA-Turner
Factor out make_production()
e5624ed
@AA-Turner
Update to 8.2 make_name_target()
02210ca
@AA-Turner
Use productionlist and production nodes
587c7f9
@AA-Turner
Update topics.py
7ce49bf
@AA-Turner AA-Turner added docs Documentation in the Doc dir skip news labels Feb 20, 2025
@AA-Turner
AA-Turner requested a review from encukou February 20, 2025 19:32
@AA-Turner
AA-Turner requested a review from hugovk as a code owner February 20, 2025 19:32
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 20, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 20, 2025
Align the grammar documentation with Python's actual grammar #127833
Open
@AA-Turner AA-Turner mentioned this pull request Feb 22, 2025
GH-125722: Increase minimum supported Sphinx to 8.2.0 #130444
Merged
encukou
encukou reviewed Feb 24, 2025
View reviewed changes

@encukou encukou left a comment

Copy link
Copy Markdown
Member

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.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/tools/extensions/grammar_snippet.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

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

Uh oh!

There was an error while loading. Please reload this page.

encukou and others added 3 commits February 26, 2025 17:08
@encukou
Add highlighting back
93d80df
@encukou
Merge each multi-line productions into a single production node
8c3f133
@blaisep @encukou
Add Blaise as co-author
9ad7e8f
@encukou

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.

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou
Run ruff format
cde13e2
encukou
encukou reviewed Feb 26, 2025
View reviewed changes
Comment thread Doc/tools/extensions/grammar_snippet.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

encukou added 2 commits March 5, 2025 16:06
@encukou
Fill in the rawsource lines
a9237dd
@encukou
Fix initial case
c958165
@encukou

encukou commented Mar 5, 2025

Copy link
Copy Markdown
Member

OK, now each production should should have complete rawsource.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner added 2 commits March 12, 2025 06:50
@AA-Turner
Small tweaks
e591450
@AA-Turner
Extract production lines logic into production_definitions()
6b4ec3d
@AA-Turner

AA-Turner commented Mar 12, 2025

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou added 2 commits March 17, 2025 15:46
@encukou
Dict → tuple
f5b5ff5
@encukou
Provide more info on error
be8f9e7
@encukou

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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou
Merge in the main branch
8144750
@encukou

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner

AA-Turner commented Mar 19, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner added 2 commits March 19, 2025 18:38
@AA-Turner
Merge branch 'main' into docs/productionlist-grammar
5b39df3
@AA-Turner
Regenerate pydoc_data/topics.py
1c793eb
@encukou

encukou commented Mar 20, 2025

Copy link
Copy Markdown
Member

I think that was a GitHub glitch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou
encukou approved these changes Mar 20, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 20, 2025
@encukou encukou mentioned this pull request Mar 20, 2025
gh-127833: Fix grammar snippet formatting for help() output #129692
Closed
@AA-Turner
AA-Turner merged commit 443c0cd into python:main Mar 20, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 20, 2025
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Mar 20, 2025
@AA-Turner
AA-Turner deleted the docs/productionlist-grammar branch March 20, 2025 15:35
@AA-Turner AA-Turner mentioned this pull request Mar 20, 2025
[3.13] gh-127833: Docs: Add a grammar-snippet directive & replace productionlist (GH-127835) #129689
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou approved these changes
@hugovk hugovk Awaiting requested review from hugovk hugovk is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@AA-Turner @encukou @blaisep
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.