(self)
| 230 | option_spec = {} |
| 231 | |
| 232 | def run(self) -> list[addnodes.productionlist]: |
| 233 | # The "content" of a productionlist is actually the first and only |
| 234 | # argument. The first line is the group; the rest is the content lines. |
| 235 | lines = self.arguments[0].splitlines() |
| 236 | group = lines[0].strip() |
| 237 | options = {'group': group} |
| 238 | # We assume there's a colon in each line; align on it. |
| 239 | align_column = max(line.index(':') for line in lines[1:]) + 1 |
| 240 | content = [] |
| 241 | for line in lines[1:]: |
| 242 | rule_name, _colon, text = line.partition(':') |
| 243 | rule_name = rule_name.strip() |
| 244 | if rule_name: |
| 245 | name_part = rule_name + ':' |
| 246 | else: |
| 247 | name_part = '' |
| 248 | content.append(f'{name_part:<{align_column}}{text}') |
| 249 | return self.make_grammar_snippet(options, content) |
| 250 | |
| 251 | |
| 252 | def setup(app: Sphinx) -> ExtensionMetadata: |
nothing calls this directly
no test coverage detected