(
graph_path: Path,
output_path: Path,
*,
root: Optional[str] = None,
max_children: int = DEFAULT_MAX_CHILDREN,
project_label: Optional[str] = None,
# kept for CLI compatibility with the older signature; ignored now
top_k_edges: int = 0,
)
| 560 | |
| 561 | |
| 562 | def write_tree_html( |
| 563 | graph_path: Path, |
| 564 | output_path: Path, |
| 565 | *, |
| 566 | root: Optional[str] = None, |
| 567 | max_children: int = DEFAULT_MAX_CHILDREN, |
| 568 | project_label: Optional[str] = None, |
| 569 | # kept for CLI compatibility with the older signature; ignored now |
| 570 | top_k_edges: int = 0, |
| 571 | ) -> Path: |
| 572 | from graphify.security import check_graph_file_size_cap |
| 573 | check_graph_file_size_cap(graph_path) |
| 574 | graph = json.loads(graph_path.read_text(encoding="utf-8")) |
| 575 | tree = build_tree(graph, root=root, max_children=max_children, |
| 576 | project_label=project_label) |
| 577 | title = f"{tree['name']} — graphify tree viewer" |
| 578 | header = f"{tree['name']} — Knowledge Graph" |
| 579 | html = emit_html(tree, title=title, header=header) |
| 580 | output_path.parent.mkdir(parents=True, exist_ok=True) |
| 581 | output_path.write_text(html, encoding="utf-8") |
| 582 | return output_path |
no test coverage detected