metanorma-plugin-lutaml 0.7.30 → 0.7.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -8
  3. data/README.adoc +16 -1030
  4. data/docs/usages/enterprise_architect.adoc +583 -0
  5. data/docs/usages/express.adoc +299 -0
  6. data/docs/usages/json_yaml.adoc +1034 -0
  7. data/docs/usages/lutaml-gml.adoc +73 -0
  8. data/docs/usages/lutaml-uml.adoc +73 -0
  9. data/lib/metanorma/plugin/lutaml/asciidoctor/preprocessor.rb +1 -1
  10. data/lib/metanorma/plugin/lutaml/base_structured_text_preprocessor.rb +192 -0
  11. data/lib/metanorma/plugin/lutaml/content.rb +89 -0
  12. data/lib/metanorma/plugin/lutaml/data2_text_preprocessor.rb +45 -0
  13. data/lib/metanorma/plugin/lutaml/express_remarks_decorator.rb +19 -6
  14. data/lib/metanorma/plugin/lutaml/json2_text_preprocessor.rb +43 -0
  15. data/lib/metanorma/plugin/lutaml/liquid/custom_blocks/key_iterator.rb +31 -0
  16. data/lib/metanorma/plugin/lutaml/liquid/custom_filters/loadfile.rb +18 -0
  17. data/lib/metanorma/plugin/lutaml/liquid/custom_filters/replace_regex.rb +14 -0
  18. data/lib/metanorma/plugin/lutaml/liquid/custom_filters/values.rb +13 -0
  19. data/lib/metanorma/plugin/lutaml/liquid/multiply_local_file_system.rb +29 -22
  20. data/lib/metanorma/plugin/lutaml/liquid_drops/gml_dictionary_drop.rb +1 -1
  21. data/lib/metanorma/plugin/lutaml/lutaml_diagram_base.rb +1 -1
  22. data/lib/metanorma/plugin/lutaml/lutaml_diagram_block_macro.rb +2 -1
  23. data/lib/metanorma/plugin/lutaml/lutaml_ea_diagram_block_macro.rb +2 -1
  24. data/lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb +48 -36
  25. data/lib/metanorma/plugin/lutaml/lutaml_figure_inline_macro.rb +2 -1
  26. data/lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_block_macro.rb +3 -1
  27. data/lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb +2 -1
  28. data/lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb +15 -2
  29. data/lib/metanorma/plugin/lutaml/lutaml_table_inline_macro.rb +2 -1
  30. data/lib/metanorma/plugin/lutaml/source_extractor.rb +97 -0
  31. data/lib/metanorma/plugin/lutaml/utils.rb +59 -26
  32. data/lib/metanorma/plugin/lutaml/version.rb +1 -1
  33. data/lib/metanorma/plugin/lutaml/yaml2_text_preprocessor.rb +41 -0
  34. data/lib/metanorma-plugin-lutaml.rb +3 -0
  35. data/metanorma-plugin-lutaml.gemspec +7 -1
  36. metadata +35 -6
  37. data/lib/metanorma/plugin/lutaml/liquid_templates/test.rb +0 -1
  38. /data/lib/metanorma/plugin/lutaml/liquid/{custom_filters.rb → custom_filters/html2adoc.rb} +0 -0
data/README.adoc CHANGED
@@ -9,10 +9,11 @@ LutaML is a data model accessor that supports various data model formats.
9
9
  This plugin allows you to access the following types of information models from
10
10
  within a Metanorma document:
11
11
 
12
- * EXPRESS (`*.exp` files)
13
- * LutaML-UML (`*.lutaml` files)
14
- * Enterprise Architect exported UML in XMI format (`*.xmi` files)
15
-
12
+ * EXPRESS files (`*.exp`)
13
+ * LutaML-UML files (`*.lutaml`)
14
+ * Enterprise Architect exported UML files in XMI format (`*.xmi`)
15
+ * LutaML GML Dictionary files (`*.xml`)
16
+ * JSON or YAML files (`*.json|*.yml|*.yaml`)
16
17
 
17
18
  == Installation
18
19
 
@@ -21,1039 +22,24 @@ within a Metanorma document:
21
22
  $ gem install metanorma-plugin-lutaml
22
23
  ----
23
24
 
25
+ == Usages
24
26
 
25
- == Usage with EXPRESS
26
-
27
- === General
28
-
29
- The LutaML plugin supports working with EXPRESS schema files to render EXPRESS
30
- models and definitions.
31
-
32
- LutaML supports accessing EXPRESS models via the
33
- https://github.com/lutaml/expressir[Expressir] parser.
34
-
35
-
36
- === Document attribute `:lutaml-express-index:`
37
-
38
- This attribute allows specifying one or more EXPRESS files to defined names
39
- for later use with `lutaml_express` command.
40
-
41
- Syntax:
42
-
43
- [source,adoc]
44
- ----
45
- :lutaml-express-index: shortname_of_index; name_of_schemas_listing_file.yml;
46
- ----
47
-
48
- Where:
49
-
50
- `shortname_of_index`:: is name of the parsed EXPRESS files context for the later
51
- use.
52
-
53
- `name_of_schemas_listing_file.yml`:: location of the YAML index file to parse
54
- all EXPRESS files listed within.
55
-
56
-
57
- [example]
58
- .Define an index in the document and use it in the `lutaml_express` command
59
- ====
60
- [source,adoc]
61
- -----
62
- :lutaml-express-index: my_custom_name; /path/to/schemas.yml
63
-
64
- [lutaml_express,my_custom_name,context]
65
- ----
66
- {% for schema in context.schemas %}
67
- == {{schema.id}}
68
-
69
- {% for entity in schema.entities %}
70
- === {{entity.id}}
71
- {% endfor %}
72
-
73
- {% endfor %}
74
- -----
75
-
76
- Where the `schemas.yml` file contains:
77
-
78
- [source,yaml]
79
- ----
80
- ---
81
- schemas:
82
- action_schema:
83
- path: "../../schemas/resources/action_schema/action_schema.exp"
84
- application_context_schema:
85
- path: "../../schemas/resources/application_context_schema/application_context_schema.exp"
86
- ----
87
- ====
88
-
89
-
90
- === Schemas listing file
91
-
92
- The schemas listing file is a YAML file that lists all EXPRESS files to be
93
- parsed. The file should have the following structure:
94
-
95
- [source,yaml]
96
- ----
97
- ---
98
- schemas:
99
- schema_name:
100
- path: path/to/schema_file.exp
101
- schema_name_2:
102
- path: path/to/schema_file_2.exp
103
- ----
104
-
105
- Where:
106
-
107
- `schema_name`:: is the name of the EXPRESS schema.
108
-
109
- `path`:: (optional) path to the EXPRESS schema file. When the path is not
110
- specified, the command will look for the schema file in the directory where the
111
- YAML file is located using the filename pattern `{schema_name}.exp`. The path
112
- can be relative to the YAML file or an absolute path.
113
-
114
-
115
- === Usage of the `lutaml_express` command
116
-
117
- Given an `example.exp` EXPRESS file with content:
118
-
119
- [source,exp]
120
- ----
121
- SCHEMA test_schema 'test';
122
-
123
- (* Need select elements for measure_value *)
124
- REFERENCE FROM measure_schema
125
- (measure_value);
126
-
127
- TYPE my_type1 = EXTENSIBLE SELECT;
128
- END_TYPE;
129
-
130
- TYPE my_type2 = EXTENSIBLE ENUMERATION;
131
- END_TYPE;
132
-
133
- TYPE my_type3 = EXTENSIBLE ENUMERATION;
134
- END_TYPE;
135
-
136
- TYPE my_type4 = EXTENSIBLE ENUMERATION;
137
- END_TYPE;
27
+ link:docs/usages/express.adoc[Usage with EXPRESS]
138
28
 
139
- TYPE my_type5 = EXTENSIBLE ENUMERATION;
140
- END_TYPE;
141
- END_SCHEMA;
142
- ----
143
-
144
- And the `lutaml_express` block:
145
-
146
- [source,adoc]
147
- -----
148
- [lutaml_express_liquid,example.exp,my_context]
149
- ----
150
- {% for schema in my_context.schemas %}
151
- == {{schema.id}}
152
-
153
- {% for entity in schema.entities %}
154
- === {{entity.id}}
155
- {% endfor %}
156
-
157
- {% endfor %}
158
- ----
159
- -----
160
-
161
- NOTE: The `lutaml` command can auto-detect the EXPRESS schema file type by the
162
- file extension. If the file extension is `.exp`, the command will use the
163
- `Expressir` parser to parse the file. If the file extension is `.lutaml`, the
164
- command will use the `Lutaml` parser to parse the file.
165
-
166
- Where:
167
-
168
- * content within the block is called the "`template`";
169
-
170
- * `{example.exp}` is the location of the EXPRESS schema file (`*.exp`) that
171
- contains data to be loaded. Location of the file is computed relative to the
172
- source directory that `[lutaml_express_liquid]` is used (e.g., if
173
- `[lutaml_express_liquid,example.exp,my_context]` is invoked in an `.adoc` file
174
- located at `/foo/bar/doc.adoc`, the data file is expected to be found at
175
- `/foo/bar/example.exp`);
176
-
177
- * `{my_context}` is the name where the EXPRESS Repository read from the `.exp`
178
- file can be accessed with.
179
-
180
- ** The `context` object is a serialized `Expressir::Model::Repository` object
181
- with all variable names available. See
182
- https://github.com/lutaml/expressir[Expressir] docs for reference.
183
- `{my_context}` has `schemas` method to access Expressir
184
- https://github.com/lutaml/expressir/blob/master/lib/expressir/model/schema.rb[schemas]
185
-
186
- Will produce this output:
187
-
188
- ____
189
- == test_schema
190
-
191
- === my_type1
192
- === my_type2
193
- === my_type3
194
- === my_type4
195
- === my_type5
196
- ____
197
-
198
-
199
- Instead of using the direct path to the file one can use `:lutaml-express-index:`
200
- document attribute to supply directory with express files or YAML index file to
201
- parse as well as the cache file location.
202
-
203
- Syntax:
204
-
205
- [source,adoc]
206
- ----
207
- :lutaml-express-index: my_custom_name; dir_or_index_path[; cache=cache_path]
208
- ----
209
-
210
- Where:
211
-
212
- `my_custom_name`:: is name of the parsed EXPRESS files context for the later
213
- use with lutaml command
214
-
215
- `dir_or_index_path`:: location of directory with EXPRESS files or path to the
216
- YAML index file to parse
217
-
218
- `cache_path`:: (optional) location of the Expressir cache file to use
219
-
220
- Example of usage:
221
-
222
- [source,adoc]
223
- -----
224
- = Document title
225
- Author
226
- :lutaml-express-index: index_name; /path/to/express_files; cache=/path/to/cache_file.yaml
227
-
228
- [lutaml_express_liquid,index_name,context]
229
- ----
230
- {% for schema in context.schemas %}
231
- == {{schema.id}}
232
- {% endfor %}
233
- ----
234
- -----
235
-
236
- * The `lutaml_express_liquid` macro processes the EXPRESS files specified by
237
- the `index_name` and makes them available in the `context` as
238
- Liquid Drops object.
239
-
240
- * The Liquid template inside the macro block iterates over the `schemas` in
241
- the `context` and renders the attributes of each schema such as `id`.
242
-
243
- === Using `config_yaml`
244
-
245
- This functionality allows `[lutaml_express_liquid]` blocks to load a full set of
246
- EXPRESS schemas in one index, and then provide a select ("filter") option
247
- per-block via a separate YAML file.
248
-
249
- [source,adoc]
250
- -----
251
- :lutaml-express-index: all_schemas; ../schemas_all.yaml;
252
-
253
- [lutaml_express_liquid,all_schemas,context,config_yaml=schemas.yaml]
254
- ---
255
- {% assign all_schemas = repo.schemas %}
256
- {% render "templates/resources/schema" for ordered_schemas as schema %}
257
- ----
258
- -----
259
-
260
- Where `schemas_all.yml` provides all schemas:
261
-
262
- [source,yaml]
263
- ----
264
- ---
265
- schemas:
266
- action_schema:
267
- path: "../../schemas/resources/action_schema/action_schema.exp"
268
- application_context_schema:
269
- path: "../../schemas/resources/application_context_schema/application_context_schema.exp"
270
- approval_schema:
271
- path: "../../schemas/resources/approval_schema/approval_schema.exp"
272
- ...
273
- ----
29
+ link:docs/usages/lutaml-uml.adoc[Usage with LutaML-UML]
274
30
 
275
- And `schemas.yaml` only selects 2 schemas:
276
-
277
- [source,yaml]
278
- ----
279
- ---
280
- schemas:
281
- action_schema:
282
- anything: ...
283
- application_context_schema:
284
- anything: ...
285
- ----
286
-
287
- The resulting block adds the `ordered_schemas` context to allows you to filter
288
- out the schemas you want to render according to the order in the config_yaml.
289
-
290
- [source,liquid]
291
- ----
292
- [lutaml_express_liquid,schemas_1,repo,config_yaml=select.yaml]
293
- ---
294
- {% assign all_schemas = repo.schemas %}
295
- {% render "templates/resources/schema" for ordered_schemas as schema %}
296
- ...
297
- ---
298
- ----
299
-
300
- NOTE: This functionality is used in the ISO 10303 SRL to load the full schema
301
- set at once but only render the selected schemas in individual documents.
302
-
303
- === Using `include_path`
304
-
305
- This functionality allows `[lutaml_express_liquid]` blocks to load templates
306
- from the paths other than the location of the document.
307
-
308
- [source,adoc]
309
- -----
310
- :lutaml-express-index: all_schemas; ../schemas_all.yaml;
311
-
312
- [lutaml_express_liquid,all_schemas,context,config_yaml=schemas.yaml,include_path=../templates]
313
- ---
314
- {% assign all_schemas = repo.schemas %}
315
- {% render "templates/resources/schema" for ordered_schemas as schema %}
316
- ...
317
- ----
318
- -----
319
-
320
- The resulting block adds the `include_path` to the Liquid renderer. The path is
321
- resolved based on the location of the document. You can add multiple paths by
322
- separating them with commas.
323
-
324
- == Usage with Lutaml-UML
325
-
326
- === General
327
-
328
- The LutaML plugin supports working with LutaML UML files to render UML diagrams
329
- and class definitions.
330
-
331
-
332
- === Rendering a LutaML view: `lutaml_diagram`
333
-
334
- This command allows to quickly render a LutaML view as an image file.
335
-
336
- Given a file `example.lutaml` file with content:
337
-
338
- [source,java]
339
- ----
340
- diagram MyView {
341
- title "my diagram"
342
-
343
- enum AddressClassProfile {
344
- imlicistAttributeProfile: CharacterString [0..1] {
345
- definition
346
- this is multiline with `asciidoc`
347
- end definition
348
- }
349
- }
350
-
351
- class AttributeProfile {
352
- +addressClassProfile: CharacterString [0..1]
353
- imlicistAttributeProfile: CharacterString [0..1] {
354
- definition this is attribute definition
355
- }
356
- }
357
- }
358
- ----
359
-
360
- The `lutaml_diagram` command will add the image to the document.
361
-
362
- [source,adoc]
363
- ----
364
- lutaml_diagram::example.lutaml[]
365
- ----
366
-
367
- The `lutaml_diagram` command can also be used to denote a block with an embedded
368
- LutaML view.
369
-
370
- For example:
371
-
372
- [source,java]
373
- ----
374
- [lutaml_diagram]
375
- ....
376
- diagram MyView {
377
- title "my diagram"
378
-
379
- enum AddressClassProfile {
380
- imlicistAttributeProfile: CharacterString [0..1] {
381
- definition {
382
- This is multiline AsciiDoc content.
383
- }
384
- }
385
- }
386
-
387
- class AttributeProfile {
388
- +addressClassProfile: CharacterString [0..1]
389
- imlicistAttributeProfile: CharacterString [0..1] {
390
- definition this is attribute definition
391
- }
392
- }
393
- }
394
- ....
395
- ----
396
-
397
- == Usage with Enterprise Architect (UML in XMI)
398
-
399
- === General
400
-
401
- The LutaML plugin supports working with Enterprise Architect exported XMI files
402
- to render UML diagrams and class definitions.
403
-
404
- The commands are prefixed as `lutaml_ea_*` to denote their specific use with
405
- Enterprise Architect XMI files.
406
-
407
-
408
- === Document attribute `:lutaml-xmi-index:`
409
-
410
- This attribute allows specifying one or more XMI files to defined names
411
- for later use with `lutaml_ea_*` commands.
412
-
413
- Syntax:
414
-
415
- [source,adoc]
416
- ----
417
- :lutaml-xmi-index: index_name; index_path[; config=config_path]
418
- ----
419
-
420
- where:
421
-
422
- `index_name`:: name of index
423
- `index_path`:: path to XMI file for the later use with `lutaml_ea_*` command
424
- `config_path`:: optional, location of YAML configuration file that specifies
425
- what packages to include in the render, what render style is desired and
426
- location of the root package.
427
-
428
-
429
- [example]
430
- .Define two indexes in the document and use them in the `lutaml_ea_xmi` command
431
- ====
432
- [source,adoc]
433
- ----
434
- :lutaml-xmi-index: first-xmi-index; /path/to/first.xmi
435
- :lutaml-xmi-index: second-xmi-index; /path/to/second.xmi; config=/path/to/config.yml
436
-
437
- [lutaml_ea_xmi,index=first-xmi-index]
438
- --
439
- ...
440
- --
441
-
442
- lutaml_ea_diagram::[name="NameOfDiagramInSecondXmiIndex",base_path="./xmi-images",format="png",index="second-xmi-index"]
443
- ...
444
- ----
445
-
446
- The command `lutaml_ea_xmi` will load the XMI file from the path
447
- `/path/to/first.xmi` which is specified by the `index`: `first-xmi-index`.
448
-
449
- The command `lutaml_ea_diagram` will load the XMI file from the path
450
- `/path/to/second.xmi` which is specified by the `index`: `second-xmi-index`.
451
- ====
452
-
453
-
454
- === Rendering a Enterprise Architect diagram from XMI: `lutaml_ea_diagram`
455
-
456
- This command allows to quickly render a LutaML diagram as an image file by
457
- specifying the name of diagram.
458
-
459
- Syntax:
460
-
461
- [source,adoc]
462
- ----
463
- lutaml_ea_diagram::[{options}]
464
- ----
465
-
466
- where `{options}` is a hash of options, where:
467
-
468
- `name`:: (mandatory) name of the diagram to render.
469
- `base_path`:: (mandatory) base path where the diagram images are located.
470
- `format`:: (optional) format of the image file. Defaults to `png`.
471
- `index`:: (optional) index name of the XMI file. If the index is not provided,
472
- the command will look for the diagram in the first XMI file specified through
473
- the `lutaml_ea_xmi` command.
474
- `package`:: (optional) name of the package which contains the diagram. If the
475
- package is not provided, the command will look for the diagram across all
476
- packages in the XMI file.
477
-
478
- The diagram with name `name_of_diagram` will be converted into the following
479
- Metanorma block:
480
-
481
- [source,adoc]
482
- ----
483
- [[figure-{{ diagram.xmi_id }}]]
484
- .{{ diagram.name }}
485
- image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[]
486
- ----
487
-
488
- [example]
489
- .Specifying a diagram within an XMI file
490
- ====
491
- [source,adoc]
492
- ----
493
- lutaml_ea_diagram::[name="name_of_diagram",base_path="/path/to/xmi-images",format="png"]
494
- ----
495
-
496
- Renders the diagram with name `name_of_diagram` from the XMI file in PNG format,
497
- where the EA images exported with the XMI file are at `/path/to/xmi-images`.
498
- ====
499
-
500
- [example]
501
- .Specifying a diagram within a specific package (if there are multiple diagrams with the same name)
502
- ====
503
- [source,adoc]
504
- ----
505
- lutaml_ea_diagram::[name="DiagramName",package="PackageA",base_path="/path/to/xmi-images"]
506
- ----
507
-
508
- The search wil be restricted to the diagrams named `DiagramName` in the
509
- `PackageA` package.
510
- ====
511
-
512
- [example]
513
- .Specifying a diagram using a specific index
514
- ====
515
- [source,adoc]
516
- ----
517
- :lutaml-xmi-index: index_name; /path/to/xmi-file.xmi
518
-
519
- ...
520
-
521
- lutaml_ea_diagram::[name="name_of_diagram",base_path="/path/to/xmi-images",format="png",index="index_name"]
522
- ----
31
+ link:docs/usages/enterprise_architect.adoc[Usage with Enterprise Architect (UML in XMI)]
523
32
 
524
- Renders the diagram with name `name_of_diagram` from the XMI file in PNG format,
525
- where the EA images exported with the XMI file are at `/path/to/xmi-images` and
526
- the XMI file defined in the index `index_name`.
527
- ====
33
+ link:docs/usages/lutaml-gml.adoc[Usage with LutaML GML Dictionary]
528
34
 
35
+ link:docs/usages/json_yaml.adoc[Usage with JSON or YAML files]
529
36
 
37
+ == Documentation
530
38
 
531
- === Generating a class definition table for a class: `lutaml_klass_table`
532
-
533
- This command allows to render a LutaML table of a class by using Liquid Drop.
534
-
535
- The table will show:
536
-
537
- * Class Name
538
- * Class Definition
539
- * Inherited Properties
540
- * Self-defined Properties
541
- * Properties Inherited from Association
542
- * Properties Defined in Association
543
-
544
- [source,adoc]
545
- ----
546
- lutaml_klass_table::/path/to/example.xmi[name="NameOfClass",template="/path/to/templates/_my_klass_table.liquid"]
547
- ----
548
-
549
- The command accepts the options listed below:
550
-
551
- * `/path/to/example.xmi` specifies the path of xmi file.
552
-
553
- * `name` option only, `name` option with `package` option or `path` option.
554
- One of 3 forms of options can be used to specify the name of the class.
555
-
556
- ** `name="NameOfClass"` specifies the name of the `class`.
557
- (e.g. `name="Building"`)
558
- If there are multiple classes with the same name, other form of options
559
- are recommended to specify the class.
560
-
561
- ** `package="NameOfPackage"name="NameOfClass"` specifies the name of the
562
- `class` (specified by `name` option) inside the `package`
563
- (specified by `package` option).
564
- The `package` option must be used with the `name` option.
565
- (e.g. `package="uro",name="_BoundarySurface"`)
566
-
567
- ** `path="PathOfClass"` specifies the `absolute` path of the `class`
568
- which is started with `::`
569
- (e.g. `path="::EA_Model::Conceptual Models::i-UR::Urban Planning ADE 3.
570
- 1::uro::_BoundarySurface"`)
571
- or `relative` path of the `class` which is not started with `::`
572
- (e.g. `path="uro::_BoundarySurface"`).
573
- The last part of the path separated by `::` is the name of the `class`.
574
- The other parts of the path are the names of the `packages`.
575
-
576
- * `template="/path/to/templates/_my_klass_table.liquid"` specifies the path of
577
- the liquid template. (Optional)
578
- By default, it will look for the template `_klass_table.liquid` defined in
579
- `lib/metanorma/plugin/lutaml/templates`. This template can be customized by
580
- changing the template path in the `template` option.
581
-
582
- * `guidance="/path/to/my_guidance.yml"` specifies the path of
583
- the yaml file of the guidance. (Optional)
584
-
585
- The guidance file should be in the following format:
586
-
587
- [source,yaml]
588
- ----
589
- ---
590
- classes:
591
- - name: Name Of Class
592
- attributes:
593
- - name: Name Of Attribute (e.g. gml:boundedBy)
594
- used: false
595
- guidance: |
596
- Drop guidance message here.
597
- ...
598
- ----
599
-
600
- If you want to define the guidance, you can define the `name` of the class
601
- under `classes`. Then define which `attributes` you want to add guidance by the
602
- `name`. Set `used` to show the attribute is used or not. Drop the message of
603
- guidance in `guidance`.
604
-
605
-
606
-
607
-
608
- === Usage of `lutaml_ea_xmi` command
609
-
610
- The `lutaml_ea_xmi` command supersedes the `lutaml_uml_datamodel_description`
611
- command which it is functionally equivalent to.
612
-
613
- This command renders data model packages and its dependent objects for supplied
614
- XMI file, by using Liquid Drop objects.
615
-
616
- NOTE: The performance of `lutaml_ea_xmi` exceeds
617
- `lutaml_uml_datamodel_description` by 10~20 times (Tested with a 10.6MB XMI file
618
- with 120,000+ lines).
619
-
620
- NOTE: To migrate to this command from `lutaml_uml_datamodel_description`, just
621
- replace the command `lutaml_uml_datamodel_description` by `lutaml_ea_xmi`.
622
-
623
- Replace:
624
-
625
- [source,adoc]
626
- ----
627
- [lutaml_uml_datamodel_description, path/to/example.xmi]
628
- ...
629
- ----
630
-
631
- By:
632
-
633
- [source,adoc]
634
- ----
635
- [lutaml_ea_xmi, path/to/example.xmi]
636
- ...
637
- ----
638
-
639
- You can define guidance in the configuration file as well. The configuration
640
- file will looks like:
641
-
642
- [source,yaml]
643
- ----
644
- packages:
645
- - my_package
646
- guidance: "path/to/guidance.yaml"
647
- ----
648
-
649
- The guidance file should be in the following format:
650
-
651
- [source,yaml]
652
- ----
653
- ---
654
- classes:
655
- - name: "NameOfClass"
656
- attributes:
657
- - name: Name Of Attribute (e.g. gml:boundedBy)
658
- used: false
659
- guidance: |
660
- Drop guidance message here.
661
- ...
662
- ----
663
-
664
- If you want to define the guidance, you can define the `name` of the class
665
- under `classes`. Then define which `attributes` you want to add guidance by the
666
- `name`. Set `used` to show the attribute is used or not. Drop the message of
667
- guidance in `guidance`.
668
-
669
- The `name` of class can be defined in the following ways:
670
-
671
- * `name: "NameOfClass"` specifies the name of the `class`.
672
- (e.g. `name: "Building"`)
673
- If there are multiple classes with the same name, it is recommended to
674
- specify the class by absolute path.
675
-
676
- * `name: "::NameOfPackage::NameOfClass"` specifies the name of the `class` in
677
- `absolute` path.
678
- (e.g. `name: "::EA_Model::Conceptual Models::CityGML2.0::bldg::Building"`)
679
-
680
-
681
- === Usage of `lutaml_uml_datamodel_description` command
682
-
683
- This command allows to quickly render data model packages and its dependent
684
- objects for supplied XMI file.
685
-
686
- Given an Enterprise Architect `example.xmi` file with 2 packages:
687
-
688
- * 'Another'
689
- * 'CityGML'
690
-
691
- The `lutaml_uml_datamodel_description` command can be used:
692
-
693
- [source,adoc]
694
- ----
695
- [lutaml_uml_datamodel_description, path/to/example.xmi]
696
- --
697
- [.before]
698
- ....
699
- my text
700
- ....
701
-
702
- [.diagram_include_block, base_path="requirements/", format="emf"]
703
- ....
704
- Diagram text
705
- ....
706
-
707
- [.include_block, package="Another", base_path="spec/fixtures"]
708
- ....
709
- my text
710
- ....
711
-
712
- [.include_block, base_path="spec/fixtures"]
713
- ....
714
- my text
715
- ....
716
-
717
- [.before, package="Another"]
718
- ....
719
- text before Another package
720
- ....
721
-
722
- [.after, package="Another"]
723
- ....
724
- text after Another package
725
- ....
726
-
727
- [.after, package="CityGML"]
728
- ....
729
- text after CityGML package
730
- ....
731
-
732
- [.after]
733
- ....
734
- footer text
735
- ....
736
- --
737
- --
738
- ----
739
-
740
- Where:
741
-
742
- * `path/to/example.xmi` - required, path to the XMI file to render
743
-
744
- * `[.before]` - block text that adds additional text before the rendered output, can be used only once, additional occurrences of command will overwrite text, not that `literal` block style must be used in there(eg `....`)
745
-
746
- * `[.after]` - block text that adds additional text after the rendered output, can be used only once, additional occurrences of command will overwrite text
747
-
748
- * `[.after, package="Another"]` - block text to be inserted before(after in case of `.before` name) the package
749
-
750
- * `[.package_text, position="after", package="Another"]` - include custom adoc code into package rendered body, `position` is a a required attribute which tells where to insert the code.
751
-
752
- * `[.package_text, package="Another"]` - same as above, but include block will be included only for supplied package name
753
-
754
- * `[.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.
755
- +
756
- The logic is as follows:
757
- [source,adoc]
758
- ----
759
- {% for diagram in package.diagrams %}
760
- [[figure-{{ diagram.xmi_id }}]]
761
- .{{ diagram.name }}
762
- image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[]
763
-
764
- {% if diagram.definition %}
765
- {{ diagram.definition | html2adoc }}
766
- {% endif %}
767
- {% endfor %}
768
- ----
769
-
770
- 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 command text, it will be added as paragraph before each image include.
771
-
772
- * `[.diagram_include_block, package="Another"]` - same as above, but diagram will be included only for supplied package name
773
-
774
- * `[.include_block, base_path="spec/fixtures"]` - command 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. command 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`, command will look for the following file path: `my/path/_my_package_name.adoc`.
775
-
776
- * `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but include block will be included only for supplied package name
777
-
778
-
779
- NOTE: .after, .before, package_text and include_block commandses all can be used with additional option - `liquid`, if this option is supplied then the code inside block will be interpolated in liquid context
780
-
781
-
782
- === Referencing objects generated by LutaML
783
-
784
-
785
- There are two other commands that are used to refer to LutaML generated document elements:
786
-
787
- * `lutaml_figure`. Provides a reference anchor to a figure defined in the XMI
788
- file, using its XMI ID for reference.
789
-
790
- * `lutaml_table`. Provides a reference anchor to the definition tables of a
791
- particular package, class, enumeration or data type object in the XMI.
792
-
793
-
794
- The syntax is as follows:
795
-
796
- [source,adoc]
797
- ----
798
- // For lutaml_figure
799
- This is lutaml_figure::[package="Wrapper root package", name="Fig B1 Full model"] figure
800
-
801
- // For lutaml_table
802
- This is lutaml_table::[package="Wrapper root package"] package
803
- This is lutaml_table::[package="Wrapper root package", class="my name"] class
804
- This is lutaml_table::[package="Wrapper root package", enum="my name"] enumeration
805
- This is lutaml_table::[package="Wrapper root package", data_type="my name"] data type
806
- ----
807
-
808
- This code will be transformed into `<<figure-{diagram.xmi_id}>>` and will point to diagram figure. One can only use this command when document rendered `lutaml_uml_datamodel_description` command as it needs diagram lookup table in order to reference package diagram.
809
-
810
- Will produce this output:
811
-
812
- [source,adoc]
813
- ----
814
- my text
815
- == CityGML package
816
- === CityGML overview
817
-
818
- Diagram text
819
-
820
- [[figure-EAID_ACBB5EE3_3428_40f5_9C7C_E41923419F29]]
821
- .CityGML Package Diagram
822
- image::requirements/EAID_ACBB5EE3_3428_40f5_9C7C_E41923419F29.png[]
823
-
824
- BuildingFurnitureFunctionValue is a code list that enumerates the different purposes of a BuildingFurniture.
825
-
826
- [[figure-EAID_938AE961_1C57_4052_B964_997D1894A58D]]
827
- .Use of ISO and OASIS standards in CityGML
828
- image::requirements/EAID_938AE961_1C57_4052_B964_997D1894A58D.png[]
829
-
830
- The CityGML package is organized into
831
- 2 packages with 1 modules:
832
-
833
- . Another package
834
- . CityTML package
835
-
836
- my text
837
-
838
- Content for CityGML package
839
-
840
- ==== Defining tables
841
-
842
- .<<section-EAPK_9C96A88B_E98B_490b_8A9C_24AEDAC64293>> -- Elements of &#8220;Another::AbstractAtomicTimeseries&#8221; (class)
843
-
844
- [[section-EAPK_9C96A88B_E98B_490b_8A9C_24AEDAC64293]]
845
- .Elements of &#8220;Another::AbstractAtomicTimeseries&#8221; (class)
846
- [width="100%",cols="a,a,a,a,a,a,a,a"]
847
- |===
848
- h|Name: 7+| AbstractAtomicTimeseries
849
- h|Definition: 7+|
850
- h|Stereotype: 7+| interface
851
- h|Abstract: 7+|
852
- h|Associations: 7+| (none)
853
- .4+h|Public attributes:
854
- | _Name_
855
- 2+| _Definition_
856
- | _Derived_
857
- | _Obligation_
858
- | _Maximum occurrence_
859
- | _Data type_
860
- | adeOfAbstractAtomicTimeseries
861
- 2+|
862
- |
863
- | C
864
- | *
865
- | ADEOfAbstractAtomicTimeseries
866
- | observationProperty
867
- 2+|
868
- |
869
- | M
870
- | 1
871
- | CharacterString
872
- | uom
873
- 2+|
874
- |
875
- | C
876
- | 1
877
- | CharacterString
878
- h|Constraints: 7+| (none)
879
- |===
880
-
881
- === Additional Information
882
-
883
- text after CityGML package
884
- ----
885
-
886
- In addition to the XMI file, this command also supports a YAML configuration file
887
- that specifies:
888
-
889
- * What packages to include in the render;
890
-
891
- * What render style is desired;
892
-
893
- * Location of the root package (which package should the iterative process start
894
- at);
895
-
896
- * Which EA extensions to be loaded.
897
-
898
- The format for using the YAML configuration file:
899
-
900
- [source,yaml]
901
- ----
902
- ---
903
- packages:
904
- # includes these packages
905
- - "Package *"
906
- - two*
907
- - three
908
- # skips these packages
909
- - skip: four
910
- render_style: entity_list | data_dictionary | default
911
- section_depth: 2
912
- ea_extension:
913
- - "CityGML_MDG_Technology.xml"
914
- - "xmi_definition_for_some_standard.xml"
915
- ----
916
-
917
- Where:
918
-
919
- * `packages` - required, root element with the list of strings or objects
920
-
921
- * `Package *` - pattern matching, specifies lookup condition for packages to
922
- render.
923
- +
924
- NOTE: In this example, it is equal to the following regular expression: `/^Package.*$/`
925
-
926
- * `skip: four` - object with package name to skip
927
-
928
- * `render_style` - what template to use to render packages, can be one of:
929
-
930
- ** `entity_list`
931
-
932
- ** `data_dictionary`; or
933
-
934
- ** `default`
935
-
936
- * `section_depth` - what package to use as root package for render.
937
- e.g., a `section_depth` equal to `2` tells the processor to use the first
938
- nested package of the first root packages in XMI file.
939
- +
940
- EXAMPLE: If the XMI file has this package structure, and we have `section_depth`
941
- equal to 2, root package will be `one-1`.
942
- +
943
- [source,json]
944
- ----
945
- [
946
- {
947
- name: 'One',
948
- packages: [{ name: 'one-1' }, { name: 'one-2' }]
949
- },
950
- {
951
- name: 'Two',
952
- packages: [{ name: 'two-1' }, { name: 'two-2' }]
953
- }
954
- ]
955
- ----
956
-
957
- * `ea_extension` - optional, list of EA extensions to load. Some XMI files may
958
- contain elements that cannot be resolved by default, for example CityGML
959
- elements. You can use `ea_extension` to load the definition of these elements
960
- in XML format (`CityGML_MDG_Technology.xml`) in order to resolve them. The
961
- location of the xml files is relative to the config YAML file.
962
-
963
- Usage with command:
964
-
965
- [source,adoc]
966
- --
967
- [lutaml_uml_datamodel_description, path/to/example.xmi, path/to/config.yml]
968
- ----
969
- [.diagram_include_block, base_path="models/Images", format="png"]
970
- ...
971
- ...
972
- ----
973
- --
974
-
975
- The processor will read the supplied YAML config file (`path/to/config.yml`),
976
- and iterate through packages according to the order supplied in the file. All
977
- packages that matches `skip` in the YAML config file will be skipped during
978
- render.
979
-
980
-
981
-
982
-
983
- == Usage with GML
984
-
985
- === Rendering a LutaML GML Dictionary: `lutaml_gml_dictionary`
986
-
987
- This command allows to render a LutaML GML Dictionary by using Liquid Drop.
988
-
989
- GmlDictionaryDrop has the following attributes:
990
-
991
- * name
992
- * file_name
993
- * dictionary_entry
994
-
995
- Each `dictionary_entry` has the following attributes:
996
-
997
- * name
998
- * description
999
-
1000
- [source,adoc]
1001
- ----
1002
- lutaml_gml_dictionary::/path/to/dictionary.xml[template="/path/to/template.liquid",context=dict]
1003
- ----
1004
-
1005
- The command accepts the options listed below:
1006
-
1007
- * `/path/to/dictionary.xml` specifies the path of xml file of the
1008
- GML Dictionary.
1009
-
1010
- * `template="/path/to/template.liquid"` specifies the liquid template.
1011
- For example, you can create a liquid template and link it by `template`.
1012
-
1013
- * `context=dict` define the context in the template.
1014
-
1015
- [source,adoc]
1016
- ----
1017
- [cols="3a,22a"]
1018
- |===
1019
- | Name | {{ dict.file_name }}
1020
-
1021
- h| Code h| Description
1022
- {% for entry in dict.dictionary_entry %}
1023
- | {{ entry.name }} | {{ entry.description }}
1024
- {% endfor %}
1025
- |===
1026
-
1027
- [.source]
1028
- <<source_link>>
1029
- ----
1030
-
1031
- In spite of specifying the path of the template, you can also define an inline
1032
- template within a block by
1033
- `[lutaml_gml_dictionary,"/path/to/dictionary.xml",context=dict]`.
1034
-
1035
- [source,adoc]
1036
- ----
1037
- [lutaml_gml_dictionary,"/path/to/dictionary.xml",context=dict]
1038
- --
1039
- {% capture link %}https://www.test.com/{{ dict.file_name }}{% endcapture %}
1040
-
1041
- [cols="3a,22a"]
1042
- |===
1043
- | File Name | {{ dict.file_name }}
1044
- h| URL | {{ link }}
1045
- h| Help | Description
1046
- {% for entry in dict.dictionary_entry %}
1047
- | {{ entry.name }} | {{ entry.description }}
1048
- {% endfor %}
1049
- |===
1050
-
1051
- [.source]
1052
- <<source_link>>
1053
- --
1054
- ----
39
+ Please refer to https://www.metanorma.org.
1055
40
 
41
+ == Copyright and license
1056
42
 
1057
- == Documentation
43
+ Copyright Ribose.
1058
44
 
1059
- Please refer to https://www.metanorma.org.
45
+ Licensed under the MIT License.