MkDiagram
Class representing a mermaid diagram.¶
Description
MkDiagrams can show directed acyclic graphs and allows to manually create diagrams.
Bases: MkCode
__init__
¶
__init__(
names: list[str] | None = None,
connections: list[tuple] | None = None,
*,
direction: Literal["TD", "DT", "LR", "RL"] = "TD",
**kwargs: Any
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
list[str] | None
|
names which should be part of the diagram |
None
|
connections
|
list[tuple] | None
|
tuples indicating the connections of the names |
None
|
direction
|
Literal['TD', 'DT', 'LR', 'RL']
|
diagram direction |
'TD'
|
kwargs
|
Any
|
Keyword arguments passed to parent |
{}
|
Name | Children | Inherits |
---|---|---|
MkClassDiagram mknodes.templatenodes.mkclassdiagram Node to display the class hierarchy of a class. Supports multiple modes. |
||
MkPipDepTree mknodes.templatenodes.mkpipdeptree Node to display a mermaid diagram for the dependencies. |
Name | Children | Inherits |
---|---|---|
MkCode mknodes.basenodes.mkcode Class representing a Code block. |
graph TD
94596169875232["mkdiagram.MkDiagram"]
94596170179664["mkcode.MkCode"]
94596169139824["mkcontainer.MkContainer"]
94596169136704["mknode.MkNode"]
94596171773984["node.Node"]
139930746687680["builtins.object"]
94596170179664 --> 94596169875232
94596169139824 --> 94596170179664
94596169136704 --> 94596169139824
94596171773984 --> 94596169136704
139930746687680 --> 94596171773984
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mkdiagram/metadata.toml
[metadata]
icon = "mdi:graph-outline"
name = "MkDiagram"
group = "diagram"
[[requirements.extension."pymdownx.superfences".custom_fences]]
name = "mermaid"
class = "mermaid"
format = "pymdownx.superfences.fence_code_format"
[examples.regular]
title = "Regular"
jinja = """
{{ ["1", "2", "3"] | MkDiagram(connections=[("1", "2"), ("2", "3")]) }}
"""
[examples.direction]
title = "Direction"
jinja = """
{{ ["1", "2", "3"] | MkDiagram(connections=[("1", "2"), ("2", "3", "comment")], direction="LR") }}
"""
[output.markdown]
template = """
{{ node.fence_boundary }} mermaid
graph {{ node.direction }}
{% if node.connections %}
{% for name in node.names %}
{{ name }}
{% endfor %}
{% for connection in node.connections %}
{% if connection | length == 2 %}
{{ connection[0] }} --> {{ connection[1] }}
{% else %}
{{ connection[0] }} --> |{{ connection[2] }}| {{ connection[1] }}
{% endif %}
{% endfor %}
{% else %}
{% for name in node.names %}
{{ name | get_hash }}["{{ name }}"]
{% endfor %}
{% for prev, nxt in node.names | pairwise %}
{{ prev | get_hash }} --> {{ nxt | get_hash }}
{% endfor %}
{% endif %}
{{ node.fence_boundary }}
"""