Files
term-flow/.termflow/exporters/graphviz_exporter.py
7000pctAUTO 449deab1e2
Some checks failed
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
Add exporters, utils, and tests
2026-01-30 05:30:56 +00:00

27 lines
675 B
Python

"""Graphviz export functionality."""
from typing import List, Optional
class GraphvizExporter:
"""Exports diagrams to Graphviz format."""
def generate_dot(
self,
commands: List[str],
title: str = "Command Flow",
) -> str:
"""Generate DOT graph."""
lines = ["digraph {\n", f' label="{title}"\n', ' node [shape=box]\n\n']
for i, cmd in enumerate(commands):
safe_cmd = cmd.replace('"', '\\"')
lines.append(f' n{i} [label="{safe_cmd}"]\n')
if i > 0:
lines.append(f' n{{i-1}} -> n{{i}}\n')
lines.append("}\n")
return "".join(lines)