MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / generate_call_table_rows

Function generate_call_table_rows

graphify/callflow_html.py:1232–1299  ·  view source on GitHub ↗

Generate call table row scaffolding for a section's nodes. The Caller/Callee columns make a claim about the whole graph ("External entry / no inbound edge"), so they must be computed from the whole graph. Built from ``section_edges`` alone they only see edges whose *both* endpoints

(
    nodes: list,
    section_edges: list,
    lang: str,
    all_edges: list | None = None,
    all_nodes: list | None = None,
)

Source from the content-addressed store, hash-verified

1230
1231
1232def generate_call_table_rows(
1233 nodes: list,
1234 section_edges: list,
1235 lang: str,
1236 all_edges: list | None = None,
1237 all_nodes: list | None = None,
1238) -> str:
1239 """Generate call table row scaffolding for a section's nodes.
1240
1241 The Caller/Callee columns make a claim about the whole graph ("External
1242 entry / no inbound edge"), so they must be computed from the whole graph.
1243 Built from ``section_edges`` alone they only see edges whose *both*
1244 endpoints sit in this section, so a node called from anywhere else is
1245 mislabelled an entry point. Section coverage makes that the common case
1246 rather than a corner case: only ``max_sections`` communities are rendered,
1247 so most callers are not in any rendered section at all.
1248
1249 ``all_edges``/``all_nodes`` are the full graph; ``all_nodes`` also lets
1250 out-of-section callers render as labels instead of raw node ids. Both
1251 default to None, preserving the previous behaviour for other callers.
1252 """
1253 if not nodes:
1254 return ""
1255
1256 # Build source/target lookup from edges
1257 node_by_id = {n.get("id"): n for n in (all_nodes or nodes)}
1258 callers = defaultdict(set)
1259 callees = defaultdict(set)
1260 for e in (all_edges if all_edges is not None else section_edges):
1261 src = e.get("source", "")
1262 tgt = e.get("target", "")
1263 if e.get("relation") in ("calls", "imports", "imports_from", "uses", "method", "indirect_call"):
1264 callers[tgt].add(src)
1265 callees[src].add(tgt)
1266
1267 rows = []
1268 for i, n in enumerate(nodes[:30], 1): # cap at 30 rows
1269 nid = n.get("id", "")
1270 label = n.get("label", nid)
1271 source_file = safe_file_path(n.get("source_file", ""))
1272 file_type = n.get("file_type", "code")
1273
1274 # Suggest a tag type based on file_type and label heuristics
1275 tag = _suggest_tag(label, file_type, lang, node_kind(n))
1276
1277 caller_text = format_node_refs(
1278 callers.get(nid, set()),
1279 node_by_id,
1280 lang,
1281 pick_text(lang, "外部入口 / 无直接入边", "External entry / no inbound edge"),
1282 )
1283 callee_text = format_node_refs(
1284 callees.get(nid, set()),
1285 node_by_id,
1286 lang,
1287 pick_text(lang, "无直接出边", "No direct outbound edge"),
1288 )
1289

Calls 8

safe_file_pathFunction · 0.85
_suggest_tagFunction · 0.85
node_kindFunction · 0.85
format_node_refsFunction · 0.85
pick_textFunction · 0.85
_describe_nodeFunction · 0.85
getMethod · 0.45
joinMethod · 0.45