Skip to content

Commit

Permalink
chore: generalize dot attributes
Browse files Browse the repository at this point in the history
so that they're easier to extend
  • Loading branch information
Konstantin committed Oct 29, 2024
1 parent d681046 commit 68a0a21
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rebdhuhn/graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ def convert_graph_to_dot(ebd_graph: EbdGraph) -> str:
f'<B><FONT POINT-SIZE="18">{ebd_graph.metadata.chapter}</FONT></B><BR/><BR/>'
f'<B><FONT POINT-SIZE="16">{ebd_graph.metadata.sub_chapter}</FONT></B><BR/><BR/><BR/><BR/>'
)
dot_code = "digraph D {\n" f'{ADD_INDENT}labelloc="t";\n{ADD_INDENT}label=<{header}>;\n'
dot_attributes: dict[str, str] = {f"'{ADD_INDENT}labelloc": '"t"', "label": f"<{header}>"}
dot_code = "digraph D {\n"
for dot_attr_key, dot_attr_value in dot_attributes.items():
dot_code += f"{dot_attr_key}={dot_attr_value};\n"
assert len(nx_graph["Start"]) == 1, "Start node must have exactly one outgoing edge."
dot_code += _convert_nodes_to_dot(ebd_graph, ADD_INDENT) + "\n\n"
dot_code += "\n".join(_convert_edges_to_dot(ebd_graph, ADD_INDENT)) + "\n"
Expand Down

0 comments on commit 68a0a21

Please sign in to comment.