File size: 439 Bytes
906d397
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
def generate_mermaid_diagram(path: list) -> str:
    """Generates Mermaid.js syntax for the execution path."""
    if not path:
        return ""
    
    diagram = "graph TD;\n"
    # Replace spaces with underscores for valid Mermaid node names
    path_nodes = [p.replace(' ', '_') for p in path]
    
    for i in range(len(path_nodes) - 1):
        diagram += f"    {path_nodes[i]} --> {path_nodes[i+1]};\n"
        
    return diagram