metanorma-plugin-lutaml 0.4.8 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 202335c2a56ade17a5bdfedd489b6c39363b256ebbaa2e2cbfe812a6bb6995e5
4
- data.tar.gz: 9637bc5a68bbbe8cda105e74a537ae7e41d5676f584e64e907ad26ba6cf50082
3
+ metadata.gz: 7be44107e7c1d3c9a4471ead7d39630d49cdced1e3996b6bea8b3c64be4fd03f
4
+ data.tar.gz: b99ff8fa3069c0fb0f983de14a984c06db12ecc595e0b876ed83e83926c6eeba
5
5
  SHA512:
6
- metadata.gz: 7e183219067f431d7b839d59ab3e5c8a8b3f54b335cb1e232297f1fa997e7f7abafa4a0858d5398a034c2a025d46feef240f3e71b14db7730fb1789b2dd11afb
7
- data.tar.gz: 400132cae1b7b1b3f03414f4c4ab8b16edde68ab285cd192bd0894d913bee26985182aaf880c2a4ddac1935541bac62913679424e433d88bacc8242c7fcabede
6
+ metadata.gz: 2e6d79ef550cecde85e2e0d49717259f6e9016ef7e3935fdb938d13173361daf404e586a1d1319b05a1ab4a393213086625399d5d3e1090a4afd902c0bfc3f82
7
+ data.tar.gz: 454fe356b82f983a2a4ed9b2a1fa81de19ea8dcb6ac0c10243f1afc8db8e2eed8b8600658c7f0e37040224401dae077a0f93e433227b31c9dd63c7119c59db5f
data/README.adoc CHANGED
@@ -377,11 +377,15 @@ For instance, the script will take package diagrams supplied in the XMI file and
377
377
 
378
378
  * `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but include block will be included only for supplied package name
379
379
 
380
- In addition to the macros listed above that can be used only inside `lutaml_uml_datamodel_description` macro there is another macro called `lutaml_figure`. `lutaml_figure` is used to lookup and reference xmi package diagrams. The syntax is as follows:
380
+ In addition to the macros listed above that can be used only inside `lutaml_uml_datamodel_description` macro there is another macroses called `lutaml_figure` and `lutaml_table`. `lutaml_figure` is used to lookup and reference xmi package diagrams. `lutaml_table` is used to lookup rendered xmi entries. The syntax is as follows:
381
381
 
382
382
  [source,adoc]
383
383
  -----
384
384
  This is lutaml_figure::[package="Wrapper root package", name="Fig B1 Full model"] figure
385
+ This is lutaml_table::[package="Wrapper root package"] package
386
+ This is lutaml_table::[package="Wrapper root package", class="my name"] class
387
+ This is lutaml_table::[package="Wrapper root package", enum="my name"] enum
388
+ This is lutaml_table::[package="Wrapper root package", data_type="my name"] data_type
385
389
  -----
386
390
 
387
391
  This code will be transformed into `<<figure-{diagram.xmi_id}>>` and will point to diagram figure. One can only use this macro when document rendered `lutaml_uml_datamodel_description` macro as it needs diagram lookup table in order to reference package diagram.
@@ -418,9 +422,9 @@ Content for CityGML package
418
422
 
419
423
  ==== Defining tables
420
424
 
421
- .<<tab-P-another-C-{XMI_ID}>> -- Elements of &#8220;Another::AbstractAtomicTimeseries&#8221; (class)
425
+ .<<section-EAPK_9C96A88B_E98B_490b_8A9C_24AEDAC64293>> -- Elements of &#8220;Another::AbstractAtomicTimeseries&#8221; (class)
422
426
 
423
- [[tab-P-another-C-{XMI_ID}]]
427
+ [[section-EAPK_9C96A88B_E98B_490b_8A9C_24AEDAC64293]]
424
428
  .Elements of &#8220;Another::AbstractAtomicTimeseries&#8221; (class)
425
429
  [width="100%",cols="a,a,a,a,a,a,a,a"]
426
430
  |===
@@ -10,11 +10,8 @@
10
10
  {% elsif is_package_spare == 'Spare' %}{% continue %}
11
11
  {% endif %}
12
12
 
13
- {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}
14
-
15
- [[lutaml-section-{{ package_name }}]]
16
- {{equalsigns}} {{ package.name }} package
17
-
13
+ {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }} package
14
+ [[section-{{ package.xmi_id }}]]
18
15
  {{equalsigns}}= {{ package.name }} overview
19
16
 
20
17
  {% assign before_package_key = 'before;' | append: package.name %}
@@ -54,8 +51,7 @@
54
51
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
55
52
  {% endif %}
56
53
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
57
- {% assign klass_xid = klass.xmi_id %}
58
- .<<tab-P-{{ package_name }}-C-{{ klass_xid }}>> -- Elements of "{{ package.name }}::{{ klass.name }}"
54
+ .<<section-{{ klass.xmi_id }}>> -- &#8220;Elements of {{ package.name }}::{{ klass.name }}&#8221; (class)
59
55
 
60
56
  {% endfor %}
61
57
  {% for enum in package.enums %}
@@ -64,8 +60,7 @@
64
60
  {% elsif is_enum_spare == 'Spare' %}{% continue %}
65
61
  {% endif %}
66
62
  {% assign enum_name = enum.name | downcase | replace: ':', '' | replace: ' ', '_' %}
67
- {% assign enum_xid = enum.xmi_id %}
68
- .<<tab-P-{{ package_name }}-E-{{ enum_xid }}>> -- Elements of "{{ package.name }}::{{ enum.name }}"
63
+ .<<section-{{ enum.xmi_id }}>> -- &#8220;Elements of {{ package.name }}::{{ enum.name }}&#8221; (enum)
69
64
 
70
65
  {% endfor %}
71
66
  {% for data_type in package.data_types %}
@@ -74,8 +69,7 @@
74
69
  {% elsif is_data_type_spare == 'Spare' %}{% continue %}
75
70
  {% endif %}
76
71
  {% assign data_type_name = data_type.name | downcase | replace: ':', '' | replace: ' ', '_' %}
77
- {% assign data_type_xid = data_type.xmi_id %}
78
- .<<tab-P-{{ package_name }}-DT-{{ data_type_xid }}>> -- Elements of "{{ package.name }}::{{ data_type.name }}"
72
+ .<<section-{{ data_type.xmi_id }}>> -- &#8220;Elements of {{ package.name }}::{{ data_type.name }}&#8221; (data_type)
79
73
 
80
74
  {% endfor %}
81
75
 
@@ -3,9 +3,8 @@
3
3
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
4
4
  {% endif %}
5
5
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
6
- {% assign klass_xid = klass.xmi_id %}
7
- [[tab-P-{{ package_name }}-C-{{ klass_xid }}]]
8
- .Elements of "{{ package.name }}::{{ klass.name }}" (class)
6
+ [[section-{{ klass.xmi_id }}]]
7
+ .Elements of &#8220;{{ package.name }}::{{ klass.name }}&#8221; (class)
9
8
  [width="100%",cols="a,a,a,a,a,a,a,a"]
10
9
  |===
11
10
 
@@ -6,7 +6,6 @@
6
6
  {% endfor %}
7
7
  {% endif %}
8
8
  {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }}
9
- {{equalsigns}}= {{ package.name }}
10
9
 
11
10
  {% assign before_package_key = 'before;' | append: package.name %}
12
11
  {% if additional_context[before_package_key] and additional_context[before_package_key].size > 0 %}
@@ -24,41 +23,58 @@ h|Stereotype: | «{{ package.stereotype }}»
24
23
 
25
24
  |===
26
25
 
27
- {% assign feature_types = package.classes | where: "stereotype", "FeatureType" %}
28
- {% assign object_types = package.classes | where: "stereotype", "ObjectType" %}
29
26
  {% assign basic_types = package.classes | where: "stereotype", "BasicType" %}
30
- {% assign unions = package.classes | where: "stereotype", "Union" %}
27
+ {% assign unions = package.data_types | where: "stereotype", "Union" %}
31
28
  {% assign code_lists = package.classes | where: "stereotype", "CodeList" %}
32
- {% if feature_types.size > 0 or object_types.size > 0 %}
29
+ {% assign not_classes_length = basic_types.size | plus: code_lists.size %}
30
+ {% assign not_classes_stereoptypes = 'DataType,BasicType,Enumeration,CodeList' | split: ','%}
33
31
  {{equalsigns}}= Classes
34
32
 
35
- {% include "packages_data_dictionary_classes", classes: feature_types %}
36
- {% include "packages_data_dictionary_classes", classes: object_types %}
37
- {% endif %}
33
+ {% unless not_classes_length == package.classes.size %}
34
+
35
+ {% for klass in package.classes %}
36
+ {% unless not_classes_stereoptypes contains klass.stereotype %}
37
+ {% include "packages_data_dictionary_class" %}
38
+ {% endunless %}
39
+ {% endfor %}
40
+ {% else %}
41
+ None
42
+ {% endunless %}
38
43
 
39
- {% if basic_types.size > 0 %}
40
44
  {{equalsigns}}= Basic types
41
45
 
46
+ {% if basic_types.size > 0 %}
47
+
42
48
  {% include "packages_data_dictionary_classes", classes: basic_types %}
49
+ {% else %}
50
+ None
43
51
  {% endif %}
44
52
 
45
- {% if unions.size > 0 %}
46
53
  {{equalsigns}}= Unions
47
54
 
55
+ {% if unions.size > 0 %}
56
+
48
57
  {% include "packages_data_dictionary_classes", classes: unions %}
58
+ {% else %}
59
+ None
49
60
  {% endif %}
50
61
 
51
- {% if code_lists.size > 0 %}
52
62
  {{equalsigns}}= Code lists
53
63
 
64
+ {% if code_lists.size > 0 %}
65
+
54
66
  {% include "packages_data_dictionary_classes", classes: code_lists %}
67
+ {% else %}
68
+ None
55
69
  {% endif %}
56
70
 
57
- {% if package.data_types.size > 0 %}
58
71
  {{equalsigns}}= Data types
59
72
 
60
- {% for data_type in package.data_types %}
61
- {% capture generalizations %}{% for assoc in data_type.associations | where: "member_end_type", "generalization" %}{{ assoc.member_end }} {% endfor %}{% endcapture %}
73
+ {% assign non_unions = package.data_types | where: "stereotype", "DataType" %}
74
+ {% if non_unions.size > 0 %}
75
+
76
+ {% for data_type in non_unions %}
77
+ {% capture generalizations %}{% assign inheritance = data_type.associations | where: "member_end_type", "inheritance" %}{% for assoc in inheritance %}{{ assoc.member_end }} {% endfor %}{% endcapture %}
62
78
  [[{{ data_type.name }}-section]]
63
79
  [cols="1a"]
64
80
  |===
@@ -66,8 +82,8 @@ h|Stereotype: | «{{ package.stereotype }}»
66
82
  |[cols="1,4"]
67
83
  !===
68
84
  !Definition: ! {{ data_type.definition }}
69
- !Subclass of: ! {{ generalizations }}
70
- !Stereotype: ! «DataType»
85
+ !Subclass of: ! {% if generalizations.size > 4 %}{{ generalizations }}{% else %}None{% endif %}
86
+ !Stereotype: ! «{{ data_type.stereotype }}»
71
87
  !===
72
88
  {% if data_type.associations.size > 0 %}
73
89
  {% capture rendered_associations %}
@@ -78,7 +94,7 @@ h|Stereotype: | «{{ package.stereotype }}»
78
94
  {% endif %}
79
95
  {% endfor %}
80
96
  {% endcapture %}
81
- {% if rendered_associations.size > 0 %}
97
+ {% if rendered_associations.size > 100 %}
82
98
  |
83
99
  [cols="15,20,60",options="header"]
84
100
  !===
@@ -94,7 +110,7 @@ h|Stereotype: | «{{ package.stereotype }}»
94
110
  ! Attribute ! Value type and multiplicity ! Definition
95
111
  {% for attr in data_type.attributes %}
96
112
  {% capture cardinality %}{% if attr.cardinality.min == 'C' %}[0..{{ attr.cardinality.max }}]{% elsif assoc.member_end_cardinality.min == 'M' and assoc.member_end_cardinality.max == '1' %}[1..1]{% else %}[{{ attr.cardinality.max }}]{% endif %}{% endcapture %}
97
- ! {{ attr.name }} !<<{{ attr.type }}-section,{{ attr.name }}>> {{ cardinality }} !{{ attr.definition }}
113
+ ! {{ attr.name }} !<<{{ attr.type }}-section,{{ attr.type }}>> {{ cardinality }} !{{ attr.definition }}
98
114
  {% endfor %}
99
115
  !===
100
116
  | NOTE: Unless otherwise specified, all attributes and role names have the stereotype «Property».
@@ -102,13 +118,15 @@ h|Stereotype: | «{{ package.stereotype }}»
102
118
  |===
103
119
 
104
120
  {% endfor %}
121
+ {% else %}
122
+ None
105
123
  {% endif %}
106
124
 
107
- {% if package.enums.size > 0 %}
108
125
  {{equalsigns}}= Enumerations
109
126
 
127
+ {% if package.enums.size > 0 %}
128
+
110
129
  {% for enum in package.enums %}
111
- {% capture generalizations %}{% for assoc in enum.associations | where: "member_end_type", "generalization" %}{{ assoc.member_end }} {% endfor %}{% endcapture %}
112
130
  [[{{ enum.name }}-section]]
113
131
  [cols="1a"]
114
132
  |===
@@ -133,6 +151,8 @@ h|Stereotype: | «{{ package.stereotype }}»
133
151
  |===
134
152
 
135
153
  {% endfor %}
154
+ {% else %}
155
+ None
136
156
  {% endif %}
137
157
 
138
158
  {% if additional_context.include_block and additional_context.include_block.size > 0 %}
@@ -0,0 +1,67 @@
1
+ {% capture generalizations %}{% assign inheritance = klass.associations | where: "member_end_type", "inheritance" %}{% for assoc in inheritance %}{{ assoc.member_end }} {% endfor %}{% endcapture %}
2
+ [[{{ klass.name }}-section]]
3
+ [cols="1a"]
4
+ |===
5
+ |*{{ klass.name }}*
6
+ |
7
+ [cols="1,4"]
8
+ !===
9
+ ! Definition: ! {{ klass.definition }}
10
+ ! Subclass of: ! {% if generalizations.size > 4 %}{{ generalizations }}{% else %}None{% endif %}
11
+ ! Stereotype: ! «{{ klass.stereotype }}»
12
+ {% if klass.constraints.size > 0 %}
13
+ {% for constraint in klass.constraints %}
14
+ ! Constraint: ! {{ constraint.body }}: {{ constraint.definition | replace: '|', '\|' }}
15
+ {% endfor %}
16
+ {% endif %}
17
+ !===
18
+
19
+ {% if klass.associations.size > 0 %}
20
+ {% capture rendered_associations %}
21
+ {% for assoc in klass.associations %}
22
+
23
+ {% if assoc.member_end_attribute_name.size > 0 %}
24
+
25
+ {% capture cardinality %}{% if assoc.member_end_cardinality.min == 'C' %}[0..{{ assoc.member_end_cardinality.max }}]{% elsif assoc.member_end_cardinality.min == 'M' and assoc.member_end_cardinality.max == '1' %}[1..1]{% else %}[{{ assoc.member_end_cardinality.max }}]{% endif %}{% endcapture %}
26
+
27
+ ! {{ assoc.member_end_attribute_name }}
28
+ ! <<{{assoc.member_end}}-section,{{assoc.member_end}}>> {{ cardinality }}
29
+ ! {{ assoc.definition }}
30
+
31
+ {% endif %}
32
+ {% endfor %}
33
+ {% endcapture %}
34
+
35
+ {% if rendered_associations.size > 100 %}
36
+ |
37
+ [cols="15,20,60",options="header"]
38
+ !===
39
+ ! *Role name*
40
+ ! *Target class and multiplicity*
41
+ ! *Definition*
42
+ {{ rendered_associations }}
43
+ !===
44
+ {% endif %}
45
+
46
+ {% endif %}
47
+ {% if klass.attributes.size > 0 %}
48
+ |
49
+ [cols="15,20,60",options="header"]
50
+ !===
51
+ ! *Attribute*
52
+ ! *Value type and multiplicity*
53
+ ! *Definition*
54
+ {% for attr in klass.attributes %}
55
+
56
+ {% capture cardinality %}{% if attr.cardinality.min == 'C' %}[0..{{ attr.cardinality.max }}]{% elsif assoc.member_end_cardinality.min == 'M' and assoc.member_end_cardinality.max == '1' %}[1..1]{% else %}[{{ attr.cardinality.max }}]{% endif %}{% endcapture %}
57
+
58
+ ! {{ attr.name }}
59
+ !<<{{ attr.type }}-section,{{ attr.type }}>> {{ cardinality }}
60
+ !{{ attr.definition }}
61
+
62
+ {% endfor %}
63
+ !===
64
+
65
+ | NOTE: Unless otherwise specified, all attributes and role names have the stereotype «Property».
66
+ {% endif %}
67
+ |===
@@ -1,65 +1,3 @@
1
1
  {% for klass in classes %}
2
- {% capture generalizations %}{% for assoc in klass.associations | where: "member_end_type", "generalization" %}{{ assoc.member_end }} {% endfor %}{% endcapture %}
3
- [[{{ klass.name }}-section]]
4
- [cols="1a"]
5
- |===
6
- |*{{ klass.name }}*
7
- |
8
- [cols="1,4"]
9
- !===
10
- ! Definition: ! {{ klass.definition }}
11
- ! Subclass of: ! {{ generalizations }}
12
- ! Stereotype: ! «{{ klass.stereotype }}»
13
- !===
14
-
15
- {% if klass.associations.size > 0 %}
16
- {% capture rendered_associations %}
17
- {% for assoc in klass.associations %}
18
-
19
- {% if assoc.member_end_attribute_name.size > 0 %}
20
-
21
- {% capture cardinality %}{% if assoc.member_end_cardinality.min == 'C' %}[0..{{ assoc.member_end_cardinality.max }}]{% elsif assoc.member_end_cardinality.min == 'M' and assoc.member_end_cardinality.max == '1' %}[1..1]{% else %}[{{ assoc.member_end_cardinality.max }}]{% endif %}{% endcapture %}
22
-
23
- ! {{ assoc.member_end_attribute_name }}
24
- ! <<{{assoc.member_end}}-section,{{assoc.member_end}}>> {{ cardinality }}
25
- ! {{ assoc.definition }}
26
-
27
- {% endif %}
28
- {% endfor %}
29
- {% endcapture %}
30
-
31
- {% if rendered_associations.size > 0 %}
32
- |
33
- [cols="15,20,60",options="header"]
34
- !===
35
- ! *Role name*
36
- ! *Target class and multiplicity*
37
- ! *Definition*
38
- {{ rendered_associations }}
39
- !===
40
- {% endif %}
41
-
42
- {% endif %}
43
- {% if klass.attributes.size > 0 %}
44
- |
45
- [cols="15,20,60",options="header"]
46
- !===
47
- ! *Attribute*
48
- ! *Value type and multiplicity*
49
- ! *Definition*
50
- {% for attr in klass.attributes %}
51
-
52
- {% capture cardinality %}{% if attr.cardinality.min == 'C' %}[0..{{ attr.cardinality.max }}]{% elsif assoc.member_end_cardinality.min == 'M' and assoc.member_end_cardinality.max == '1' %}[1..1]{% else %}[{{ attr.cardinality.max }}]{% endif %}{% endcapture %}
53
-
54
- ! {{ attr.name }}
55
- !<<{{ attr.type }}-section,{{ attr.name }}>> {{ cardinality }}
56
- !{{ attr.definition }}
57
-
58
- {% endfor %}
59
- !===
60
-
61
- | NOTE: Unless otherwise specified, all attributes and role names have the stereotype «Property».
62
- {% endif %}
63
- |===
64
-
2
+ {% include "packages_data_dictionary_class" %}
65
3
  {% endfor %}
@@ -3,9 +3,8 @@
3
3
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
4
4
  {% endif %}
5
5
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
6
- {% assign klass_xid = klass.xmi_id %}
7
- [[tab-P-{{ package_name }}-DT-{{ klass_xid }}]]
8
- .Elements of "{{ package.name }}::{{ klass.name }}" (data type)
6
+ [[section-{{ klass.xmi_id }}]]
7
+ .Elements of {{ package.name }}::{{ klass.name }}&#8221; (data_type)
9
8
  [width="100%",cols="a,a,a,a,a,a,a,a"]
10
9
  |===
11
10
 
@@ -5,66 +5,89 @@
5
5
  {{ before.text }}
6
6
  {% endfor %}
7
7
  {% endif %}
8
- {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }}
9
-
8
+ {% if depth %}
10
9
  [[rc_{{ package_name }}-model_section]]
11
- {{equalsigns}}= {{ package.name }}
12
-
13
- {% assign before_package_key = 'before;' | append: package.name %}
14
- {% if additional_context[before_package_key] and additional_context[before_package_key].size > 0 %}
15
- {% for before in additional_context[before_package_key] %}
16
- {{ before.text }}
17
- {% endfor %}
18
- {% endif %}
19
- {% if additional_context.diagram_include_block %}
20
- {% for diagram_include_block in additional_context.diagram_include_block %}
21
- {% include "diagrams_block", package_name: package_name, image_base_path: diagram_include_block.base_path, text: diagram_include_block.text %}
22
- {% endfor %}
10
+ {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }}
23
11
  {% endif %}
24
12
 
25
- {% if additional_context.include_block and additional_context.include_block.size > 0 %}
26
- {% for block in additional_context.include_block %}
13
+ {% if additional_context.all_macroses.size > 0 %}
14
+ {% assign sorted_all_macroses = additional_context.all_macroses | where: "position", "before" | sort: 'index' %}
15
+ {% for block in sorted_all_macroses %}
16
+ {% case block.type %}
17
+ {% when 'include_block' %}
18
+ {% unless block.package and block.package != package.name %}
27
19
  {% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
28
20
  {% capture block_content %}{% include block_filename %}{% endcapture %}
29
21
  {% unless block_content contains "Liquid error" %}
30
22
  {% if block.text %}
23
+
31
24
  {{ block.text }}
32
25
  {% endif %}
26
+
33
27
  {{ block_content }}
34
28
  {% endunless %}
35
- {% endfor %}
36
- {% endif %}
29
+ {% endunless %}
30
+ {% when 'package_text' %}
31
+ {% unless block.package and block.package != package.name %}
37
32
 
38
- {% assign include_block_package_key = 'include_block;' | append: package.name %}
39
- {% if additional_context[include_block_package_key] and additional_context[include_block_package_key].size > 0 %}
40
- {% for block in additional_context[include_block_package_key] %}
41
- {% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
42
- {% capture block_content %}{% include block_filename %}{% endcapture %}
43
- {% unless block_content contains "Liquid error" %}
44
- {% if block.text %}
45
33
  {{ block.text }}
46
- {% endif %}
47
- {{ block_content }}
48
34
  {% endunless %}
35
+ {% else %}
36
+ {% endcase %}
37
+ {% endfor %}
38
+ {% endif %}
39
+
40
+ // TODO: move to all_macroses block
41
+ {% if additional_context.diagram_include_block %}
42
+ {% for diagram_include_block in additional_context.diagram_include_block %}
43
+ {% include "diagrams_block", package_name: package_name, image_base_path: diagram_include_block.base_path, text: diagram_include_block.text %}
49
44
  {% endfor %}
50
45
  {% endif %}
51
46
 
52
- {{equalsigns}}= Class definitions
53
47
  {% if package.classes.size > 0 %}
48
+ {{equalsigns}}= Class definitions
49
+
50
+ {% comment %} {% assign data_types = package.classes | where: "stereotype", "DataType" %} {% endcomment %}
51
+ {% assign basic_types = package.classes | where: "stereotype", "BasicType" %}
52
+ {% comment %} {% assign enumerations = package.classes | where: "stereotype", "Enumeration" %} {% endcomment %}
53
+ {% assign code_lists = package.classes | where: "stereotype", "CodeList" %}
54
+
55
+ {% assign not_classes_length = plus: basic_types.size | plus: code_lists.size %}
56
+ {% assign not_classes_stereoptypes = 'DataType,BasicType,Enumeration,CodeList' | split: ','%}
57
+ {% unless not_classes_length == package.classes.size %}
54
58
  .Classes used in {{ package.name }}
55
59
  [cols="2a,6a",options="header"]
56
60
  |===
57
- |Class |Description
58
-
61
+ |Name |Description
59
62
  {% for klass in package.classes %}
63
+ {% unless not_classes_stereoptypes contains klass.stereotype %}
60
64
  |<<{{ klass.name }}-section,{{ klass.name }}>> «{{ klass.stereotype }}»
61
65
  |{{ klass.definition }}
62
66
 
67
+ {% endunless %}
63
68
  {% endfor %}
64
69
  |===
65
- {% endif %}
70
+ {% endunless %}
66
71
 
67
72
  {% if package.data_types.size > 0 %}
73
+ {% include "packages_entity_list_classes", classes: package.data_types, type: "Data Types" %}
74
+ {% endif %}
75
+
76
+ {% if basic_types.size > 0 %}
77
+ {% include "packages_entity_list_classes", classes: basic_types, type: "Primitive Data Types" %}
78
+ {% endif %}
79
+
80
+ {% if package.enums.size > 0 %}
81
+ {% include "packages_entity_list_classes", classes: package.enums, type: "Enumerated Classes" %}
82
+ {% endif %}
83
+
84
+ {% if code_lists.size > 0 %}
85
+ {% include "packages_entity_list_classes", classes: code_lists, type: "CodeList Classes" %}
86
+ {% endif %}
87
+
88
+ {% endif %}
89
+
90
+ {% comment %} {% if package.data_types.size > 0 %}
68
91
  .Data types used in {{ package.name }}
69
92
  [cols="2,6",options="header"]
70
93
  |===
@@ -92,7 +115,7 @@
92
115
  {% endfor %}
93
116
 
94
117
  |===
95
- {% endif %}
118
+ {% endif %} {% endcomment %}
96
119
 
97
120
  {% assign after_package_key = 'after;' | append: package.name %}
98
121
  {% if additional_context[after_package_key] %}
@@ -0,0 +1,11 @@
1
+ .{{ type }} used in {{ package.name }}
2
+ [cols="2a,6a",options="header"]
3
+ |===
4
+ |Name |Description
5
+
6
+ {% for klass in classes %}
7
+ |<<{{ klass.name }}-section,{{ klass.name }}>> «{{ klass.stereotype | default: "Enumeration" }}»
8
+ |{{ klass.definition }}
9
+
10
+ {% endfor %}
11
+ |===
@@ -3,9 +3,9 @@
3
3
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
4
4
  {% endif %}
5
5
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
6
- {% assign klass_xid = klass.xmi_id %}
7
- [[tab-P-{{ package_name }}-E-{{ klass_xid }}]]
8
- .Elements of "{{ package.name }}::{{ klass.name }}" (enumeration)
6
+
7
+ [[section-{{ klass.xmi_id }}]]
8
+ .Elements of {{ package.name }}::{{ klass.name }}&#8221; (enum)
9
9
  [width="100%",cols="a,a,a,a,a,a,a,a"]
10
10
  |===
11
11
 
@@ -0,0 +1 @@
1
+ k = {"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_0BD8DEDF_F024_453d_AA7D_6EBC873FDBB6", "member_end"=>"AbstractFeatureWithLifespan", "member_end_type"=>"inheritance", "member_end_cardinality"=>{"min"=>nil, "max"=>""},"}, "member_end_attribute_name"=>nil, "owner_end"=>"AbstractCityObject", "definition"=>""}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_1C91D9CF_14CB_400c_A818_7C74428AE5B7", "member_end"=>"AbstractAppearance", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>" "member_end_attribute_name"=>"appearance", "owner_end"=>"AbstractCityObject", "definition"=>"Relates appearances to the city object."}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_BDD0FCAB_72F7_499b_AC4D_2391D4DE7CAC", "member_end"=>"AbstractGenericAttribute", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>""},"}, "member_end_attribute_name"=>"genericAttribute", "owner_end"=>"AbstractCityObject", "definition"=>"Relates generic attributes to the city object."}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_C22B8769_C2E7_4e9b_9C0D_138631E90002", "member_end"=>"AbstractCityObject", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>" "member_end_attribute_name"=>"generalizesTo", "owner_end"=>"AbstractCityObject", "definition"=>"Relates generalized representations of the same real-world object in different Levels of Detail to the city object. The direction of this relation is from the city object to the corresponding generalized city objects."}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_CF0045E1_6BF1_40a7_B08D_9B7B30ECA025", "member_end"=>"ExternalReference", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>""},"}, "member_end_attribute_name"=>"externalReference", "owner_end"=>"AbstractCityObject", "definition"=>"References external objects in other information systems that have a relation to the city object."}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_D45045CA_AAD6_418a_AF10_F4BC95DE923A", "member_end"=>"AbstractCityObject", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>" "member_end_attribute_name"=>"relatedTo", "owner_end"=>"AbstractCityObject", "definition"=>"Relates other city objects to the city object. It also describes how the city objects are related to each other."}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_E3BB8700_143D_4dbd_A7EC_49D33C66D430", "member_end"=>"AbstractDynamizer", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>""},"}, "member_end_attribute_name"=>"dynamizer", "owner_end"=>"AbstractCityObject", "definition"=>"Relates Dynamizer objects to the city object. These allow timeseries data to override static attribute values of the city object."}{"visibility"=>"public", "name"=>nil, "owner_end"=>"AbstractCityObject"}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_BE026036_E811_494c_9776_D1A309393D6D", "member_end"=>"AbstractSpace", "member_end_type"=>"generalization", "member_end_cardinality"=>nil, "member_end_attribute_name"=>nil, "owner_end"=>"AbstractCityObject", "definition"=>""}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_C2189DFF_0F24_475b_AB55_070CD09A3186", "member_end"=>"AbstractSpaceBoundary", "member_end_type"=>"generalization", "member_end_cardinality"=>{"min"=>nil, "max"=>" "member_end_attribute_name"=>nil, "owner_end"=>"AbstractCityObject", "definition"=>""}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_C22B8769_C2E7_4e9b_9C0D_138631E90002", "member_end"=>"AbstractCityObject", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>""},"}, "member_end_attribute_name"=>"generalizesTo", "owner_end"=>"AbstractCityObject", "definition"=>"Relates generalized representations of the same real-world object in different Levels of Detail to the city object. The direction of this relation is from the city object to the corresponding generalized city objects."}{"visibility"=>"public", "name"=>nil, "xmi_id"=>"EAID_D45045CA_AAD6_418a_AF10_F4BC95DE923A", "member_end"=>"AbstractCityObject", "member_end_type"=>"aggregation", "member_end_cardinality"=>{"min"=>"M", "max"=>" "member_end_attribute_name"=>"relatedTo", "owner_end"=>"AbstractCityObject", "definition"=>"Relates other city objects to the city object. It also describes how the city objects are related to each other."}{"visibility"=>"public", "name"=>nil, "owner_end"=>"AbstractCityObject"}{"visibility"=>"public", "name"=>nil, "owner_end"=>"AbstractCityObject"}
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module Plugin
5
+ module Lutaml
6
+ class LutamlTableInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
7
+ include LutamlDiagramBase
8
+ SUPPORTED_OPTIONS = %w[class enum data_type]
9
+
10
+ use_dsl
11
+ named :lutaml_table_class
12
+
13
+ def process(parent, _target, attrs)
14
+ keyword = SUPPORTED_OPTIONS.find { |n| attrs[n] }
15
+ entity_key = [keyword, attrs["package"], attrs[keyword]].compact.join(":")
16
+ return if parent.document.attributes['lutaml_entity_id'].nil?
17
+ xmi_id = parent.document.attributes['lutaml_entity_id'][entity_key]
18
+ return unless xmi_id
19
+
20
+ %Q(<xref target="section-#{xmi_id}"></xref>)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -26,8 +26,9 @@ module Metanorma
26
26
  'entity_list' => 'packages_entity_list',
27
27
  'data_dictionary' => 'packages_data_dictionary'
28
28
  }.freeze
29
+ RENDER_STYLE_ATTRIBUTE = 'render_style'.freeze
29
30
  SUPPORTED_NESTED_MACRO = %w[
30
- before diagram_include_block after include_block].freeze
31
+ before diagram_include_block after include_block package_text].freeze
31
32
  # search document for block `lutaml_uml_datamodel_description`
32
33
  # read include derectives that goes after that in block and transform
33
34
  # into yaml2text blocks
@@ -74,6 +75,35 @@ module Metanorma
74
75
  parse_yaml_config_file(document, block_match[2]))
75
76
  end
76
77
 
78
+ def fill_in_entities_refs_attributes(document, lutaml_document_wrapper, options)
79
+ lutaml_document = lutaml_document_wrapper.original_document
80
+ render_style = options.fetch(RENDER_STYLE_ATTRIBUTE, 'default')
81
+ all_children_packages = lutaml_document.packages.map(&:children_packages).flatten
82
+ package_flat_packages = lambda do |pks|
83
+ pks.each_with_object({}) do |package, res|
84
+ res[package.name] = package.xmi_id
85
+ end
86
+ end
87
+ children_pks = package_flat_packages.call(all_children_packages)
88
+ ref_dictionary = package_flat_packages.call(lutaml_document.packages)
89
+ .merge(children_pks)
90
+ %w[class enum data_type].each do |type|
91
+ package_flat = lambda do |pks|
92
+ pks.each_with_object({}) do |package, res|
93
+ plural = type == "class" ? "classes" : "#{type}s"
94
+ package.send(plural).map do |entity|
95
+ res["#{type}:#{package.name}:#{entity.name}"] = entity.xmi_id
96
+ end
97
+ end
98
+ end
99
+ children_pks_daigs = package_flat.call(all_children_packages)
100
+ ref_dictionary = ref_dictionary
101
+ .merge(package_flat.call(lutaml_document.packages)
102
+ .merge(children_pks_daigs))
103
+ end
104
+ document.attributes['lutaml_entity_id'] = ref_dictionary
105
+ end
106
+
77
107
  def fill_in_diagrams_attributes(document, lutaml_document_wrapper)
78
108
  lutaml_document = lutaml_document_wrapper.original_document
79
109
  package_flat_diagrams = lambda do |pks|
@@ -88,6 +118,7 @@ module Metanorma
88
118
 
89
119
  def collect_additional_context(input_lines, end_mark)
90
120
  additional_context = Hash.new { |hash, key| hash[key] = [] }
121
+ additional_context['all_macroses'] = []
91
122
  block_lines = []
92
123
  while (block_line = input_lines.next) != end_mark
93
124
  block_lines.push(block_line)
@@ -100,8 +131,9 @@ module Metanorma
100
131
  name = attrs.delete('role')
101
132
  package = attrs.delete('package')
102
133
  macro_keyword = [name, package].compact.join(";")
103
- block_text = block.lines.length > 0 ? block.lines[1..-2].join("\n") : ''
134
+ block_text = block.lines.length > 0 ? block.lines.join("\n") : ''
104
135
  additional_context[macro_keyword].push({ 'text' => block_text }.merge(attrs))
136
+ additional_context['all_macroses'].push({ 'text' => block_text, 'type' => name, 'package' => package }.merge(attrs))
105
137
  end
106
138
  additional_context
107
139
  end
@@ -118,14 +150,18 @@ module Metanorma
118
150
  return {
119
151
  'render_nested_packages' => true,
120
152
  "packages" => root_package['packages'],
121
- "additional_context" => additional_context
153
+ "root_packages" => [root_package],
154
+ "additional_context" => additional_context,
155
+ "name" => root_package['name']
122
156
  }
123
157
  end
124
158
 
125
159
  all_packages = [root_package, *root_package['children_packages']]
126
160
  {
127
161
  "packages" => sort_and_filter_out_packages(all_packages, options),
128
- "additional_context" => additional_context
162
+ "additional_context" => additional_context,
163
+ "root_packages" => [root_package],
164
+ "name" => root_package['name']
129
165
  }
130
166
  end
131
167
 
@@ -163,8 +199,9 @@ module Metanorma
163
199
  end
164
200
 
165
201
  def model_representation(lutaml_document, document, additional_context, options)
202
+ fill_in_entities_refs_attributes(document, lutaml_document, options)
166
203
  render_result, errors = Utils.render_liquid_string(
167
- template_string: table_template(options['section_depth'] || 2, options['render_style']),
204
+ template_string: table_template(options['section_depth'] || 2, options['render_style'], options['include_root']),
168
205
  context_items: create_context_object(lutaml_document,
169
206
  additional_context,
170
207
  options),
@@ -176,9 +213,15 @@ module Metanorma
176
213
  render_result.split("\n")
177
214
  end
178
215
 
179
- def table_template(section_depth, render_style)
216
+ def table_template(section_depth, render_style, include_root)
180
217
  include_name = RENDER_STYLES_INCLUDES.fetch(render_style, DEFAULT_RENDER_INCLUDE)
181
- <<~LIQUID
218
+ result = ""
219
+ if include_root
220
+ result += <<~LIQUID
221
+ {% include "#{include_name}", context: context.root_packages, additional_context: context.additional_context, render_nested_packages: false %}
222
+ LIQUID
223
+ end
224
+ result += <<~LIQUID
182
225
  {% include "#{include_name}", depth: #{section_depth}, context: context, additional_context: context.additional_context, render_nested_packages: context.render_nested_packages %}
183
226
  LIQUID
184
227
  end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.4.8".freeze
4
+ VERSION = "0.4.9".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -5,6 +5,7 @@ require "metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor"
5
5
  require "metanorma/plugin/lutaml/lutaml_diagram_block"
6
6
  require "metanorma/plugin/lutaml/lutaml_diagram_block_macro"
7
7
  require "metanorma/plugin/lutaml/lutaml_figure_inline_macro"
8
+ require "metanorma/plugin/lutaml/lutaml_table_inline_macro"
8
9
 
9
10
  module Metanorma
10
11
  module Plugin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-plugin-lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-24 00:00:00.000000000 Z
11
+ date: 2021-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -262,15 +262,19 @@ files:
262
262
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages.liquid
263
263
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages_class.liquid
264
264
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary.liquid
265
+ - lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary_class.liquid
265
266
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary_classes.liquid
266
267
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_type.liquid
267
268
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list.liquid
269
+ - lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list_classes.liquid
268
270
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages_enum.liquid
271
+ - lib/metanorma/plugin/lutaml/liquid_templates/test.rb
269
272
  - lib/metanorma/plugin/lutaml/lutaml_diagram_base.rb
270
273
  - lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb
271
274
  - lib/metanorma/plugin/lutaml/lutaml_diagram_block_macro.rb
272
275
  - lib/metanorma/plugin/lutaml/lutaml_figure_inline_macro.rb
273
276
  - lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
277
+ - lib/metanorma/plugin/lutaml/lutaml_table_inline_macro.rb
274
278
  - lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb
275
279
  - lib/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor.rb
276
280
  - lib/metanorma/plugin/lutaml/utils.rb
@@ -296,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
300
  - !ruby/object:Gem::Version
297
301
  version: '0'
298
302
  requirements: []
299
- rubygems_version: 3.0.3
303
+ rubygems_version: 3.1.6
300
304
  signing_key:
301
305
  specification_version: 4
302
306
  summary: Metanorma plugin for LutaML