cpython/Doc/reference
Petr Viktorin 58a4357e29
gh-127833: Docs: Add a grammar-snippet directive & replace productionlist (GH-127835)
As a first step toward aligning the grammar documentation with Python's actual
grammar, 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 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
(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>
2025-02-05 16:12:23 +01:00
..
compound_stmts.rst gh-122845: fix parameter_list_starargs in function definition pseudo-grammar (#122847) 2025-01-21 20:04:07 +00:00
datamodel.rst Postpone module.__loader__ deprecation to Python 3.16 (#126482) 2024-11-09 16:48:33 -08:00
executionmodel.rst gh-70870: Clarify dual usage of 'free variable' (#122545) 2024-10-08 07:52:12 +00:00
expressions.rst gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829) 2024-11-26 17:57:39 +02:00
grammar.rst Docs: Add label to grammar spec for linking from PEPs (#113235) 2023-12-17 12:23:14 -07:00
import.rst gh-115911: Ignore PermissionError during import from cwd (#116131) 2025-01-26 19:00:28 +00:00
index.rst
introduction.rst GH-103484: Fix permanently redirects reported by linkcheck (GH-124144) 2024-09-17 02:53:38 +00:00
lexical_analysis.rst gh-125461: Remove Python 2 from identifiers in doc (GH-125462) 2024-10-14 15:26:57 +00:00
simple_stmts.rst Docs: Miscellaneous corrections to simple statements in the language reference (GH-126720) 2024-11-15 13:02:34 -08:00
toplevel_components.rst gh-127833: Docs: Add a grammar-snippet directive & replace productionlist (GH-127835) 2025-02-05 16:12:23 +01:00