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
94875593528528["mkdiagram.MkDiagram"]
94875593791856["mkcode.MkCode"]
94875590900096["mkcontainer.MkContainer"]
94875594508576["mknode.MkNode"]
94875592833088["node.Node"]
140216716431552["builtins.object"]
94875593791856 --> 94875593528528
94875590900096 --> 94875593791856
94875594508576 --> 94875590900096
94875592833088 --> 94875594508576
140216716431552 --> 94875592833088
/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 }}
"""