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).
This commit is contained in:
Clément Pit-Claudel
2019-05-13 23:21:55 -04:00
parent 55554b0ead
commit 44c8a3b982
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -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
----------
+1 -1
View File
@@ -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'])