-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclass_diagram.md.jinja2
63 lines (60 loc) · 2.72 KB
/
class_diagram.md.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!-- Jinja2 template based on https://github.com/linkml/linkml/blob/main/linkml/generators/docgen/class_diagram.md.jinja2 -->
<!-- This file should be periodically checked against the original source -->
<!-- Last check 25 August 2023 -->
{% if schemaview.class_parents(element.name) and schemaview.class_children(element.name) %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_parents(element.name)|sort(attribute='name') -%}
{{ gen.name(schemaview.get_element(s)) }} <|-- {{ gen.name(element) }}
{% endfor %}
{% for s in schemaview.class_children(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} <|-- {{ gen.name(schemaview.get_element(s)) }}
{% endfor %}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% if s.range not in gen.all_type_object_names() %}
{{ gen.name(element) }} --|> {{ s.range }} : {{ gen.name(s) }}
{% endif %}
{% endfor %}
```
{% elif schemaview.class_parents(element.name) %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_parents(element.name)|sort(attribute='name') -%}
{{ gen.name(schemaview.get_element(s)) }} <|-- {{ gen.name(element) }}
{% endfor %}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% if s.range not in gen.all_type_object_names() %}
{{ gen.name(element) }} --|> {{ s.range }} : {{ gen.name(s) }}
{% endif %}
{% endfor %}
```
{% elif schemaview.class_children(element.name) %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_children(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} <|-- {{ gen.name(schemaview.get_element(s)) }}
{% endfor %}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% if s.range not in gen.all_type_object_names() %}
{{ gen.name(element) }} --|> {{ s.range }} : {{ gen.name(s) }}
{% endif %}
{% endfor %}
```
{% else %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% if s.range not in gen.all_type_object_names() %}
{{ gen.name(element) }} --|> {{ s.range }} : {{ gen.name(s) }}
{% endif %}
{% endfor %}
```
{% endif %}