MCPcopy Create free account
hub / github.com/doldecomp/mkdd / generate_changes_markdown

Function generate_changes_markdown

tools/changes_fmt.py:92–121  ·  view source on GitHub ↗
(changes: list[Change], description: str)

Source from the content-addressed store, hash-verified

90
91
92def generate_changes_markdown(changes: list[Change], description: str) -> str:
93 if len(changes) == 0:
94 return ""
95
96 out_lines = []
97 name_max_len = 100
98
99 out_lines.append("<details>")
100 out_lines.append(
101 f"<summary>Detected {len(changes)} {description} compared to the base:</summary>"
102 )
103 out_lines.append("") # Must include a blank line before a table
104 out_lines.append("| Name | Type | Before | After |")
105 out_lines.append("| ---- | ---- | ------ | ----- |")
106
107 for name, key, from_value, to_value in changes:
108 if name is None:
109 name = "Total"
110 else:
111 if len(name) > name_max_len:
112 name = name[: name_max_len - len("...")] + "..."
113 name = f"`{name}`" # Surround with backticks
114 key = key.replace("_", " ").capitalize()
115 out_lines.append(
116 f"| {name} | {key} | {format_float(from_value)}% | {format_float(to_value)}% |"
117 )
118
119 out_lines.append("</details>")
120
121 return "\n".join(out_lines)
122
123
124def main():

Callers 1

mainFunction · 0.85

Calls 2

format_floatFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected