sphinx-contrib / kroki

Embed PlantUML, DOT, etc. diagrams in your documentation using Kroki.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

danieleades opened this issue · comments

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

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

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)

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