From 44c8a3b9822d4e0a372066d463151b04af1f388e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= Date: Sun, 12 May 2019 12:25:20 -0400 Subject: [PATCH] productionlist: Put the full production in production.rawsource This makes it possible to iterate over the productions and see exactly the text that was entered by the author, which is useful to e.g. extract information from the grammar (like syntax-highlighting patterns). --- CHANGES | 2 ++ sphinx/domains/std.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index f79253820b..755924f320 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,8 @@ Incompatible changes * #6230: The anchor of term in glossary directive is changed if it is consisted by non-ASCII characters * #4550: html: Centering tables by default using CSS +* The ``rawsource`` property of ``production`` nodes now contains the full + production rule. Deprecated ---------- diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index c5b3e4e436..01cc797c3a 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -443,7 +443,7 @@ class ProductionList(SphinxDirective): name, tokens = rule.split(':', 1) except ValueError: break - subnode = addnodes.production() + subnode = addnodes.production(rule) subnode['tokenname'] = name.strip() if subnode['tokenname']: idname = nodes.make_id('grammar-token-%s' % subnode['tokenname'])