Skip to content
Snippets Groups Projects
Commit 54c01ea7 authored by Leah Tacke genannt Unterberg's avatar Leah Tacke genannt Unterberg
Browse files

switching to labels in mermaid class diagram gen

parent 00a9c041
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ class Drawable(ABC):
def sanitize_mermaid(text: str, *, is_er: bool = False):
RE = re.compile("[^0-9a-zA-Z._-]+")
RE = re.compile("[^0-9a-zA-Z_-]+")
"""Mermaid does not allow special characters in column names"""
if not text:
return text
......@@ -269,12 +269,12 @@ class Table(Drawable):
def to_mermaid(self) -> str:
columns = [c.to_mermaid() for c in self.columns]
name = sanitize_mermaid(self.name)
return f" class {name}{{\n " + "\n ".join(columns) + "\n }"
return f' class {name}["{self.name}"]{{\n ' + "\n ".join(columns) + "\n }"
def to_mermaid_er(self) -> str:
columns = [c.to_mermaid_er() for c in self.columns]
name = sanitize_mermaid(self.name, is_er=True)
return f"{name} {{\n" + "\n ".join(columns) + "\n}"
return f'{name}["{self.name}"] {{\n' + "\n ".join(columns) + "\n}"
@property
def columns_sorted(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment