From bb60f3fb9f0ac494297ed53807407e3eef2f517a Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Tue, 21 Apr 2026 18:02:01 +0100 Subject: [PATCH] Allow breaking cross-reference of tokens in a `productionlist` --- Doc/tools/extensions/grammar_snippet.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Doc/tools/extensions/grammar_snippet.py b/Doc/tools/extensions/grammar_snippet.py index 8078b7ebeb8076..6154ce059aa3ad 100644 --- a/Doc/tools/extensions/grammar_snippet.py +++ b/Doc/tools/extensions/grammar_snippet.py @@ -144,7 +144,13 @@ def make_production( location=location, ) case 'rule_ref': - production_node += token_xrefs(content, group_name) + if content.startswith('`!'): + token = content[2:-1] + production_node += nodes.literal( + token, token, classes=['xref'] + ) + else: + production_node += token_xrefs(content, group_name) case 'single_quoted' | 'double_quoted': production_node += snippet_string_node('', content) case 'text':