metanorma-plugin-lutaml 0.4.6 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +155 -74
- data/lib/metanorma/plugin/lutaml/liquid/custom_filters.rb +9 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/_diagrams_block.liquid +1 -1
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages.liquid +113 -7
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_class.liquid +12 -12
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary.liquid +235 -63
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary_class.liquid +73 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary_classes.liquid +1 -41
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_type.liquid +9 -10
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list.liquid +134 -36
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list_class.liquid +19 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list_classes.liquid +11 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_enum.liquid +11 -11
- data/lib/metanorma/plugin/lutaml/liquid_templates/test.rb +1 -0
- data/lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb +1 -1
- data/lib/metanorma/plugin/lutaml/lutaml_table_inline_macro.rb +25 -0
- data/lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb +1 -1
- data/lib/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor.rb +93 -19
- data/lib/metanorma/plugin/lutaml/utils.rb +1 -1
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- data/lib/metanorma-plugin-lutaml.rb +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 241b12b07d457ea48176e22ce2cacc4a533c2ffc5435465637d51d37d6da1e80
|
4
|
+
data.tar.gz: 2a2bd1fe63f4febdae9ce40679f525cfe476f2a773ab15c5de9622145dbdbd7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ef546ecbc2929104ccda434021ef50afbd067d5f466b7d07181aea92415a15aaad67fdf3848b4bd0cf93878e032b007b437a630b1d5ea87398396b446b622f
|
7
|
+
data.tar.gz: 7373d126f78af6063dbfea6076018712f4185a6c0e75e50309befc23bf1e34beeec86ab80d8b36f9c73eb7e5ae238b0522e85ec307ee434538222790cc05d8c3
|
data/README.adoc
CHANGED
@@ -1,21 +1,36 @@
|
|
1
|
-
= metanorma-plugin-lutaml
|
1
|
+
= Metanorma LutaML plugin (metanorma-plugin-lutaml)
|
2
2
|
|
3
3
|
image:https://github.com/metanorma/metanorma-plugin-lutaml/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-plugin-lutaml/actions?workflow=rake"]
|
4
4
|
|
5
|
-
==
|
5
|
+
== Purpose
|
6
6
|
|
7
|
-
|
7
|
+
LutaML is a data model accessor that supports various data model formats,
|
8
|
+
including:
|
8
9
|
|
9
|
-
|
10
|
+
* EXPRESS (`*.exp` files)
|
11
|
+
* OMG UML in XMI format (`*.xmi` files)
|
12
|
+
|
13
|
+
This plugin allows you to access LutaML models from within a Metanorma document.
|
14
|
+
|
15
|
+
== Installation
|
10
16
|
|
11
17
|
[source,console]
|
12
18
|
----
|
13
19
|
$ gem install metanorma-plugin-lutaml
|
14
20
|
----
|
15
21
|
|
16
|
-
=== Usage, `lutaml` macro
|
17
22
|
|
18
|
-
|
23
|
+
== Usage with EXPRESS
|
24
|
+
|
25
|
+
=== General
|
26
|
+
|
27
|
+
LutaML supports accessing EXPRESS models via the
|
28
|
+
https://github.com/lutaml/expressir[Expressir] parser.
|
29
|
+
|
30
|
+
|
31
|
+
=== Usage of the `lutaml` macro
|
32
|
+
|
33
|
+
Given an `example.exp` EXPRESS file with the content:
|
19
34
|
|
20
35
|
[source,exp]
|
21
36
|
----
|
@@ -71,17 +86,18 @@ source directory that `[lutaml]` is used (e.g., if
|
|
71
86
|
`/foo/bar/doc.adoc`, the data file is expected to be found at
|
72
87
|
`/foo/bar/example.exp`);
|
73
88
|
|
74
|
-
* `{my_context}` is the name where the EXPRESS Repository read from the
|
75
|
-
file can be accessed with.
|
76
|
-
|
89
|
+
* `{my_context}` is the name where the EXPRESS Repository read from the `.exp`
|
90
|
+
file can be accessed with.
|
91
|
+
|
92
|
+
** The `context` object is a serialized `Expressir::Model::Repository` object
|
93
|
+
with all variable names available. See
|
77
94
|
https://github.com/lutaml/expressir[Expressir] docs for reference.
|
78
95
|
`{my_context}` has `schemas` method to access Expressir
|
79
96
|
https://github.com/lutaml/expressir/blob/master/lib/expressir/model/schema.rb[schemas]
|
80
97
|
|
81
98
|
Will produce this output:
|
82
99
|
|
83
|
-
|
84
|
-
-----
|
100
|
+
____
|
85
101
|
== test_schema
|
86
102
|
|
87
103
|
=== my_type1
|
@@ -89,9 +105,9 @@ Will produce this output:
|
|
89
105
|
=== my_type3
|
90
106
|
=== my_type4
|
91
107
|
=== my_type5
|
92
|
-
|
108
|
+
____
|
93
109
|
|
94
|
-
This
|
110
|
+
This command also supports `.lutaml` files.
|
95
111
|
|
96
112
|
Instead of using the direct path to the file one can use `lutaml-express-index`
|
97
113
|
document attribute to supply directory with express files or YAML index file to
|
@@ -120,19 +136,22 @@ Example of usage:
|
|
120
136
|
-----
|
121
137
|
= Document title
|
122
138
|
Author
|
123
|
-
:lutaml-express-index:
|
124
|
-
[lutaml,
|
139
|
+
:lutaml-express-index: index_name; /path/to/express_files; cache=/path/to/cache_file.yaml
|
140
|
+
[lutaml,index_name,context]
|
125
141
|
----
|
126
|
-
{% for schema in
|
142
|
+
{% for schema in context.schemas %}
|
127
143
|
== {{schema.id}}
|
128
144
|
{% endfor %}
|
129
145
|
----
|
130
146
|
-----
|
131
147
|
|
132
|
-
|
148
|
+
== Usage with UML
|
133
149
|
|
134
|
-
|
135
|
-
|
150
|
+
=== Rendering a LutaML view: `lutaml_diagram`
|
151
|
+
|
152
|
+
This command allows to quickly render a LutaML view as an image file.
|
153
|
+
|
154
|
+
Given a file `example.lutaml` file with content:
|
136
155
|
|
137
156
|
[source,java]
|
138
157
|
----
|
@@ -142,7 +161,7 @@ diagram MyView {
|
|
142
161
|
enum AddressClassProfile {
|
143
162
|
imlicistAttributeProfile: CharacterString [0..1] {
|
144
163
|
definition
|
145
|
-
this is multiline with `
|
164
|
+
this is multiline with `asciidoc`
|
146
165
|
end definition
|
147
166
|
}
|
148
167
|
}
|
@@ -156,16 +175,17 @@ diagram MyView {
|
|
156
175
|
}
|
157
176
|
----
|
158
177
|
|
159
|
-
|
178
|
+
The `lutaml_diagram` command will add the image to the document.
|
160
179
|
|
161
180
|
[source,adoc]
|
162
181
|
-----
|
163
182
|
lutaml_diagram::example.lutaml[]
|
164
183
|
-----
|
165
184
|
|
166
|
-
|
185
|
+
The `lutaml_diagram` command can also be used to denote a block with an embedded
|
186
|
+
LutaML view.
|
167
187
|
|
168
|
-
|
188
|
+
For example:
|
169
189
|
|
170
190
|
[source,java]
|
171
191
|
----
|
@@ -176,9 +196,9 @@ diagram MyView {
|
|
176
196
|
|
177
197
|
enum AddressClassProfile {
|
178
198
|
imlicistAttributeProfile: CharacterString [0..1] {
|
179
|
-
definition
|
180
|
-
|
181
|
-
|
199
|
+
definition {
|
200
|
+
This is multiline AsciiDoc content.
|
201
|
+
}
|
182
202
|
}
|
183
203
|
}
|
184
204
|
|
@@ -193,9 +213,9 @@ diagram MyView {
|
|
193
213
|
----
|
194
214
|
|
195
215
|
|
196
|
-
===
|
216
|
+
=== `lutaml_uml_attributes_table`
|
197
217
|
|
198
|
-
This
|
218
|
+
This command allows rendering definition tables for a UML model.
|
199
219
|
|
200
220
|
Given `example.lutaml` file with the content:
|
201
221
|
|
@@ -230,23 +250,22 @@ And the `lutaml_uml_attributes_table` macro:
|
|
230
250
|
|
231
251
|
Will produce this output:
|
232
252
|
|
233
|
-
|
234
|
-
-----
|
253
|
+
____
|
235
254
|
=== AttributeProfile
|
236
255
|
|
237
|
-
|
238
256
|
.AttributeProfile attributes
|
239
257
|
|===
|
240
258
|
|Name |Definition |Mandatory/ Optional/ Conditional |Max Occur |Data Type
|
241
259
|
|
242
|
-
|addressClassProfile |TODO: enum
|
260
|
+
|addressClassProfile |TODO: enum's definition |M |1 | `CharacterString`
|
243
261
|
|
244
262
|
|imlicistAttributeProfile |this is attribute definition with multiply lines |M |1 | `CharacterString`
|
245
263
|
|
246
264
|
|===
|
247
|
-
|
265
|
+
____
|
248
266
|
|
249
|
-
|
267
|
+
|
268
|
+
In case of "enumeration" (AddressClassProfile) entity:
|
250
269
|
|
251
270
|
[source,adoc]
|
252
271
|
-----
|
@@ -255,23 +274,21 @@ In case of "enumeration"(AddressClassProfile) entity:
|
|
255
274
|
|
256
275
|
Will produce this output:
|
257
276
|
|
258
|
-
|
259
|
-
-----
|
277
|
+
____
|
260
278
|
=== AddressClassProfile
|
261
279
|
|
262
|
-
|
263
280
|
.AddressClassProfile values
|
264
281
|
|===
|
265
282
|
|Name |Definition
|
266
283
|
|
267
|
-
|imlicistAttributeProfile |this is multiline with `
|
284
|
+
|imlicistAttributeProfile |this is multiline with `asciidoc`
|
268
285
|
|
269
286
|
|===
|
270
|
-
|
287
|
+
____
|
271
288
|
|
272
|
-
=== Usage
|
289
|
+
=== Usage of `lutaml_uml_datamodel_description` macro
|
273
290
|
|
274
|
-
This
|
291
|
+
This command allows to quickly render data model packages and its dependent
|
275
292
|
objects for supplied XMI file.
|
276
293
|
|
277
294
|
Given an Enterprise Architect `example.xmi` file with 2 packages:
|
@@ -290,7 +307,7 @@ The `lutaml_uml_datamodel_description` macro can be used:
|
|
290
307
|
my text
|
291
308
|
....
|
292
309
|
|
293
|
-
[.diagram_include_block, base_path="requirements/"]
|
310
|
+
[.diagram_include_block, base_path="requirements/", format="emf"]
|
294
311
|
....
|
295
312
|
Diagram text
|
296
313
|
....
|
@@ -332,41 +349,67 @@ Where:
|
|
332
349
|
|
333
350
|
* `path/to/example.xmi` - required, path to the XMI file to render
|
334
351
|
|
335
|
-
* `[.before]` -
|
352
|
+
* `[.before]` - block text that adds 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 `....`)
|
353
|
+
|
354
|
+
* `[.after]` - block text that adds additional text after the rendered output, can be used only once, additional occurrences of macro will overwrite text
|
336
355
|
|
337
|
-
* `[.after]` -
|
356
|
+
* `[.after, package="Another"]` - block text to be inserted before(after in case of `.before` name) the package
|
338
357
|
|
339
|
-
* `[.after, package="Another"]` -
|
358
|
+
* `[.package_text, position="after", package="Another"]` - include custom adoc code into package rendered body, `position` is a arequired attribute which tells where to insert the code.
|
340
359
|
|
341
|
-
* `[.
|
360
|
+
* `[.package_text, package="Another"]` - same as above, but include block will be included only for supplied package name
|
361
|
+
|
362
|
+
* `[.diagram_include_block]` - block text to automatically include diagram images. Attribute `base_path` is a required attribute to supply path prefix where to look for a diagram image. `format` is an optional attribute that tells what file extension to use when including diagram file.
|
363
|
+
+
|
364
|
+
The logic is as follows:
|
342
365
|
[source,adoc]
|
343
366
|
-----
|
344
367
|
{% for diagram in package.diagrams %}
|
345
368
|
[[figure-{{ diagram.xmi_id }}]]
|
346
369
|
.{{ diagram.name }}
|
347
|
-
image::{{ image_base_path }}/{{ diagram.xmi_id }}.png[]
|
370
|
+
image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[]
|
348
371
|
|
349
372
|
{% if diagram.definition %}
|
350
373
|
{{ diagram.definition | html2adoc }}
|
351
374
|
{% endif %}
|
352
375
|
{% endfor %}
|
353
376
|
-----
|
354
|
-
|
377
|
+
|
378
|
+
For instance, the script will take package diagrams supplied in the XMI file and will try to include `image` with the name equal to diagram' xmi_id attribute plus `.png`. Also one can add any text to the macro text, it will be added as paragraph before each image include.
|
355
379
|
|
356
380
|
* `[.diagram_include_block, package="Another"]` - same as above, but diagram will be included only for supplied package name
|
357
381
|
|
358
|
-
* `[.include_block, base_path="spec/fixtures"]` - macro to
|
382
|
+
* `[.include_block, base_path="spec/fixtures"]` - macro to include files (`*.adoc` or `*.liquid`) for each package name. Attribute `base_path` is a required attribute to supply path prefix where to look for file to include. Macro will look for a file called `base_path` + `/` `_package_name`(downcase, replace : -> '', ' ' -> '_') + `.adoc`[`.liquid`], eg for package 'My Package name' and `base_path` eq to `my/path`, macro will look for the following file path: `my/path/_my_package_name.adoc`.
|
359
383
|
|
360
384
|
* `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but include block will be included only for supplied package name
|
361
385
|
|
362
|
-
|
386
|
+
|
387
|
+
NOTE: .after, .before, package_text and include_block macroses all can be used with additional option - `liquid`, if this option is supplied then the code inside block will be interpolated in liquid context
|
388
|
+
|
389
|
+
|
390
|
+
There are two other commands that are used to refer to LutaML generated document elements:
|
391
|
+
|
392
|
+
* `lutaml_figure`. Provides a reference anchor to a figure defined in the XMI
|
393
|
+
file, using its XMI ID for reference.
|
394
|
+
|
395
|
+
* `lutaml_table`. Provides a reference anchor to the definition tables of a
|
396
|
+
particular package, class, enumeration or data type object in the XMI.
|
397
|
+
|
398
|
+
The syntax is as follows:
|
363
399
|
|
364
400
|
[source,adoc]
|
365
401
|
-----
|
402
|
+
// For lutaml_figure
|
366
403
|
This is lutaml_figure::[package="Wrapper root package", name="Fig B1 Full model"] figure
|
404
|
+
|
405
|
+
// For lutaml_table
|
406
|
+
This is lutaml_table::[package="Wrapper root package"] package
|
407
|
+
This is lutaml_table::[package="Wrapper root package", class="my name"] class
|
408
|
+
This is lutaml_table::[package="Wrapper root package", enum="my name"] enumeration
|
409
|
+
This is lutaml_table::[package="Wrapper root package", data_type="my name"] data type
|
367
410
|
-----
|
368
411
|
|
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
|
412
|
+
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.
|
370
413
|
|
371
414
|
Will produce this output:
|
372
415
|
|
@@ -380,18 +423,17 @@ Diagram text
|
|
380
423
|
|
381
424
|
[[figure-EAID_ACBB5EE3_3428_40f5_9C7C_E41923419F29]]
|
382
425
|
.CityGML Package Diagram
|
383
|
-
image::requirements
|
426
|
+
image::requirements/EAID_ACBB5EE3_3428_40f5_9C7C_E41923419F29.png[]
|
384
427
|
|
385
428
|
BuildingFurnitureFunctionValue is a code list that enumerates the different purposes of a BuildingFurniture.
|
386
429
|
|
387
430
|
[[figure-EAID_938AE961_1C57_4052_B964_997D1894A58D]]
|
388
431
|
.Use of ISO and OASIS standards in CityGML
|
389
|
-
image::requirements
|
432
|
+
image::requirements/EAID_938AE961_1C57_4052_B964_997D1894A58D.png[]
|
390
433
|
|
391
434
|
The CityGML package is organized into
|
392
435
|
2 packages with 1 modules:
|
393
436
|
|
394
|
-
[arabic]
|
395
437
|
. Another package
|
396
438
|
. CityTML package
|
397
439
|
|
@@ -401,18 +443,17 @@ Content for CityGML package
|
|
401
443
|
|
402
444
|
==== Defining tables
|
403
445
|
|
404
|
-
|
405
|
-
.<<tab-P-another-C-abstractatomictimeseries>> -- Elements of Another::AbstractAtomicTimeseries
|
446
|
+
.<<section-EAPK_9C96A88B_E98B_490b_8A9C_24AEDAC64293>> -- Elements of “Another::AbstractAtomicTimeseries” (class)
|
406
447
|
|
407
|
-
[[
|
408
|
-
.Elements of Another::AbstractAtomicTimeseries
|
448
|
+
[[section-EAPK_9C96A88B_E98B_490b_8A9C_24AEDAC64293]]
|
449
|
+
.Elements of “Another::AbstractAtomicTimeseries” (class)
|
409
450
|
[width="100%",cols="a,a,a,a,a,a,a,a"]
|
410
451
|
|===
|
411
452
|
h|Name: 7+| AbstractAtomicTimeseries
|
412
453
|
h|Definition: 7+|
|
413
454
|
h|Stereotype: 7+| interface
|
414
455
|
h|Abstract: 7+|
|
415
|
-
|
456
|
+
h|Associations: 7+| (none)
|
416
457
|
.4+h|Public attributes:
|
417
458
|
| _Name_
|
418
459
|
2+| _Definition_
|
@@ -446,13 +487,20 @@ h|Constraints: 7+| (none)
|
|
446
487
|
text after CityGML package
|
447
488
|
-----
|
448
489
|
|
449
|
-
In addition to
|
450
|
-
|
490
|
+
In addition to the XMI file, this macro also supports a YAML configuration file
|
491
|
+
that specifies:
|
492
|
+
|
493
|
+
* What packages to include in the render;
|
494
|
+
|
495
|
+
* What render style is desired;
|
451
496
|
|
452
|
-
|
497
|
+
* Location of the root package (which package should the iterative process start
|
498
|
+
at).
|
499
|
+
|
500
|
+
The format for using the YAML configuration file:
|
453
501
|
|
454
502
|
[source,yaml]
|
455
|
-
|
503
|
+
----
|
456
504
|
---
|
457
505
|
packages:
|
458
506
|
# includes these packages
|
@@ -461,34 +509,67 @@ packages:
|
|
461
509
|
- three
|
462
510
|
# skips these packages
|
463
511
|
- skip: four
|
464
|
-
render_style: entity_list|data_dictionary|default
|
512
|
+
render_style: entity_list | data_dictionary | default
|
465
513
|
section_depth: 2
|
466
|
-
|
514
|
+
----
|
467
515
|
|
468
516
|
Where:
|
469
517
|
|
470
518
|
* `packages` - required, root element with the list of strings or objects
|
519
|
+
|
471
520
|
* `Package *` - pattern matching, specifies lookup condition for packages to
|
472
521
|
render.
|
473
522
|
+
|
474
523
|
NOTE: In this example, it is equal to the following regular expression: `/^Package.*$/`
|
475
524
|
|
476
525
|
* `skip: four` - object with package name to skip
|
477
|
-
|
478
|
-
* `
|
526
|
+
|
527
|
+
* `render_style` - what template to use to render packages, can be one of:
|
528
|
+
|
529
|
+
** `entity_list`
|
530
|
+
|
531
|
+
** `data_dictionary`; or
|
532
|
+
|
533
|
+
** `default`
|
534
|
+
|
535
|
+
* `section_depth` - what package to use as root package for render.
|
536
|
+
e.g., a `section_depth` equal to `2` tells the processor to use the first
|
537
|
+
nested package of the first root packages in XMI file.
|
538
|
+
+
|
539
|
+
EXAMPLE: If the XMI file has this package structure, and we have `section_depth`
|
540
|
+
equal to 2, root package will be `one-1`.
|
541
|
+
+
|
542
|
+
[source,json]
|
543
|
+
----
|
544
|
+
[
|
545
|
+
{
|
546
|
+
name: 'One',
|
547
|
+
packages: [{ name: 'one-1' }, { name: 'one-2' }]
|
548
|
+
},
|
549
|
+
{
|
550
|
+
name: 'Two',
|
551
|
+
packages: [{ name: 'two-1' }, { name: 'two-2' }]
|
552
|
+
}
|
553
|
+
]
|
554
|
+
----
|
479
555
|
|
480
556
|
Usage with macro:
|
481
557
|
|
482
558
|
[source,adoc]
|
483
|
-
|
559
|
+
--
|
484
560
|
[lutaml_uml_datamodel_description, path/to/example.xmi, path/to/config.yml]
|
485
|
-
|
486
|
-
|
561
|
+
----
|
562
|
+
[.diagram_include_block, base_path="models/Images", format="png"]
|
563
|
+
...
|
564
|
+
...
|
565
|
+
----
|
566
|
+
--
|
487
567
|
|
488
|
-
The
|
489
|
-
to the order supplied in the
|
490
|
-
will be skipped during
|
568
|
+
The processor will read the supplied YAML config file (`path/to/config.yml`),
|
569
|
+
and iterate through packages according to the order supplied in the file. All
|
570
|
+
packages that matches `skip` in the YAML config file will be skipped during
|
571
|
+
render.
|
491
572
|
|
492
573
|
== Documentation
|
493
574
|
|
494
|
-
Please refer to https://www.metanorma.
|
575
|
+
Please refer to https://www.metanorma.oeg.
|