metanorma-plugin-lutaml 0.4.4 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 213cd8b2ecaa1b45360480fc2de787f6708b625f5370b7e7617317d77b703ee6
4
- data.tar.gz: 396fd04d0ac3f979a6a9ee3b425988fc17af5a267b8e140438a92b73ac41dd5f
3
+ metadata.gz: 202335c2a56ade17a5bdfedd489b6c39363b256ebbaa2e2cbfe812a6bb6995e5
4
+ data.tar.gz: 9637bc5a68bbbe8cda105e74a537ae7e41d5676f584e64e907ad26ba6cf50082
5
5
  SHA512:
6
- metadata.gz: 37ad00c2a5bed4ddd9314ad99883545b526ed461e92d99de045072e900592c09798d82dc6119017a5e7656d891c1ea0cc331c844801ec2c0b4d2aae8784775aa
7
- data.tar.gz: b8b6cb960be27fc5612c7a987250cd607ea0ae3f07dec61e44334765a64f7d5c22d245a108f2bbfdd4ec6fdc34e3b822b87fb801f70a3406611639d887ea00a9
6
+ metadata.gz: 7e183219067f431d7b839d59ab3e5c8a8b3f54b335cb1e232297f1fa997e7f7abafa4a0858d5398a034c2a025d46feef240f3e71b14db7730fb1789b2dd11afb
7
+ data.tar.gz: 400132cae1b7b1b3f03414f4c4ab8b16edde68ab285cd192bd0894d913bee26985182aaf880c2a4ddac1935541bac62913679424e433d88bacc8242c7fcabede
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
- == Functionality
5
+ == Purpose
6
6
 
7
- Metanorma plugin that allows you to access lutaml objects from a Metanorma document
7
+ LutaML is a data model accessor that supports various data model formats,
8
+ including:
8
9
 
9
- === Installation
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
- Given `example.exp` file with the content:
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_express` EXPRESS macro
32
+
33
+ Given an `example.exp` EXPRESS file with the content:
19
34
 
20
35
  [source,exp]
21
36
  ----
@@ -42,11 +57,11 @@ SCHEMA test_schema 'test';
42
57
  END_SCHEMA;
43
58
  ----
44
59
 
45
- And the `lutaml` macro block:
60
+ And the `lutaml_express` macro block:
46
61
 
47
62
  [source,adoc]
48
63
  -----
49
- [lutaml,example.exp,my_context]
64
+ [lutaml_express,example.exp,my_context]
50
65
  ----
51
66
 
52
67
  {% for schema in my_context.schemas %}
@@ -67,13 +82,15 @@ Where:
67
82
  * `{example.exp}` is the location of the EXPRESS schema file (`*.exp`) that
68
83
  contains data to be loaded. Location of the file is computed relative to the
69
84
  source directory that `[lutaml]` is used (e.g., if
70
- `[lutaml,example.exp,my_context]` is invoked in an `.adoc` file located at
85
+ `[lutaml_express,example.exp,my_context]` is invoked in an `.adoc` file located at
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 .exp
75
- file can be accessed with. Context object is a serialized
76
- `Expressir::Model::Repository` object with all variable names available. See
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]
@@ -121,7 +138,7 @@ Example of usage:
121
138
  = Document title
122
139
  Author
123
140
  :lutaml-express-index: my_custom_name; /path/to/express_files; cache=/path/to/cache_file.yaml
124
- [lutaml,my_custom_name,my_context]
141
+ [lutaml_express,my_custom_name,my_context]
125
142
  ----
126
143
  {% for schema in my_context.schemas %}
127
144
  == {{schema.id}}
@@ -142,7 +159,7 @@ diagram MyView {
142
159
  enum AddressClassProfile {
143
160
  imlicistAttributeProfile: CharacterString [0..1] {
144
161
  definition
145
- this is multiline with `ascidoc`
162
+ this is multiline with `asciidoc`
146
163
  end definition
147
164
  }
148
165
  }
@@ -193,7 +210,7 @@ diagram MyView {
193
210
  ----
194
211
 
195
212
 
196
- === Usage, `lutaml_uml_attributes_table` macro
213
+ === Usage of `lutaml_uml_attributes_table` macro
197
214
 
198
215
  This macro allows to quickly render data model attributes/values tables.
199
216
 
@@ -246,7 +263,7 @@ Will produce this output:
246
263
  |===
247
264
  -----
248
265
 
249
- In case of "enumeration"(AddressClassProfile) entity:
266
+ In case of "enumeration" (AddressClassProfile) entity:
250
267
 
251
268
  [source,adoc]
252
269
  -----
@@ -264,12 +281,12 @@ Will produce this output:
264
281
  |===
265
282
  |Name |Definition
266
283
 
267
- |imlicistAttributeProfile |this is multiline with `ascidoc`
284
+ |imlicistAttributeProfile |this is multiline with `asciidoc`
268
285
 
269
286
  |===
270
287
  -----
271
288
 
272
- === Usage, `lutaml_uml_datamodel_description` macro
289
+ === Usage of `lutaml_uml_datamodel_description` macro
273
290
 
274
291
  This macro allows to quickly render data model packages and its dependent
275
292
  objects for supplied XMI file.
@@ -286,44 +303,44 @@ The `lutaml_uml_datamodel_description` macro can be used:
286
303
  [lutaml_uml_datamodel_description, path/to/example.xmi]
287
304
  --
288
305
  [.before]
289
- ...
306
+ ....
290
307
  my text
291
- ...
308
+ ....
292
309
 
293
- [.diagram_include_block, base_path="requirements/"]
294
- ...
310
+ [.diagram_include_block, base_path="requirements/", format="emf"]
311
+ ....
295
312
  Diagram text
296
- ...
313
+ ....
297
314
 
298
315
  [.include_block, package="Another", base_path="spec/fixtures"]
299
- ...
316
+ ....
300
317
  my text
301
- ...
318
+ ....
302
319
 
303
320
  [.include_block, base_path="spec/fixtures"]
304
- ...
321
+ ....
305
322
  my text
306
- ...
323
+ ....
307
324
 
308
325
  [.before, package="Another"]
309
- ...
326
+ ....
310
327
  text before Another package
311
- ...
328
+ ....
312
329
 
313
330
  [.after, package="Another"]
314
- ...
331
+ ....
315
332
  text after Another package
316
- ...
333
+ ....
317
334
 
318
335
  [.after, package="CityGML"]
319
- ...
336
+ ....
320
337
  text after CityGML package
321
- ...
338
+ ....
322
339
 
323
340
  [.after]
324
- ...
341
+ ....
325
342
  footer text
326
- ...
343
+ ....
327
344
  --
328
345
  --
329
346
  -----
@@ -332,33 +349,42 @@ Where:
332
349
 
333
350
  * `path/to/example.xmi` - required, path to the XMI file to render
334
351
 
335
- * `[.before]` - macro to add additional text before the rendered output, can be used only once, additional occurrences of macro will overwrite text
352
+ * `[.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
353
 
337
354
  * `[.after]` - macro to add additional text after the rendered output, can be used only once, additional occurrences of macro will overwrite text
338
355
 
339
356
  * `[.after, package="Another"]` - macro with text to be inserted before(after in case of `.before` name) the package
340
357
 
341
- * `[.diagram_include_block]` - macro to automatically include diagram images. Attribute `base_path` is a required attribute to supply path prefix where to look for a digram image. The logic is as follows:
358
+ * `[.diagram_include_block]` - macro 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. The logic is as follows:
342
359
  [source,adoc]
343
360
  -----
344
361
  {% for diagram in package.diagrams %}
345
362
  [[figure-{{ diagram.xmi_id }}]]
346
363
  .{{ diagram.name }}
347
- image::{{ image_base_path }}/{{ diagram.xmi_id }}.png[]
364
+ image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[]
348
365
 
349
366
  {% if diagram.definition %}
350
367
  {{ diagram.definition | html2adoc }}
351
368
  {% endif %}
352
369
  {% endfor %}
353
370
  -----
354
- Eg: script will take package diagrams supplied in 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.
371
+
372
+ 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
373
 
356
374
  * `[.diagram_include_block, package="Another"]` - same as above, but diagram will be included only for supplied package name
357
375
 
358
- * `[.include_block, base_path="spec/fixtures"]` - macro to inlude files(adoc/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`.
376
+ * `[.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
377
 
360
378
  * `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but include block will be included only for supplied package name
361
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:
381
+
382
+ [source,adoc]
383
+ -----
384
+ This is lutaml_figure::[package="Wrapper root package", name="Fig B1 Full model"] figure
385
+ -----
386
+
387
+ 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.
362
388
 
363
389
  Will produce this output:
364
390
 
@@ -372,18 +398,17 @@ Diagram text
372
398
 
373
399
  [[figure-EAID_ACBB5EE3_3428_40f5_9C7C_E41923419F29]]
374
400
  .CityGML Package Diagram
375
- image::requirements//EAID_ACBB5EE3_3428_40f5_9C7C_E41923419F29.png[]
401
+ image::requirements/EAID_ACBB5EE3_3428_40f5_9C7C_E41923419F29.png[]
376
402
 
377
403
  BuildingFurnitureFunctionValue is a code list that enumerates the different purposes of a BuildingFurniture.
378
404
 
379
405
  [[figure-EAID_938AE961_1C57_4052_B964_997D1894A58D]]
380
406
  .Use of ISO and OASIS standards in CityGML
381
- image::requirements//EAID_938AE961_1C57_4052_B964_997D1894A58D.png[]
407
+ image::requirements/EAID_938AE961_1C57_4052_B964_997D1894A58D.png[]
382
408
 
383
409
  The CityGML package is organized into
384
410
  2 packages with 1 modules:
385
411
 
386
- [arabic]
387
412
  . Another package
388
413
  . CityTML package
389
414
 
@@ -393,18 +418,17 @@ Content for CityGML package
393
418
 
394
419
  ==== Defining tables
395
420
 
396
- [arabic]
397
- .<<tab-P-another-C-abstractatomictimeseries>> -- Elements of Another::AbstractAtomicTimeseries
421
+ .<<tab-P-another-C-{XMI_ID}>> -- Elements of &#8220;Another::AbstractAtomicTimeseries&#8221; (class)
398
422
 
399
- [[tab-P-another-C-abstractatomictimeseries]]
400
- .Elements of Another::AbstractAtomicTimeseries
423
+ [[tab-P-another-C-{XMI_ID}]]
424
+ .Elements of &#8220;Another::AbstractAtomicTimeseries&#8221; (class)
401
425
  [width="100%",cols="a,a,a,a,a,a,a,a"]
402
426
  |===
403
427
  h|Name: 7+| AbstractAtomicTimeseries
404
428
  h|Definition: 7+|
405
429
  h|Stereotype: 7+| interface
406
430
  h|Abstract: 7+|
407
- .1+h|Associations: 7+| (none)
431
+ h|Associations: 7+| (none)
408
432
  .4+h|Public attributes:
409
433
  | _Name_
410
434
  2+| _Definition_
@@ -438,7 +462,7 @@ h|Constraints: 7+| (none)
438
462
  text after CityGML package
439
463
  -----
440
464
 
441
- In addition to just supplying XMI file, this macro also supports YAML
465
+ In addition to just supplying an XMI file, this macro also supports a YAML
442
466
  configuration file.
443
467
 
444
468
  The format for using YAML is this:
@@ -453,26 +477,33 @@ packages:
453
477
  - three
454
478
  # skips these packages
455
479
  - skip: four
480
+ render_style: entity_list|data_dictionary|default
481
+ section_depth: 2
456
482
  -----
457
483
 
458
484
  Where:
459
485
 
460
486
  * `packages` - required, root element with the list of strings or objects
461
-
462
487
  * `Package *` - pattern matching, specifies lookup condition for packages to
463
488
  render.
464
489
  +
465
490
  NOTE: In this example, it is equal to the following regular expression: `/^Package.*$/`
466
491
 
467
492
  * `skip: four` - object with package name to skip
493
+ * `render_style` - what template to use to render packages, can be: entity_list, data_dictionary or default
494
+ * `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
495
 
469
496
  Usage with macro:
470
497
 
471
498
  [source,adoc]
472
- -----
499
+ --
473
500
  [lutaml_uml_datamodel_description, path/to/example.xmi, path/to/config.yml]
474
- ....
475
- -----
501
+ ----
502
+ [.diagram_include_block, base_path="models/Images", format="png"]
503
+ ...
504
+ ...
505
+ ----
506
+ --
476
507
 
477
508
  The macro processor will read supplied YAML file and arrange packages according
478
509
  to the order supplied in the config file, also all packages supplied as `skip`
@@ -3,7 +3,7 @@
3
3
  {% for diagram in package.diagrams %}
4
4
  [[figure-{{ diagram.xmi_id }}]]
5
5
  .{{ diagram.name }}
6
- image::{{ image_base_path }}/{{ diagram.xmi_id }}.png[]
6
+ image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[]
7
7
 
8
8
  {% if diagram.definition %}
9
9
  {{ diagram.definition | html2adoc }}
@@ -1,28 +1,38 @@
1
1
  {% for package in context.packages %}
2
2
  {% assign package_name = package.name | downcase | replace: ":", "" | replace: " ", "_" %}
3
- {% if additional_context.before %}
4
- {{ additional_context.before.text }}
5
- {% endif %}
6
- {% assign before_package_key = 'before;' | append: package.name %}
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 %}
12
10
  {% elsif is_package_spare == 'Spare' %}{% continue %}
13
11
  {% endif %}
14
12
 
15
- {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}{{equalsigns}} {{ package.name }} package
13
+ {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}
14
+
15
+ [[lutaml-section-{{ package_name }}]]
16
+ {{equalsigns}} {{ package.name }} package
17
+
16
18
  {{equalsigns}}= {{ package.name }} overview
17
19
 
20
+ {% assign before_package_key = 'before;' | append: package.name %}
21
+ {% if additional_context[before_package_key] and additional_context[before_package_key].size > 0 %}
22
+ {% for before in additional_context[before_package_key] %}
23
+ {{ before.text }}
24
+ {% endfor %}
25
+ {% endif %}
18
26
  {% if additional_context.diagram_include_block %}
19
- {% include "diagrams_block", package_name: package_name, image_base_path: additional_context.diagram_include_block.base_path, text: additional_context.diagram_include_block.text %}
27
+ {% for diagram_include_block in additional_context.diagram_include_block %}
28
+ {% include "diagrams_block", package_name: package_name, image_base_path: diagram_include_block.base_path, text: diagram_include_block.text, format: diagram_include_block.format %}
29
+ {% endfor %}
20
30
  {% endif %}
21
31
 
22
32
  {% if package.packages.size > 0 %}The {{ package.name }} package is organized into
23
33
  {{ package.packages.size }} packages{% assign modules_nested_size = 0 %}{% for module in package.packages %}{% assign modules_nested_size = modules_nested_size | plus: module.packages.size %}{% endfor %}{% if modules_nested_size > 0 %} with {{modules_nested_size}} modules{% endif %}:
24
34
  {% endif %}
25
- [arabic]
35
+
26
36
  {% for module in package.packages %}
27
37
  {% if module.packages.length > 0 %}
28
38
  . {{ module.name }} package comprises:
@@ -38,14 +48,14 @@
38
48
 
39
49
  {{equalsigns}}= Defining tables
40
50
 
41
- [arabic]
42
51
  {% for klass in package.classes %}
43
52
  {% assign is_klass_spare = klass.name | slice: 0,5 %}
44
53
  {% if is_klass_spare == 'old: ' %}{% continue %}
45
54
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
46
55
  {% endif %}
47
56
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
48
- .<<tab-P-{{ package_name }}-C-{{ klass_name }}>> -- Elements of {{ package.name }}::{{ klass.name }}
57
+ {% assign klass_xid = klass.xmi_id %}
58
+ .<<tab-P-{{ package_name }}-C-{{ klass_xid }}>> -- Elements of "{{ package.name }}::{{ klass.name }}"
49
59
 
50
60
  {% endfor %}
51
61
  {% for enum in package.enums %}
@@ -54,7 +64,8 @@
54
64
  {% elsif is_enum_spare == 'Spare' %}{% continue %}
55
65
  {% endif %}
56
66
  {% assign enum_name = enum.name | downcase | replace: ':', '' | replace: ' ', '_' %}
57
- .<<tab-P-{{ package_name }}-E-{{ enum_name }}>> -- Elements of {{ package.name }}::{{ enum.name }}
67
+ {% assign enum_xid = enum.xmi_id %}
68
+ .<<tab-P-{{ package_name }}-E-{{ enum_xid }}>> -- Elements of "{{ package.name }}::{{ enum.name }}"
58
69
 
59
70
  {% endfor %}
60
71
  {% for data_type in package.data_types %}
@@ -63,7 +74,8 @@
63
74
  {% elsif is_data_type_spare == 'Spare' %}{% continue %}
64
75
  {% endif %}
65
76
  {% assign data_type_name = data_type.name | downcase | replace: ':', '' | replace: ' ', '_' %}
66
- .<<tab-P-{{ package_name }}-DT-{{ data_type_name }}>> -- Elements of {{ package.name }}::{{ data_type.name }}
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 }}"
67
79
 
68
80
  {% endfor %}
69
81
 
@@ -81,9 +93,9 @@
81
93
 
82
94
  {% endif %}
83
95
 
84
- {% if additional_context.include_block %}
85
- {% assign block = additional_context.include_block %}
86
- {% capture block_filename %}{{ block.base_path }}/{{ package_name }}{% endcapture %}
96
+ {% if additional_context.include_block and additional_context.include_block.size > 0 %}
97
+ {% for block in additional_context.include_block %}
98
+ {% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
87
99
  {% capture block_content %}{% include block_filename %}{% endcapture %}
88
100
  {% unless block_content contains "Liquid error" %}
89
101
  {% if block.text %}
@@ -91,12 +103,13 @@
91
103
  {% endif %}
92
104
  {{ block_content }}
93
105
  {% endunless %}
106
+ {% endfor %}
94
107
  {% endif %}
95
108
 
96
109
  {% assign include_block_package_key = 'include_block;' | append: package.name %}
97
- {% assign block = additional_context[include_block_package_key] %}
98
- {% if block %}
99
- {% capture block_filename %}{{ block.base_path }}/{{ package_name }}{% endcapture %}
110
+ {% if additional_context[include_block_package_key] and additional_context[include_block_package_key].size > 0 %}
111
+ {% for block in additional_context[include_block_package_key] %}
112
+ {% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
100
113
  {% capture block_content %}{% include block_filename %}{% endcapture %}
101
114
  {% unless block_content contains "Liquid error" %}
102
115
  {% if block.text %}
@@ -104,16 +117,23 @@
104
117
  {% endif %}
105
118
  {{ block_content }}
106
119
  {% endunless %}
120
+ {% endfor %}
107
121
  {% endif %}
108
122
 
109
123
  {% assign after_package_key = 'after;' | append: package.name %}
110
- {{equalsigns}}= Additional Information
111
124
  {% if additional_context[after_package_key] %}
112
- {{ additional_context[after_package_key].text }}
125
+ {{equalsigns}}= Additional information
126
+ {% for after in additional_context[after_package_key] %}
127
+ {{ after.text }}
128
+ {% endfor %}
129
+ {% endif %}
130
+ {% if package.packages.size > 0 and render_nested_packages %}
131
+ {% assign nested_depth = depth | plus: 1 %}{% include "packages", depth: nested_depth, context: package %}
113
132
  {% 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
133
  {% endfor %}
116
134
 
117
- {% if additional_context.after %}
118
- {{ additional_context.after.text }}
135
+ {% if additional_context.after and additional_context.after.size > 0 %}
136
+ {% for after in additional_context.after %}
137
+ {{ after.text }}
138
+ {% endfor %}
119
139
  {% endif %}
@@ -3,8 +3,9 @@
3
3
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
4
4
  {% endif %}
5
5
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
6
- [[tab-P-{{ package_name }}-C-{{ klass_name }}]]
7
- .Elements of {{ package.name }}::{{ klass.name }}
6
+ {% assign klass_xid = klass.xmi_id %}
7
+ [[tab-P-{{ package_name }}-C-{{ klass_xid }}]]
8
+ .Elements of "{{ package.name }}::{{ klass.name }}" (class)
8
9
  [width="100%",cols="a,a,a,a,a,a,a,a"]
9
10
  |===
10
11
 
@@ -24,14 +25,14 @@ h|Inheritance from: 7+| {{ inherited | map: 'member_end' | join: ", " }}
24
25
  h|Generalization of: 7+| {{ generalizations | map: 'member_end' | join: ", " }}
25
26
  {% endif %}
26
27
 
27
- h|Abstract: 7+| {{ klass.is_abstract }}
28
+ h|Abstract: 7+| {% if klass.is_abstract %}True{% else %}False{% endif %}
28
29
  {% assign aggregations = klass.associations | where: "member_end_type", "aggregation" %}
29
30
  {% if aggregations.size > 0 %}
30
31
  .{{aggregations.size | plus: 1}}+h|Associations:
31
- 4+|_Association with:_
32
- |_Obligation_
32
+ 4+| _Association with_
33
+ | _Obligation_
33
34
  | _Maximum occurrence_
34
- |_Provides:_
35
+ | _Provides_
35
36
 
36
37
  {% for assoc in aggregations %}
37
38
  4+| {{assoc.member_end}}
@@ -41,9 +42,9 @@ h|Abstract: 7+| {{ klass.is_abstract }}
41
42
 
42
43
  {% endfor %}
43
44
  {% else %}
44
-
45
- .1+h|Associations: 7+| (none)
45
+ h| Associations: 7+| (none)
46
46
  {% endif %}
47
+
47
48
  {% if klass.attributes.size > 0 %}
48
49
  .{{klass.attributes.size | plus: 1}}+h|Public attributes:
49
50
  | _Name_
@@ -63,12 +64,12 @@ h|Abstract: 7+| {{ klass.is_abstract }}
63
64
 
64
65
  {% endfor %}
65
66
  {% else %}
66
- .1+h|Public attributes:
67
+ h| Public attributes:
67
68
  7+| (none)
68
69
  {% endif %}
69
70
 
70
71
  {% if klass.constraints.size > 0 %}
71
- .{{ klass.constraints.size }}+|*Constraints:*
72
+ .{{ klass.constraints.size }}+h| Constraints:
72
73
  {% for constr in klass.constraints %}
73
74
  7+| `{{ constr.body }}`
74
75
 
@@ -0,0 +1,181 @@
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"]
67
+ !===
68
+ !Definition: ! {{ data_type.definition }}
69
+ !Subclass of: ! {{ generalizations }}
70
+ !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
+ ! {{ 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
+ |
83
+ [cols="15,20,60",options="header"]
84
+ !===
85
+ ! Role name !Target class and multiplicity !Definition
86
+ {{ rendered_associations }}
87
+ !===
88
+ {% endif %}
89
+ {% endif %}
90
+ {% if data_type.attributes.size > 0 %}
91
+ |
92
+ [cols="15,20,60",options="header"]
93
+ !===
94
+ ! Attribute ! Value type and multiplicity ! Definition
95
+ {% for attr in data_type.attributes %}
96
+ {% 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 }}
98
+ {% endfor %}
99
+ !===
100
+ | NOTE: Unless otherwise specified, all attributes and role names have the stereotype «Property».
101
+ {% endif %}
102
+ |===
103
+
104
+ {% endfor %}
105
+ {% endif %}
106
+
107
+ {% if package.enums.size > 0 %}
108
+ {{equalsigns}}= Enumerations
109
+
110
+ {% for enum in package.enums %}
111
+ {% capture generalizations %}{% for assoc in enum.associations | where: "member_end_type", "generalization" %}{{ assoc.member_end }} {% endfor %}{% endcapture %}
112
+ [[{{ enum.name }}-section]]
113
+ [cols="1a"]
114
+ |===
115
+ |*{{ enum.name }}*
116
+ |
117
+ [cols="1,4"]
118
+ !===
119
+ !Definition: ! {{ enum.definition }}
120
+ !Stereotype: ! «Enumeration»
121
+ !===
122
+ {% if enum.values.size > 0 %}
123
+ |
124
+ [cols="1,4",options="header"]
125
+ !===
126
+ ! Literal value !Definition
127
+
128
+ {% for val in enum.values %}
129
+ ! {{ val.name }} !{{ val.definition }}
130
+ {% endfor %}
131
+ !===
132
+ {% endif %}
133
+ |===
134
+
135
+ {% endfor %}
136
+ {% endif %}
137
+
138
+ {% if additional_context.include_block and additional_context.include_block.size > 0 %}
139
+ {% for block in additional_context.include_block %}
140
+ {% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
141
+ {% capture block_content %}{% include block_filename %}{% endcapture %}
142
+ {% unless block_content contains "Liquid error" %}
143
+ {% if block.text %}
144
+ {{ block.text }}
145
+ {% endif %}
146
+ {{ block_content }}
147
+ {% endunless %}
148
+ {% endfor %}
149
+ {% endif %}
150
+
151
+ {% assign include_block_package_key = 'include_block;' | append: package.name %}
152
+ {% if additional_context[include_block_package_key] and additional_context[include_block_package_key].size > 0 %}
153
+ {% for block in additional_context[include_block_package_key] %}
154
+ {% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
155
+ {% capture block_content %}{% include block_filename %}{% endcapture %}
156
+ {% unless block_content contains "Liquid error" %}
157
+ {% if block.text %}
158
+ {{ block.text }}
159
+ {% endif %}
160
+ {{ block_content }}
161
+ {% endunless %}
162
+ {% endfor %}
163
+ {% endif %}
164
+
165
+ {% assign after_package_key = 'after;' | append: package.name %}
166
+ {% if additional_context[after_package_key] %}
167
+ {{equalsigns}}= Additional information
168
+ {% for after in additional_context[after_package_key] %}
169
+ {{ after.text }}
170
+ {% endfor %}
171
+ {% endif %}
172
+ {% if package.packages.size > 0 and render_nested_packages %}
173
+ {% assign nested_depth = depth | plus: 1 %}{% include "packages_data_dictionary", depth: nested_depth, context: package %}
174
+ {% endif %}
175
+ {% endfor %}
176
+
177
+ {% if additional_context.after and additional_context.after.size > 0 %}
178
+ {% for after in additional_context.after %}
179
+ {{ after.text }}
180
+ {% endfor %}
181
+ {% endif %}
@@ -0,0 +1,65 @@
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
+
65
+ {% endfor %}
@@ -3,8 +3,9 @@
3
3
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
4
4
  {% endif %}
5
5
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
6
- [[tab-P-{{ package_name }}-DT-{{ klass_name }}]]
7
- .Elements of {{ package.name }}::{{ klass.name }}
6
+ {% assign klass_xid = klass.xmi_id %}
7
+ [[tab-P-{{ package_name }}-DT-{{ klass_xid }}]]
8
+ .Elements of "{{ package.name }}::{{ klass.name }}" (data type)
8
9
  [width="100%",cols="a,a,a,a,a,a,a,a"]
9
10
  |===
10
11
 
@@ -24,14 +25,14 @@ h|Inheritance from: 7+| {{ inherited | map: 'member_end' | join: ", " }}
24
25
  h|Generalization of: 7+| {{ generalizations | map: 'member_end' | join: ", " }}
25
26
  {% endif %}
26
27
 
27
- h|Abstract: 7+| {{ klass.is_abstract }}
28
+ h|Abstract: 7+| {% if klass.is_abstract %}True{% else %}False{% endif %}
28
29
  {% assign aggregations = klass.associations | where: "member_end_type", "aggregation" %}
29
30
  {% if aggregations.size > 0 %}
30
31
  .{{aggregations.size | plus: 1}}+h|Associations:
31
- 4+|_Association with:_
32
- |_Obligation_
32
+ 4+| _Association with_
33
+ | _Obligation_
33
34
  | _Maximum occurrence_
34
- |_Provides:_
35
+ | _Provides_
35
36
 
36
37
  {% for assoc in aggregations %}
37
38
  4+| {{assoc.member_end}}
@@ -41,12 +42,11 @@ h|Abstract: 7+| {{ klass.is_abstract }}
41
42
 
42
43
  {% endfor %}
43
44
  {% else %}
44
-
45
- .1+h|Associations: 7+| (none)
45
+ h| Associations: 7+| (none)
46
46
  {% endif %}
47
47
 
48
48
  {% if klass.attributes.size > 0 %}
49
- .{{klass.attributes.size | plus: 1}}+h|Values:
49
+ .{{klass.attributes.size | plus: 1}}+h| Values:
50
50
  | _Name_
51
51
  6+| _Definition_
52
52
 
@@ -56,7 +56,7 @@ h|Abstract: 7+| {{ klass.is_abstract }}
56
56
 
57
57
  {% endfor %}
58
58
  {% else %}
59
- .1+h|Values:
59
+ h| Values:
60
60
  7+| (none)
61
61
  {% endif %}
62
62
 
@@ -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
+
10
+ [[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 %}
23
+ {% endif %}
24
+
25
+ {% if additional_context.include_block and additional_context.include_block.size > 0 %}
26
+ {% for block in additional_context.include_block %}
27
+ {% capture block_filename %}{{ block.base_path }}{{ package_name }}{% endcapture %}
28
+ {% capture block_content %}{% include block_filename %}{% endcapture %}
29
+ {% unless block_content contains "Liquid error" %}
30
+ {% if block.text %}
31
+ {{ block.text }}
32
+ {% endif %}
33
+ {{ block_content }}
34
+ {% endunless %}
35
+ {% endfor %}
36
+ {% endif %}
37
+
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
+ {{ block.text }}
46
+ {% endif %}
47
+ {{ block_content }}
48
+ {% endunless %}
49
+ {% endfor %}
50
+ {% endif %}
51
+
52
+ {{equalsigns}}= Class definitions
53
+ {% if package.classes.size > 0 %}
54
+ .Classes used in {{ package.name }}
55
+ [cols="2a,6a",options="header"]
56
+ |===
57
+ |Class |Description
58
+
59
+ {% for klass in package.classes %}
60
+ |<<{{ klass.name }}-section,{{ klass.name }}>> «{{ 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 }}>> «{{ klass.stereotype }}»
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 }}>> «{{ klass.stereotype }}»
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 %}
@@ -3,8 +3,9 @@
3
3
  {% elsif is_klass_spare == 'Spare' %}{% continue %}
4
4
  {% endif %}
5
5
  {% assign klass_name = klass.name | downcase | replace: ':', '' | replace: ' ', '_' %}
6
- [[tab-P-{{ package_name }}-E-{{ klass_name }}]]
7
- .Elements of {{ package.name }}::{{ klass.name }}
6
+ {% assign klass_xid = klass.xmi_id %}
7
+ [[tab-P-{{ package_name }}-E-{{ klass_xid }}]]
8
+ .Elements of "{{ package.name }}::{{ klass.name }}" (enumeration)
8
9
  [width="100%",cols="a,a,a,a,a,a,a,a"]
9
10
  |===
10
11
 
@@ -24,14 +25,14 @@ h|Inheritance from: 7+| {{ inherited | map: 'member_end' | join: ", " }}
24
25
  h|Generalization of: 7+| {{ generalizations | map: 'member_end' | join: ", " }}
25
26
  {% endif %}
26
27
 
27
- h|Abstract: 7+| {{ klass.is_abstract }}
28
+ h|Abstract: 7+| {% if klass.is_abstract %}True{% else %}False{% endif %}
28
29
  {% assign aggregations = klass.associations | where: "member_end_type", "aggregation" %}
29
30
  {% if aggregations.size > 0 %}
30
31
  .{{aggregations.size | plus: 1}}+h|Associations:
31
- 4+|_Association with:_
32
- |_Obligation_
32
+ 4+| _Association with_
33
+ | _Obligation_
33
34
  | _Maximum occurrence_
34
- |_Provides:_
35
+ | _Provides_
35
36
 
36
37
  {% for assoc in aggregations %}
37
38
  4+| {{assoc.member_end}}
@@ -41,11 +42,11 @@ h|Abstract: 7+| {{ klass.is_abstract }}
41
42
 
42
43
  {% endfor %}
43
44
  {% else %}
44
-
45
- .1+h|Associations: 7+| (none)
45
+ h| Associations: 7+| (none)
46
46
  {% endif %}
47
+
47
48
  {% if klass.values.size > 0 %}
48
- .{{klass.values.size | plus: 1}}+h|Values:
49
+ .{{klass.values.size | plus: 1}}+h| Values:
49
50
  | _Name_
50
51
  6+| _Definition_
51
52
 
@@ -55,7 +56,7 @@ h|Abstract: 7+| {{ klass.is_abstract }}
55
56
 
56
57
  {% endfor %}
57
58
  {% else %}
58
- .1+h|Values:
59
+ h| Values:
59
60
  7+| (none)
60
61
  {% endif %}
61
62
 
@@ -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
@@ -52,7 +52,7 @@ module Metanorma
52
52
 
53
53
  def process_text_blocks(document, input_lines, express_indexes)
54
54
  line = input_lines.next
55
- block_match = line.match(/^\[lutaml,([^,]+)?,?([^,]+)?,?([^,]+)?\]/)
55
+ block_match = line.match(/^\[lutaml_express,([^,]+)?,?([^,]+)?,?([^,]+)?\]/)
56
56
  return [line] if block_match.nil?
57
57
 
58
58
  end_mark = input_lines.next
@@ -14,7 +14,7 @@ module Metanorma
14
14
  # @example [lutaml_uml_attributes_table,path/to/lutaml,EntityName]
15
15
  class LutamlUmlAttributesTablePreprocessor < Asciidoctor::Extensions::Preprocessor
16
16
  MARCO_REGEXP =
17
- /\[lutaml_uml_attributes_table,([^,]+),?(.+)?,([^,]+),?(.+)?\]/
17
+ /\[lutaml_uml_attributes_table,([^,]+),?([^,]+),?(.+?)?\]/
18
18
  # search document for block `datamodel_attributes_table`
19
19
  # read include derectives that goes after that in block and transform
20
20
  # into yaml2text blocks
@@ -36,15 +36,16 @@ module Metanorma
36
36
  input_lines.each_with_object([]) do |line, result|
37
37
  if match = line.match(MARCO_REGEXP)
38
38
  lutaml_path = match[1]
39
- entity_name = match[3]
40
- result.push(*parse_marco(lutaml_path, entity_name, document))
39
+ entity_name = match[2]
40
+ skip_headers = match[3]
41
+ result.push(*parse_marco(lutaml_path, entity_name, document, skip_headers))
41
42
  else
42
43
  result.push(line)
43
44
  end
44
45
  end
45
46
  end
46
47
 
47
- def parse_marco(lutaml_path, entity_name, document)
48
+ def parse_marco(lutaml_path, entity_name, document, skip_headers)
48
49
  lutaml_document = lutaml_document_from_file(document, lutaml_path)
49
50
  .serialized_document
50
51
  entities = [lutaml_document["classes"], lutaml_document["enums"]]
@@ -53,12 +54,12 @@ module Metanorma
53
54
  entity_definition = entities.detect do |klass|
54
55
  klass["name"] == entity_name.strip
55
56
  end
56
- model_representation(entity_definition, document)
57
+ model_representation(entity_definition, document, skip_headers)
57
58
  end
58
59
 
59
- def model_representation(entity_definition, document)
60
+ def model_representation(entity_definition, document, skip_headers)
60
61
  render_result, errors = Utils.render_liquid_string(
61
- template_string: table_template,
62
+ template_string: table_template(skip_headers),
62
63
  context_items: entity_definition,
63
64
  context_name: "definition",
64
65
  document: document
@@ -68,9 +69,9 @@ module Metanorma
68
69
  end
69
70
 
70
71
  # rubocop:disable Layout/IndentHeredoc
71
- def table_template
72
+ def table_template(skip_headers)
72
73
  <<~TEMPLATE
73
- === {{ definition.name }}
74
+ #{"=== {{ definition.name }}" unless skip_headers}
74
75
  {{ definition.definition }}
75
76
 
76
77
  {% if definition.attributes %}
@@ -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
- lutaml_document_from_file(document, block_match[1]),
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
- additional_context[macro_keyword] = { 'text' => block.lines[1..-2].join("\n") }.merge(attrs)
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
- if options.length.zero?
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" => lutaml_document.to_liquid['packages'].first['packages'].first['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 "packages", depth: 2, context: context, additional_context: context.additional_context, render_nested_packages: context.render_nested_packages %}
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
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.4.4".freeze
4
+ VERSION = "0.4.8".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -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
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
4
+ version: 0.4.8
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-05 00:00:00.000000000 Z
11
+ date: 2021-08-24 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
@@ -292,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
296
  - !ruby/object:Gem::Version
293
297
  version: '0'
294
298
  requirements: []
295
- rubygems_version: 3.1.6
299
+ rubygems_version: 3.0.3
296
300
  signing_key:
297
301
  specification_version: 4
298
302
  summary: Metanorma plugin for LutaML