MCPcopy Index your code
hub / github.com/python/cpython / run

Method run

Doc/tools/extensions/grammar_snippet.py:232–249  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
252def setup(app: Sphinx) -> ExtensionMetadata:

Callers

nothing calls this directly

Calls 6

make_grammar_snippetMethod · 0.80
splitlinesMethod · 0.45
stripMethod · 0.45
indexMethod · 0.45
partitionMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected