metanorma-plugin-lutaml 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +29 -18
- data/lib/metanorma-plugin-lutaml.rb +1 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages.liquid +32 -18
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary.liquid +177 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary_classes.liquid +43 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list.liquid +113 -0
- data/lib/metanorma/plugin/lutaml/lutaml_figure_inline_macro.rb +23 -0
- data/lib/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor.rb +41 -9
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 636e4bec2488f6e9044ab15915f37485cf08ddcec31e2e852c9d381188b2d99e
|
4
|
+
data.tar.gz: c9c0e74be3a5d5856336f5202c7cb18e442d18548e1a29f476b72694d767eac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e15f9f636f56f0f110baaec844dde2691aefbc882d3be878abe4ccd57e917472847ceb7dcca32f41c1d713d202f4e5caed0530171aad7d368fdde16431fdaee
|
7
|
+
data.tar.gz: 623fb7a37ad8be5e2aac50bbb32be6f366c75abeb47226800af1ae3ec88e24e6c024b7f57016862791f3fa89f4e8181a5c55710f71ab557d25f13480e88e53d9
|
data/README.adoc
CHANGED
@@ -286,44 +286,44 @@ The `lutaml_uml_datamodel_description` macro can be used:
|
|
286
286
|
[lutaml_uml_datamodel_description, path/to/example.xmi]
|
287
287
|
--
|
288
288
|
[.before]
|
289
|
-
|
289
|
+
....
|
290
290
|
my text
|
291
|
-
|
291
|
+
....
|
292
292
|
|
293
293
|
[.diagram_include_block, base_path="requirements/"]
|
294
|
-
|
294
|
+
....
|
295
295
|
Diagram text
|
296
|
-
|
296
|
+
....
|
297
297
|
|
298
298
|
[.include_block, package="Another", base_path="spec/fixtures"]
|
299
|
-
|
299
|
+
....
|
300
300
|
my text
|
301
|
-
|
301
|
+
....
|
302
302
|
|
303
303
|
[.include_block, base_path="spec/fixtures"]
|
304
|
-
|
304
|
+
....
|
305
305
|
my text
|
306
|
-
|
306
|
+
....
|
307
307
|
|
308
308
|
[.before, package="Another"]
|
309
|
-
|
309
|
+
....
|
310
310
|
text before Another package
|
311
|
-
|
311
|
+
....
|
312
312
|
|
313
313
|
[.after, package="Another"]
|
314
|
-
|
314
|
+
....
|
315
315
|
text after Another package
|
316
|
-
|
316
|
+
....
|
317
317
|
|
318
318
|
[.after, package="CityGML"]
|
319
|
-
|
319
|
+
....
|
320
320
|
text after CityGML package
|
321
|
-
|
321
|
+
....
|
322
322
|
|
323
323
|
[.after]
|
324
|
-
|
324
|
+
....
|
325
325
|
footer text
|
326
|
-
|
326
|
+
....
|
327
327
|
--
|
328
328
|
--
|
329
329
|
-----
|
@@ -332,7 +332,7 @@ Where:
|
|
332
332
|
|
333
333
|
* `path/to/example.xmi` - required, path to the XMI file to render
|
334
334
|
|
335
|
-
* `[.before]` - macro to add additional text before the rendered output, can be used only once, additional occurrences of macro will overwrite text
|
335
|
+
* `[.before]` - macro to add additional text before the rendered output, can be used only once, additional occurrences of macro will overwrite text, not that `literal` block style must be used in there(eg `....`)
|
336
336
|
|
337
337
|
* `[.after]` - macro to add additional text after the rendered output, can be used only once, additional occurrences of macro will overwrite text
|
338
338
|
|
@@ -359,6 +359,14 @@ Eg: script will take package diagrams supplied in xmi file and will try to inclu
|
|
359
359
|
|
360
360
|
* `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but include block will be included only for supplied package name
|
361
361
|
|
362
|
+
In addition to macroses 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:
|
363
|
+
|
364
|
+
[source,adoc]
|
365
|
+
-----
|
366
|
+
This is lutaml_figure::[package="Wrapper root package", name="Fig B1 Full model"] figure
|
367
|
+
-----
|
368
|
+
|
369
|
+
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 refernce package diagram.
|
362
370
|
|
363
371
|
Will produce this output:
|
364
372
|
|
@@ -453,18 +461,21 @@ packages:
|
|
453
461
|
- three
|
454
462
|
# skips these packages
|
455
463
|
- skip: four
|
464
|
+
render_style: entity_list|data_dictionary|default
|
465
|
+
section_depth: 2
|
456
466
|
-----
|
457
467
|
|
458
468
|
Where:
|
459
469
|
|
460
470
|
* `packages` - required, root element with the list of strings or objects
|
461
|
-
|
462
471
|
* `Package *` - pattern matching, specifies lookup condition for packages to
|
463
472
|
render.
|
464
473
|
+
|
465
474
|
NOTE: In this example, it is equal to the following regular expression: `/^Package.*$/`
|
466
475
|
|
467
476
|
* `skip: four` - object with package name to skip
|
477
|
+
* `render_style` - what template to use to render packages, can be: entity_list, data_dictionary or default
|
478
|
+
* `section_depth` - what package to use as root package for render, eg `section_depth` equal to 2 tells processor to use first nested package of the first root packages in xmi file. Example: if xmi file has this package structure: [{ name: 'One', packages: [{ name: 'one-1' }, { name: 'one-2' }] }, { name: 'Two', packages: [{ name: 'two-1' }, { name: 'two-2' }] }] and we have `section_depth` equal to 2, root package will be `one-1`
|
468
479
|
|
469
480
|
Usage with macro:
|
470
481
|
|
@@ -4,6 +4,7 @@ require "metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor"
|
|
4
4
|
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
|
+
require "metanorma/plugin/lutaml/lutaml_figure_inline_macro"
|
7
8
|
|
8
9
|
module Metanorma
|
9
10
|
module Plugin
|
@@ -1,11 +1,9 @@
|
|
1
1
|
{% for package in context.packages %}
|
2
2
|
{% assign package_name = package.name | downcase | replace: ":", "" | replace: " ", "_" %}
|
3
|
-
{% if additional_context.before %}
|
4
|
-
{
|
5
|
-
{
|
6
|
-
{%
|
7
|
-
{% if additional_context[before_package_key] %}
|
8
|
-
{{ additional_context[before_package_key].text }}
|
3
|
+
{% if additional_context.before and additional_context.before.size > 0 %}
|
4
|
+
{% for before in additional_context.before %}
|
5
|
+
{{ before.text }}
|
6
|
+
{% endfor %}
|
9
7
|
{% endif %}
|
10
8
|
{% assign is_package_spare = package.name | slice: 0,5 %}
|
11
9
|
{% if is_package_spare == 'old: ' %}{% continue %}
|
@@ -15,8 +13,16 @@
|
|
15
13
|
{% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }} package
|
16
14
|
{{equalsigns}}= {{ package.name }} overview
|
17
15
|
|
16
|
+
{% assign before_package_key = 'before;' | append: package.name %}
|
17
|
+
{% if additional_context[before_package_key] and additional_context[before_package_key].size > 0 %}
|
18
|
+
{% for before in additional_context[before_package_key] %}
|
19
|
+
{{ before.text }}
|
20
|
+
{% endfor %}
|
21
|
+
{% endif %}
|
18
22
|
{% if additional_context.diagram_include_block %}
|
19
|
-
{%
|
23
|
+
{% for diagram_include_block in additional_context.diagram_include_block %}
|
24
|
+
{% include "diagrams_block", package_name: package_name, image_base_path: diagram_include_block.base_path, text: diagram_include_block.text %}
|
25
|
+
{% endfor %}
|
20
26
|
{% endif %}
|
21
27
|
|
22
28
|
{% if package.packages.size > 0 %}The {{ package.name }} package is organized into
|
@@ -81,9 +87,9 @@
|
|
81
87
|
|
82
88
|
{% endif %}
|
83
89
|
|
84
|
-
{% if additional_context.include_block %}
|
85
|
-
{%
|
86
|
-
{% capture block_filename %}{{ block.base_path }}
|
90
|
+
{% if additional_context.include_block and additional_context.include_block.size > 0 %}
|
91
|
+
{% for block in additional_context.include_block %}
|
92
|
+
{% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
|
87
93
|
{% capture block_content %}{% include block_filename %}{% endcapture %}
|
88
94
|
{% unless block_content contains "Liquid error" %}
|
89
95
|
{% if block.text %}
|
@@ -91,12 +97,13 @@
|
|
91
97
|
{% endif %}
|
92
98
|
{{ block_content }}
|
93
99
|
{% endunless %}
|
100
|
+
{% endfor %}
|
94
101
|
{% endif %}
|
95
102
|
|
96
103
|
{% assign include_block_package_key = 'include_block;' | append: package.name %}
|
97
|
-
{%
|
98
|
-
{%
|
99
|
-
{% capture block_filename %}{{ block.base_path }}
|
104
|
+
{% if additional_context[include_block_package_key] and additional_context[include_block_package_key].size > 0 %}
|
105
|
+
{% for block in additional_context[include_block_package_key] %}
|
106
|
+
{% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
|
100
107
|
{% capture block_content %}{% include block_filename %}{% endcapture %}
|
101
108
|
{% unless block_content contains "Liquid error" %}
|
102
109
|
{% if block.text %}
|
@@ -104,16 +111,23 @@
|
|
104
111
|
{% endif %}
|
105
112
|
{{ block_content }}
|
106
113
|
{% endunless %}
|
114
|
+
{% endfor %}
|
107
115
|
{% endif %}
|
108
116
|
|
109
117
|
{% assign after_package_key = 'after;' | append: package.name %}
|
110
|
-
{{equalsigns}}= Additional Information
|
111
118
|
{% if additional_context[after_package_key] %}
|
112
|
-
{{
|
119
|
+
{{equalsigns}}= Additional Information
|
120
|
+
{% for after in additional_context[after_package_key] %}
|
121
|
+
{{ after.text }}
|
122
|
+
{% endfor %}
|
123
|
+
{% endif %}
|
124
|
+
{% if package.packages.size > 0 and render_nested_packages %}
|
125
|
+
{% assign nested_depth = depth | plus: 1 %}{% include "packages", depth: nested_depth, context: package %}
|
113
126
|
{% endif %}
|
114
|
-
{% if package.packages.size > 0 and render_nested_packages %}{% assign nested_depth = depth | plus: 1 %}{% include "packages", depth: nested_depth, context: package %}{% endif %}
|
115
127
|
{% endfor %}
|
116
128
|
|
117
|
-
{% if additional_context.after %}
|
118
|
-
{
|
129
|
+
{% if additional_context.after and additional_context.after.size > 0 %}
|
130
|
+
{% for after in additional_context.after %}
|
131
|
+
{{ after.text }}
|
132
|
+
{% endfor %}
|
119
133
|
{% endif %}
|
@@ -0,0 +1,177 @@
|
|
1
|
+
{% for package in context.packages %}
|
2
|
+
{% assign package_name = package.name | downcase | replace: ":", "" | replace: " ", "_" %}
|
3
|
+
{% if additional_context.before and additional_context.before.size > 0 %}
|
4
|
+
{% for before in additional_context.before %}
|
5
|
+
{{ before.text }}
|
6
|
+
{% endfor %}
|
7
|
+
{% endif %}
|
8
|
+
{% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }}
|
9
|
+
{{equalsigns}}= {{ package.name }}
|
10
|
+
|
11
|
+
{% assign before_package_key = 'before;' | append: package.name %}
|
12
|
+
{% if additional_context[before_package_key] and additional_context[before_package_key].size > 0 %}
|
13
|
+
{% for before in additional_context[before_package_key] %}
|
14
|
+
{{ before.text }}
|
15
|
+
{% endfor %}
|
16
|
+
{% endif %}
|
17
|
+
|
18
|
+
[cols="1a,4a"]
|
19
|
+
|===
|
20
|
+
|
21
|
+
h|Description: | {{ package.definition }}
|
22
|
+
h|Parent Package: | {{ context.name }}
|
23
|
+
h|Stereotype: | «{{ package.stereotype }}»
|
24
|
+
|
25
|
+
|===
|
26
|
+
|
27
|
+
{% assign feature_types = package.classes | where: "stereotype", "FeatureType" %}
|
28
|
+
{% assign object_types = package.classes | where: "stereotype", "ObjectType" %}
|
29
|
+
{% assign basic_types = package.classes | where: "stereotype", "BasicType" %}
|
30
|
+
{% assign unions = package.classes | where: "stereotype", "Union" %}
|
31
|
+
{% assign code_lists = package.classes | where: "stereotype", "CodeList" %}
|
32
|
+
{% if feature_types.size > 0 or object_types.size > 0 %}
|
33
|
+
{{equalsigns}}= Classes
|
34
|
+
|
35
|
+
{% include "packages_data_dictionary_classes", classes: feature_types %}
|
36
|
+
{% include "packages_data_dictionary_classes", classes: object_types %}
|
37
|
+
{% endif %}
|
38
|
+
|
39
|
+
{% if basic_types.size > 0 %}
|
40
|
+
{{equalsigns}}= Basic Types
|
41
|
+
|
42
|
+
{% include "packages_data_dictionary_classes", classes: basic_types %}
|
43
|
+
{% endif %}
|
44
|
+
|
45
|
+
{% if unions.size > 0 %}
|
46
|
+
{{equalsigns}}= Unions
|
47
|
+
|
48
|
+
{% include "packages_data_dictionary_classes", classes: unions %}
|
49
|
+
{% endif %}
|
50
|
+
|
51
|
+
{% if code_lists.size > 0 %}
|
52
|
+
{{equalsigns}}= Code Lists
|
53
|
+
|
54
|
+
{% include "packages_data_dictionary_classes", classes: code_lists %}
|
55
|
+
{% endif %}
|
56
|
+
|
57
|
+
{% if package.data_types.size > 0 %}
|
58
|
+
{{equalsigns}}= Data Types
|
59
|
+
|
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 %}
|
62
|
+
[[{{ data_type.name }}-section]]
|
63
|
+
[cols="1a"]
|
64
|
+
|===
|
65
|
+
|*{{ data_type.name }}*
|
66
|
+
|[cols="1,4",frame=none,grid=none]
|
67
|
+
!===
|
68
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Definition: ! {{ data_type.definition }}
|
69
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Subclass of: ! {{ generalizations }}
|
70
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Stereotype: ! «DataType»
|
71
|
+
!===
|
72
|
+
{% if data_type.associations.size > 0 %}
|
73
|
+
{% capture rendered_associations %}
|
74
|
+
{% for assoc in data_type.associations %}
|
75
|
+
{% if assoc.member_end_attribute_name.size > 0 %}
|
76
|
+
{% 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 %}
|
77
|
+
!{set:cellbgcolor:#FFFFFF} {{ assoc.member_end_attribute_name }} !<<{{assoc.member_end}}-section,{{assoc.member_end}}>> {{ cardinality }} ! {{ assoc.definition }}
|
78
|
+
{% endif %}
|
79
|
+
{% endfor %}
|
80
|
+
{% endcapture %}
|
81
|
+
{% if rendered_associations.size > 0 %}
|
82
|
+
|[cols="15,20,60",frame=none,grid=none,options="header"]
|
83
|
+
!===
|
84
|
+
!{set:cellbgcolor:#DDDDDD} *Role name* !*Target class and multiplicity* !*Definition*
|
85
|
+
{{ rendered_associations }}
|
86
|
+
!===
|
87
|
+
{% endif %}
|
88
|
+
{% endif %}
|
89
|
+
{% if data_type.attributes.size > 0 %}
|
90
|
+
|[cols="15,20,60",frame=none,grid=none,options="header"]
|
91
|
+
!===
|
92
|
+
!{set:cellbgcolor:#DDDDDD} *Attribute* !*Value type and multiplicity* !*Definition*
|
93
|
+
{% for attr in data_type.attributes %}
|
94
|
+
{% 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 %}
|
95
|
+
!{set:cellbgcolor:#FFFFFF} {{ attr.name }} !<<{{ attr.type }}-section,{{ attr.name }}>> {{ cardinality }} !{{ attr.definition }}
|
96
|
+
{% endfor %}
|
97
|
+
!===
|
98
|
+
|{set:cellbgcolor:#FFFFFF} Note: Unless otherwise specified, all attributes and role names have the stereotype «Property».
|
99
|
+
{% endif %}
|
100
|
+
|===
|
101
|
+
|
102
|
+
{% endfor %}
|
103
|
+
{% endif %}
|
104
|
+
|
105
|
+
{% if package.enums.size > 0 %}
|
106
|
+
{{equalsigns}}= Enumerations
|
107
|
+
|
108
|
+
{% for enum in package.enums %}
|
109
|
+
{% capture generalizations %}{% for assoc in enum.associations | where: "member_end_type", "generalization" %}{{ assoc.member_end }} {% endfor %}{% endcapture %}
|
110
|
+
[[{{ enum.name }}-section]]
|
111
|
+
[cols="1a"]
|
112
|
+
|===
|
113
|
+
|*{{ enum.name }}*
|
114
|
+
|[cols="1,4",frame=none,grid=none]
|
115
|
+
!===
|
116
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Definition: ! {{ enum.definition }}
|
117
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Stereotype: ! «Enumeration»
|
118
|
+
!===
|
119
|
+
{% if enum.values.size > 0 %}
|
120
|
+
|[cols="1,4",frame=none,grid=none,options="header"]
|
121
|
+
!===
|
122
|
+
^!{set:cellbgcolor:#DDDDDD} *Literal value* !*Definition*
|
123
|
+
|
124
|
+
{% for val in enum.values %}
|
125
|
+
^!{set:cellbgcolor:#FFFFFF} {{ val.name }} !{{ val.definition }}
|
126
|
+
{% endfor %}
|
127
|
+
!===
|
128
|
+
{% endif %}
|
129
|
+
|===
|
130
|
+
|
131
|
+
{% endfor %}
|
132
|
+
{% endif %}
|
133
|
+
|
134
|
+
{% if additional_context.include_block and additional_context.include_block.size > 0 %}
|
135
|
+
{% for block in additional_context.include_block %}
|
136
|
+
{% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
|
137
|
+
{% capture block_content %}{% include block_filename %}{% endcapture %}
|
138
|
+
{% unless block_content contains "Liquid error" %}
|
139
|
+
{% if block.text %}
|
140
|
+
{{ block.text }}
|
141
|
+
{% endif %}
|
142
|
+
{{ block_content }}
|
143
|
+
{% endunless %}
|
144
|
+
{% endfor %}
|
145
|
+
{% endif %}
|
146
|
+
|
147
|
+
{% assign include_block_package_key = 'include_block;' | append: package.name %}
|
148
|
+
{% if additional_context[include_block_package_key] and additional_context[include_block_package_key].size > 0 %}
|
149
|
+
{% for block in additional_context[include_block_package_key] %}
|
150
|
+
{% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
|
151
|
+
{% capture block_content %}{% include block_filename %}{% endcapture %}
|
152
|
+
{% unless block_content contains "Liquid error" %}
|
153
|
+
{% if block.text %}
|
154
|
+
{{ block.text }}
|
155
|
+
{% endif %}
|
156
|
+
{{ block_content }}
|
157
|
+
{% endunless %}
|
158
|
+
{% endfor %}
|
159
|
+
{% endif %}
|
160
|
+
|
161
|
+
{% assign after_package_key = 'after;' | append: package.name %}
|
162
|
+
{% if additional_context[after_package_key] %}
|
163
|
+
{{equalsigns}}= Additional Information
|
164
|
+
{% for after in additional_context[after_package_key] %}
|
165
|
+
{{ after.text }}
|
166
|
+
{% endfor %}
|
167
|
+
{% endif %}
|
168
|
+
{% if package.packages.size > 0 and render_nested_packages %}
|
169
|
+
{% assign nested_depth = depth | plus: 1 %}{% include "packages_data_dictionary", depth: nested_depth, context: package %}
|
170
|
+
{% endif %}
|
171
|
+
{% endfor %}
|
172
|
+
|
173
|
+
{% if additional_context.after and additional_context.after.size > 0 %}
|
174
|
+
{% for after in additional_context.after %}
|
175
|
+
{{ after.text }}
|
176
|
+
{% endfor %}
|
177
|
+
{% endif %}
|
@@ -0,0 +1,43 @@
|
|
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
|
+
|[cols="1,4",frame=none,grid=none]
|
8
|
+
!===
|
9
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Definition: ! {{ klass.definition }}
|
10
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Subclass of: ! {{ generalizations }}
|
11
|
+
!{nbsp}{nbsp}{nbsp}{nbsp}Stereotype: ! «{{ klass.stereotype }}»
|
12
|
+
!===
|
13
|
+
{% if klass.associations.size > 0 %}
|
14
|
+
{% capture rendered_associations %}
|
15
|
+
{% for assoc in klass.associations %}
|
16
|
+
{% if assoc.member_end_attribute_name.size > 0 %}
|
17
|
+
{% 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 %}
|
18
|
+
!{set:cellbgcolor:#FFFFFF} {{ assoc.member_end_attribute_name }} !<<{{assoc.member_end}}-section,{{assoc.member_end}}>> {{ cardinality }} ! {{ assoc.definition }}
|
19
|
+
{% endif %}
|
20
|
+
{% endfor %}
|
21
|
+
{% endcapture %}
|
22
|
+
{% if rendered_associations.size > 0 %}
|
23
|
+
|[cols="15,20,60",frame=none,grid=none,options="header"]
|
24
|
+
!===
|
25
|
+
!{set:cellbgcolor:#DDDDDD} *Role name* !*Target class and multiplicity* !*Definition*
|
26
|
+
{{ rendered_associations }}
|
27
|
+
!===
|
28
|
+
{% endif %}
|
29
|
+
{% endif %}
|
30
|
+
{% if klass.attributes.size > 0 %}
|
31
|
+
|[cols="15,20,60",frame=none,grid=none,options="header"]
|
32
|
+
!===
|
33
|
+
!{set:cellbgcolor:#DDDDDD} *Attribute* !*Value type and multiplicity* !*Definition*
|
34
|
+
{% for attr in klass.attributes %}
|
35
|
+
{% 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 %}
|
36
|
+
!{set:cellbgcolor:#FFFFFF} {{ attr.name }} !<<{{ attr.type }}-section,{{ attr.name }}>> {{ cardinality }} !{{ attr.definition }}
|
37
|
+
{% endfor %}
|
38
|
+
!===
|
39
|
+
|{set:cellbgcolor:#FFFFFF} Note: Unless otherwise specified, all attributes and role names have the stereotype «Property».
|
40
|
+
{% endif %}
|
41
|
+
|===
|
42
|
+
|
43
|
+
{% endfor %}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
{% for package in context.packages %}
|
2
|
+
{% assign package_name = package.name | downcase | replace: ":", "" | replace: " ", "_" %}
|
3
|
+
{% if additional_context.before and additional_context.before.size > 0 %}
|
4
|
+
{% for before in additional_context.before %}
|
5
|
+
{{ before.text }}
|
6
|
+
{% endfor %}
|
7
|
+
{% endif %}
|
8
|
+
{% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }}
|
9
|
+
[[rc_{{ package_name }}-model_section]]
|
10
|
+
{{equalsigns}}= {{ package.name }}
|
11
|
+
|
12
|
+
{% assign before_package_key = 'before;' | append: package.name %}
|
13
|
+
{% if additional_context[before_package_key] and additional_context[before_package_key].size > 0 %}
|
14
|
+
{% for before in additional_context[before_package_key] %}
|
15
|
+
{{ before.text }}
|
16
|
+
{% endfor %}
|
17
|
+
{% endif %}
|
18
|
+
{% if additional_context.diagram_include_block %}
|
19
|
+
{% for diagram_include_block in additional_context.diagram_include_block %}
|
20
|
+
{% include "diagrams_block", package_name: package_name, image_base_path: diagram_include_block.base_path, text: diagram_include_block.text %}
|
21
|
+
{% endfor %}
|
22
|
+
{% endif %}
|
23
|
+
|
24
|
+
{% if additional_context.include_block and additional_context.include_block.size > 0 %}
|
25
|
+
{% for block in additional_context.include_block %}
|
26
|
+
{% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
|
27
|
+
{% capture block_content %}{% include block_filename %}{% endcapture %}
|
28
|
+
{% unless block_content contains "Liquid error" %}
|
29
|
+
{% if block.text %}
|
30
|
+
{{ block.text }}
|
31
|
+
{% endif %}
|
32
|
+
{{ block_content }}
|
33
|
+
{% endunless %}
|
34
|
+
{% endfor %}
|
35
|
+
{% endif %}
|
36
|
+
|
37
|
+
{% assign include_block_package_key = 'include_block;' | append: package.name %}
|
38
|
+
{% if additional_context[include_block_package_key] and additional_context[include_block_package_key].size > 0 %}
|
39
|
+
{% for block in additional_context[include_block_package_key] %}
|
40
|
+
{% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
|
41
|
+
{% capture block_content %}{% include block_filename %}{% endcapture %}
|
42
|
+
{% unless block_content contains "Liquid error" %}
|
43
|
+
{% if block.text %}
|
44
|
+
{{ block.text }}
|
45
|
+
{% endif %}
|
46
|
+
{{ block_content }}
|
47
|
+
{% endunless %}
|
48
|
+
{% endfor %}
|
49
|
+
{% endif %}
|
50
|
+
|
51
|
+
{{equalsigns}}= Class Definitions
|
52
|
+
{% if package.classes.size > 0 %}
|
53
|
+
.Classes used in {{ package.name }}
|
54
|
+
[cols="2a,6a",options="header"]
|
55
|
+
|===
|
56
|
+
|Class |Description
|
57
|
+
|
58
|
+
{% for klass in package.classes %}
|
59
|
+
|<<{{ klass.name }}-section,{{ klass.name }}>>
|
60
|
+
«{{ klass.stereotype }}»
|
61
|
+
|{{ klass.definition }}
|
62
|
+
|
63
|
+
{% endfor %}
|
64
|
+
|===
|
65
|
+
{% endif %}
|
66
|
+
|
67
|
+
{% if package.data_types.size > 0 %}
|
68
|
+
.Data Types used in {{ package.name }}
|
69
|
+
[cols="2,6",options="header"]
|
70
|
+
|===
|
71
|
+
|Name |Description
|
72
|
+
|
73
|
+
{% for klass in package.data_types %}
|
74
|
+
|<<{{ klass.name }}-section,{{ klass.name }}>>
|
75
|
+
|{{ klass.definition }}
|
76
|
+
|
77
|
+
{% endfor %}
|
78
|
+
|
79
|
+
|===
|
80
|
+
{% endif %}
|
81
|
+
|
82
|
+
{% if package.enums.size > 0 %}
|
83
|
+
.Enumerated Classes used in {{ package.name }}
|
84
|
+
[cols="2a,6a",options="header"]
|
85
|
+
|===
|
86
|
+
|Name |Description
|
87
|
+
|
88
|
+
{% for klass in package.enums %}
|
89
|
+
|<<{{ klass.name }}-section,{{ klass.name }}>>
|
90
|
+
|{{ klass.definition }}
|
91
|
+
|
92
|
+
{% endfor %}
|
93
|
+
|
94
|
+
|===
|
95
|
+
{% endif %}
|
96
|
+
|
97
|
+
{% assign after_package_key = 'after;' | append: package.name %}
|
98
|
+
{% if additional_context[after_package_key] %}
|
99
|
+
{{equalsigns}}= Additional Information
|
100
|
+
{% for after in additional_context[after_package_key] %}
|
101
|
+
{{ after.text }}
|
102
|
+
{% endfor %}
|
103
|
+
{% endif %}
|
104
|
+
{% if package.packages.size > 0 and render_nested_packages %}
|
105
|
+
{% assign nested_depth = depth | plus: 1 %}{% include "packages_entity_list", depth: nested_depth, context: package %}
|
106
|
+
{% endif %}
|
107
|
+
{% endfor %}
|
108
|
+
|
109
|
+
{% if additional_context.after and additional_context.after.size > 0 %}
|
110
|
+
{% for after in additional_context.after %}
|
111
|
+
{{ after.text }}
|
112
|
+
{% endfor %}
|
113
|
+
{% endif %}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Metanorma
|
4
|
+
module Plugin
|
5
|
+
module Lutaml
|
6
|
+
class LutamlFigureInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
7
|
+
include LutamlDiagramBase
|
8
|
+
|
9
|
+
use_dsl
|
10
|
+
named :lutaml_figure
|
11
|
+
|
12
|
+
def process(parent, _target, attrs)
|
13
|
+
diagram_key = [attrs["package"], attrs["name"]].compact.join(":")
|
14
|
+
return if parent.document.attributes['lutaml_figure_id'].nil?
|
15
|
+
xmi_id = parent.document.attributes['lutaml_figure_id'][diagram_key]
|
16
|
+
return unless xmi_id
|
17
|
+
|
18
|
+
%Q(<xref target="figure-#{xmi_id}"></xref>)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -20,6 +20,14 @@ module Metanorma
|
|
20
20
|
Gem.loaded_specs["metanorma-plugin-lutaml"].full_gem_path,
|
21
21
|
"lib", "metanorma", "plugin", "lutaml", "liquid_templates"
|
22
22
|
)
|
23
|
+
DEFAULT_RENDER_INCLUDE = 'packages'.freeze
|
24
|
+
RENDER_STYLES_INCLUDES = {
|
25
|
+
'default' => 'packages',
|
26
|
+
'entity_list' => 'packages_entity_list',
|
27
|
+
'data_dictionary' => 'packages_data_dictionary'
|
28
|
+
}.freeze
|
29
|
+
SUPPORTED_NESTED_MACRO = %w[
|
30
|
+
before diagram_include_block after include_block].freeze
|
23
31
|
# search document for block `lutaml_uml_datamodel_description`
|
24
32
|
# read include derectives that goes after that in block and transform
|
25
33
|
# into yaml2text blocks
|
@@ -57,40 +65,63 @@ module Metanorma
|
|
57
65
|
block_match = line.match(MARCO_REGEXP)
|
58
66
|
return [line] if block_match.nil?
|
59
67
|
|
68
|
+
lutaml_document = lutaml_document_from_file(document, block_match[1])
|
69
|
+
fill_in_diagrams_attributes(document, lutaml_document)
|
60
70
|
model_representation(
|
61
|
-
|
71
|
+
lutaml_document,
|
62
72
|
document,
|
63
73
|
collect_additional_context(input_lines, input_lines.next),
|
64
74
|
parse_yaml_config_file(document, block_match[2]))
|
65
75
|
end
|
66
76
|
|
77
|
+
def fill_in_diagrams_attributes(document, lutaml_document_wrapper)
|
78
|
+
lutaml_document = lutaml_document_wrapper.original_document
|
79
|
+
package_flat_diagrams = lambda do |pks|
|
80
|
+
pks.each_with_object({}) do |package, res|
|
81
|
+
package.diagrams.map { |diag| res["#{package.name}:#{diag.name}"] = diag.xmi_id }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
children_pks_daigs = package_flat_diagrams.call(lutaml_document.packages.map(&:children_packages).flatten)
|
85
|
+
document.attributes['lutaml_figure_id'] = package_flat_diagrams.call(lutaml_document.packages)
|
86
|
+
.merge(children_pks_daigs)
|
87
|
+
end
|
88
|
+
|
67
89
|
def collect_additional_context(input_lines, end_mark)
|
68
|
-
additional_context = {}
|
90
|
+
additional_context = Hash.new { |hash, key| hash[key] = [] }
|
69
91
|
block_lines = []
|
70
92
|
while (block_line = input_lines.next) != end_mark
|
71
93
|
block_lines.push(block_line)
|
72
94
|
end
|
73
95
|
block_document = (Asciidoctor::Document.new(block_lines, {})).parse
|
74
96
|
block_document.blocks.each do |block|
|
97
|
+
next unless SUPPORTED_NESTED_MACRO.include?(block.attributes['role'])
|
98
|
+
|
75
99
|
attrs = block.attributes
|
76
100
|
name = attrs.delete('role')
|
77
101
|
package = attrs.delete('package')
|
78
102
|
macro_keyword = [name, package].compact.join(";")
|
79
|
-
|
103
|
+
block_text = block.lines.length > 0 ? block.lines[1..-2].join("\n") : ''
|
104
|
+
additional_context[macro_keyword].push({ 'text' => block_text }.merge(attrs))
|
80
105
|
end
|
81
106
|
additional_context
|
82
107
|
end
|
83
108
|
|
109
|
+
def package_level(lutaml_document, level)
|
110
|
+
return lutaml_document if level <= 0
|
111
|
+
|
112
|
+
package_level(lutaml_document['packages'].first, level - 1)
|
113
|
+
end
|
114
|
+
|
84
115
|
def create_context_object(lutaml_document, additional_context, options)
|
85
|
-
|
116
|
+
root_package = package_level(lutaml_document.to_liquid, options['package_root_level'] || 1)
|
117
|
+
if options.length.zero? || options['packages'].nil?
|
86
118
|
return {
|
87
119
|
'render_nested_packages' => true,
|
88
|
-
"packages" =>
|
120
|
+
"packages" => root_package['packages'],
|
89
121
|
"additional_context" => additional_context
|
90
122
|
}
|
91
123
|
end
|
92
124
|
|
93
|
-
root_package = lutaml_document.to_liquid['packages'].first
|
94
125
|
all_packages = [root_package, *root_package['children_packages']]
|
95
126
|
{
|
96
127
|
"packages" => sort_and_filter_out_packages(all_packages, options),
|
@@ -133,7 +164,7 @@ module Metanorma
|
|
133
164
|
|
134
165
|
def model_representation(lutaml_document, document, additional_context, options)
|
135
166
|
render_result, errors = Utils.render_liquid_string(
|
136
|
-
template_string: table_template,
|
167
|
+
template_string: table_template(options['section_depth'] || 2, options['render_style']),
|
137
168
|
context_items: create_context_object(lutaml_document,
|
138
169
|
additional_context,
|
139
170
|
options),
|
@@ -145,9 +176,10 @@ module Metanorma
|
|
145
176
|
render_result.split("\n")
|
146
177
|
end
|
147
178
|
|
148
|
-
def table_template
|
179
|
+
def table_template(section_depth, render_style)
|
180
|
+
include_name = RENDER_STYLES_INCLUDES.fetch(render_style, DEFAULT_RENDER_INCLUDE)
|
149
181
|
<<~LIQUID
|
150
|
-
{% include "
|
182
|
+
{% include "#{include_name}", depth: #{section_depth}, context: context, additional_context: context.additional_context, render_nested_packages: context.render_nested_packages %}
|
151
183
|
LIQUID
|
152
184
|
end
|
153
185
|
end
|
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.
|
4
|
+
version: 0.4.6
|
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-
|
11
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -261,11 +261,15 @@ files:
|
|
261
261
|
- lib/metanorma/plugin/lutaml/liquid_templates/_diagrams_block.liquid
|
262
262
|
- lib/metanorma/plugin/lutaml/liquid_templates/_packages.liquid
|
263
263
|
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_class.liquid
|
264
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary.liquid
|
265
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary_classes.liquid
|
264
266
|
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_type.liquid
|
267
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list.liquid
|
265
268
|
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_enum.liquid
|
266
269
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_base.rb
|
267
270
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb
|
268
271
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_block_macro.rb
|
272
|
+
- lib/metanorma/plugin/lutaml/lutaml_figure_inline_macro.rb
|
269
273
|
- lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
|
270
274
|
- lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb
|
271
275
|
- lib/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor.rb
|