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

Function normalize_sections

graphify/callflow_html.py:692–713  ·  view source on GitHub ↗

Ensure sections have safe unique IDs and an overview section first.

(sections: list, lang: str)

Source from the content-addressed store, hash-verified

690
691
692def normalize_sections(sections: list, lang: str) -> list:
693 """Ensure sections have safe unique IDs and an overview section first."""
694 overview_name = pick_text(lang, "架构总览", "Architecture Overview")
695 normalized = [{"id": "overview", "name": overview_name, "communities": []}]
696 used = {"overview", "hyperedges", "stats"}
697
698 for index, raw in enumerate(sections or [], 1):
699 if not isinstance(raw, dict):
700 continue
701 raw_id = str(raw.get("id") or raw.get("key") or raw.get("name") or f"section-{index}")
702 raw_name = str(raw.get("name") or raw.get("label") or raw_id)
703 if raw_id.lower() == "overview":
704 normalized[0]["name"] = raw_name or overview_name
705 continue
706
707 sid = html_anchor_id(raw_id, f"section-{index}", used)
708 normalized.append({
709 "id": sid,
710 "name": raw_name,
711 "communities": normalize_communities(raw.get("communities", raw.get("community"))),
712 })
713 return normalized
714
715
716def label_for_community(cid: str, labels: dict, nodes: list, lang: str) -> str:

Callers 1

write_callflow_htmlFunction · 0.85

Calls 4

pick_textFunction · 0.85
html_anchor_idFunction · 0.85
normalize_communitiesFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected