MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / _format_module_tree

Function _format_module_tree

codewiki/src/be/prompt_template.py:267–291  ·  view source on GitHub ↗
(module_tree: dict[str, any], indent: int = 0)

Source from the content-addressed store, hash-verified

265 lines = []
266
267 def _format_module_tree(module_tree: dict[str, any], indent: int = 0):
268 for key, value in module_tree.items():
269 if key == module_name:
270 lines.append(f"{' ' * indent}{key} (current module)")
271 else:
272 lines.append(f"{' ' * indent}{key}")
273
274 # Group components by file
275 from collections import defaultdict
276 by_file = defaultdict(list)
277 for c in value['components']:
278 if "::" in c:
279 fpath, name = c.split("::", 1)
280 by_file[fpath].append(name)
281 else:
282 by_file[""].append(c)
283 for fpath, names in by_file.items():
284 if fpath:
285 lines.append(f"{' ' * (indent + 1)} {fpath}: {', '.join(names)}")
286 else:
287 lines.append(f"{' ' * (indent + 1)} {', '.join(names)}")
288
289 if isinstance(value["children"], dict) and len(value["children"]) > 0:
290 lines.append(f"{' ' * (indent + 1)} Children:")
291 _format_module_tree(value["children"], indent + 2)
292
293 _format_module_tree(module_tree, 0)
294 formatted_module_tree = "\n".join(lines)

Callers 2

format_user_promptFunction · 0.85
format_cluster_promptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected