Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is there a need to match diagram name against a hardcoded list, rather than forwarding the argument to the kroki server? #17

Open
danieleades opened this issue Oct 4, 2023 · 3 comments

Comments

@danieleades
Copy link

what it says on the tin.

If checking the value against a hardcoded list wasn't required, then new diagram types would not need to be manually added (and no issues with absent maintainers either...)

The 'checking' mechanism could still be used for known aliases, but fall back to a direct pass through

@viktorfreiman
Copy link

I am also looking in to this.

I tired to look if kroki has a api for it but I can't find any.
I posted the question up to kroki https://kroki.zulipchat.com/#narrow/stream/232085-users/topic/Api.20endpoint.20to.20list.20supported.20diagrams.3F

@danieleades
Copy link
Author

i'm referring to these lines -

types = {
"actdiag": "actdiag",
"blockdiag": "blockdiag",
"bpmn": "bpmn",
"bytefield": "bytefield",
"c4plantuml": "c4plantuml",
"d2": "d2",
"dot": "graphviz",
"ditaa": "ditaa",
"er": "erd",
"erd": "erd",
"excalidraw": "excalidraw",
"graphviz": "graphviz",
"mermaid": "mermaid",
"nomnoml": "nomnoml",
"nwdiag": "nwdiag",
"packetdiag": "packetdiag",
"pikchr": "pikchr",
"plantuml": "plantuml",
"rackdiag": "rackdiag",
"structurizr": "structurizr",
"seqdiag": "seqdiag",
"svgbob": "svgbob",
"umlet": "umlet",
"vega": "vega",
"vegalite": "vegalite",
"wavedrom": "wavedrom",
}
extension_type_map = {
"bob": "svgbob",
"c4": "c4plantuml",
"c4puml": "c4plantuml",
"dot": "graphviz",
"dsl": "structurizr",
"er": "erd",
"gv": "graphviz",
"iuml": "plantuml",
"pu": "plantuml",
"puml": "plantuml",
"uxf": "umlet",
"vg": "vega",
"vgl": "vegalite",
"vl": "vegalite",
"wsd": "plantuml",
}

seems to me the types dict is redundant, and forces you to create a new PR to support every new diagram supported upstream. When you could instead have something like-

ALIASES = {
    "bob": "svgbob",
    "c4": "c4plantuml",
    "c4puml": "c4plantuml",
    "dot": "graphviz",
    "dsl": "structurizr",
    "er": "erd",
    "gv": "graphviz",
    "iuml": "plantuml",
    "pu": "plantuml",
    "puml": "plantuml",
    "uxf": "umlet",
    "vg": "vega",
    "vgl": "vegalite",
    "vl": "vegalite",
    "wsd": "plantuml",
}

def diagram_name(name: str) -> str:
    return ALIASES.get(name, name)

@viktorfreiman
Copy link

viktorfreiman commented Jan 26, 2024

Yea I agree. I got back from kroki that we can use https://kroki.io/health to get a list of available diagrams. I will see if I can get a PR together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants