@@ -133,19 +133,33 @@ def run(self):
133133
134134
135135class  CompatProductionList (SphinxDirective ):
136-     has_content  =  True 
137-     option_spec  =  {}
138- 
139-     # We currently ignore arguments. 
136+     has_content  =  False 
140137    required_arguments  =  1 
138+     optional_arguments  =  0 
139+     final_argument_whitespace  =  True 
140+     option_spec  =  {}
141141
142142    def  run (self ):
143-         options  =  {'group' : self .arguments [0 ]}
144-         content  =  self .content 
143+         # The "content" of a productionlist is actually the first and only 
144+         # argument. The first line is the group; the rest is the content lines. 
145+         lines  =  self .arguments [0 ].splitlines ()
146+         group  =  lines [0 ].strip ()
147+         options  =  {'group' : group }
148+         # We assume there's a colon in each line; align on it. 
149+         align_column  =  max (line .index (':' ) for  line  in  lines [1 :]) +  1 
150+         content  =  []
151+         for  line  in  lines [1 :]:
152+             rule_name , colon , text  =  line .partition (':' )
153+             rule_name  =  rule_name .strip ()
154+             if  rule_name :
155+                 name_part  =  rule_name  +  ':' 
156+             else :
157+                 name_part  =  '' 
158+             content .append (f'{ name_part :<{align_column }} { text }  )
145159        return  make_snippet (self , options , content )
146160
147161
148162def  setup (app ):
149163    app .add_directive ('grammar-snippet' , GrammarSnippetDirective )
150-     app .add_directive ( 'productionlist' , CompatProductionList , override = True )
164+     app .add_directive_to_domain ( 'std' ,  'productionlist' , CompatProductionList , override = True )
151165    return  {'version' : '1.0' , 'parallel_read_safe' : True }
0 commit comments