mbdlyb_ui.mermaid ================= .. py:module:: mbdlyb_ui.mermaid .. autoapi-nested-parse:: Copyright (c) 2026 TNO-ESI All rights reserved. Attributes ---------- .. autoapisummary:: mbdlyb_ui.mermaid.BaseRelationSpec mbdlyb_ui.mermaid.RelationSpec Classes ------- .. autoapisummary:: mbdlyb_ui.mermaid.MermaidBuilder Module Contents --------------- .. py:class:: MermaidBuilder(net: mbdlyb.gdb.GMBDNet, attributes: dict[type[mbdlyb.gdb.GMBDElement], Union[list[Union[str, tuple[str, bool]]], tuple[list[RelationSpec], list[RelationSpec]]]], color_map: mbdlyb.colormap.ColorMap, label_map: Optional[dict[type[mbdlyb.gdb.GMBDRelation], str]] = None, direction: str = 'LR') Build interactive Mermaid flowcharts from graph-backed networks. .. py:method:: add_element(e: mbdlyb.gdb.GMBDNode, url: Optional[str] = None) -> str Append a styled node and optional click handler to the diagram. :param e: Node to display. :param url: Optional destination emitted on a node click. :returns: The node's Mermaid identifier. .. py:method:: add_to_tree(element: mbdlyb.gdb.GMBDElement) -> str Insert an element under its relative FQN path in the diagram tree. :param element: Model element to place in its containing subgraph. :returns: The inserted element's Mermaid identifier. .. py:method:: add_tree(t: dict, in_current_view: bool = False) Render a nested tree as subgraphs and clickable nodes. :param t: Nested mapping of IDs and labels to nodes or child mappings. :param in_current_view: Whether node links should remain in this network. .. py:method:: build() -> str Traverse the network and render the complete Mermaid flowchart. :returns: Mermaid source with subgraphs, nodes, class colors, and edges. .. py:method:: draw_mermaid_diagram(save_button: nicegui.ui.menu_item) Render the chart and wire its navigation and SVG export events. :param save_button: Menu item that initiates an SVG download. .. py:method:: m_id(n: mbdlyb.gdb.GMBDElement | str) -> str :staticmethod: Convert an element's FQN or string into a Mermaid-safe identifier. :param n: Model element or raw identifier. :returns: An identifier containing only word characters. .. py:method:: m_name(n: mbdlyb.gdb.GMBDElement | str, quote: bool = True) -> str :staticmethod: Escape a label for inclusion in a Mermaid diagram. :param n: Model element or raw label. :param quote: Whether to surround the escaped label in double quotes. :returns: The HTML-escaped, optionally quoted label. .. py:method:: m_url(element: mbdlyb.gdb.GMBDElement, in_current_view: bool) -> Optional[str] :staticmethod: Choose the navigation target for a diagram element. :param element: Element for which to resolve a URL. :param in_current_view: Whether the element belongs to the displayed network. :returns: A resolved URL, or None when no URL is configured. .. py:method:: reset() Clear chart text and traversal state before a new build. .. py:type:: BaseRelationSpec :canonical: tuple[type[GMBDDependency], str] .. py:type:: RelationSpec :canonical: Union[BaseRelationSpec, tuple[type[GMBDDependency], str, tuple[list[BaseRelationSpec], list[BaseRelationSpec]]]]