Persist the IDE agent's clustering result as the module tree.
(
arguments: Dict[str, Any],
store: SessionStore,
)
| 57 | { |
| 58 | "module": module_name, |
| 59 | "path": current_path, |
| 60 | "is_leaf": False, |
| 61 | "doc_path": module_doc_relpath(current_path, layout), |
| 62 | "children": list(children.keys()), |
| 63 | "components": module_info.get("components", []), |
| 64 | } |
| 65 | ) |
| 66 | else: |
| 67 | order.append( |
| 68 | { |
| 69 | "module": module_name, |
| 70 | "path": current_path, |
| 71 | "is_leaf": True, |
| 72 | "doc_path": module_doc_relpath(current_path, layout), |
| 73 | "components": module_info.get("components", []), |
| 74 | } |
| 75 | ) |
| 76 | |
| 77 | _collect(module_tree, parent_path) |
| 78 | return order |
| 79 | |
| 80 | |
| 81 | def _collect_component_ids(module_tree: Dict[str, Any]) -> set[str]: |
| 82 | """Return the set of all component ids referenced across the module tree. |
| 83 | |
| 84 | Walks every module (and nested ``children``) and collects the entries of |
| 85 | each module's ``components`` list. |
| 86 | """ |
| 87 | ids: set[str] = set() |
| 88 | |
| 89 | def _walk(tree: Dict[str, Any]) -> None: |
| 90 | for module_info in tree.values(): |
| 91 | ids.update(module_info.get("components", []) or []) |
| 92 | children = module_info.get("children", {}) |
| 93 | if isinstance(children, dict): |
| 94 | _walk(children) |
| 95 | |
| 96 | _walk(module_tree) |
| 97 | return ids |
| 98 | |
| 99 | |
| 100 | def _validate_module_tree( |
| 101 | module_tree: Dict[str, Any], |
| 102 | known_ids: set[str], |
| 103 | candidate_ids: set[str], |
| 104 | ) -> Tuple[List[str], List[str]]: |
| 105 | """Check the tree's component ids against the analysis index. |
| 106 | |
| 107 | Returns ``(unmatched_ids, leftover_ids)``: |
| 108 | * ``unmatched_ids``: ids referenced by the tree that do not exist in the |
| 109 | index (typos / drift) -- they will be silently omitted from docs. |
nothing calls this directly
no test coverage detected