MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / FormatLine

Function FormatLine

tools/cpp_format_struct_table.py:317–350  ·  view source on GitHub ↗
(line: str, line_state: LineState, state: ColumnsState)

Source from the content-addressed store, hash-verified

315
316
317def FormatLine(line: str, line_state: LineState, state: ColumnsState) -> str:
318 if line_state == LineState.NONE:
319 return line
320 row = ParseRow(line, state)
321 if len(row.columns) < 2:
322 return line
323
324 if row.header:
325 return (
326 "// "
327 + " ".join(
328 FormatColumn(column.rstrip(), align, width)
329 for column, width, align in zip(
330 row.columns, [state.widths[0] - 1, *state.widths[1:]], state.aligns
331 )
332 ).rstrip()
333 )
334
335 result = []
336 if row.leading_comment:
337 result.append(FormatColumn(row.columns[0], state.aligns[0], state.widths[0]))
338 result.append("{")
339 for column, width, align in zip(
340 row.columns[1:], state.widths[1:], state.aligns[1:]
341 ):
342 result.append(FormatColumn(column, align, width))
343 result.append("},")
344 return " ".join(result)
345
346 result.append("{")
347 for column, width, align in zip(row.columns, state.widths, state.aligns):
348 result.append(FormatColumn(column, align, width))
349 result.append("},")
350 return " ".join(result)
351
352
353Main()

Callers 1

ProcessFunction · 0.85

Calls 3

ParseRowFunction · 0.85
FormatColumnFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected