metanorma-plugin-lutaml 0.7.16 → 0.7.17

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: 94ae5b7c7623f566c05b312d7d2ea4fd26f558e119ceae4edb2d765f31d30f59
4
- data.tar.gz: 963b9236a881435f8270fd82b70182b17b5d706c828e9dd463e51d3eaeb22b11
3
+ metadata.gz: 6f680f88df78449b51a5edc5344da198ca126fa9d2dd5400dfe309ed456cd32a
4
+ data.tar.gz: ea9831bdfae3d53412f5581ae82a8ee79f18d3a81ce78e40295d1eacb5394614
5
5
  SHA512:
6
- metadata.gz: dc81997fa69f6a2ea70ca8eac8e22bf281927f752096307d4c503351fc9c3617ff85e3bf3877730f188cbea1b187389b33d0874656c1079f345a3cb0609812d9
7
- data.tar.gz: e4335ac32b79f4d78feee0eb49bd166f9374dd5e0d32fbc019d3ba01e1aecfa5099e39ad71d3f23118e2c272df1b256ad6598743fc6a743fbbbe347ad89a4f3a
6
+ metadata.gz: c3a5caabd987904ed65645ed49a343cac93aa2ce6d250dc521d1c51a5d5c52e43fcf9d381a6961976654dfaa892a266bf33d14ef6275e9b58d33c0387fdbbd41
7
+ data.tar.gz: 6bf56d6a0f8be8a79e9fdc643ceeec22acd3f3327550dfa7295a72dbfcac6647456d194fd43be0cb3bdd02c665dae6ea5d8400d8b309741e8d23889edc7a6175
data/README.adoc CHANGED
@@ -4,13 +4,15 @@ image:https://github.com/metanorma/metanorma-plugin-lutaml/workflows/rake/badge.
4
4
 
5
5
  == Purpose
6
6
 
7
- LutaML is a data model accessor that supports various data model formats,
8
- including:
7
+ LutaML is a data model accessor that supports various data model formats.
8
+
9
+ This plugin allows you to access the following types of information models from
10
+ within a Metanorma document:
9
11
 
10
12
  * EXPRESS (`*.exp` files)
11
- * OMG UML in XMI format (`*.xmi` files)
13
+ * LutaML-UML (`*.lutaml` files)
14
+ * Enterprise Architect exported UML in XMI format (`*.xmi` files)
12
15
 
13
- This plugin allows you to access LutaML models from within a Metanorma document.
14
16
 
15
17
  == Installation
16
18
 
@@ -24,11 +26,93 @@ $ gem install metanorma-plugin-lutaml
24
26
 
25
27
  === General
26
28
 
29
+ The LutaML plugin supports working with EXPRESS schema files to render EXPRESS
30
+ models and definitions.
31
+
27
32
  LutaML supports accessing EXPRESS models via the
28
33
  https://github.com/lutaml/expressir[Expressir] parser.
29
34
 
30
35
 
31
- === Usage of the `lutaml` command
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
32
116
 
33
117
  Given an `example.exp` EXPRESS file with content:
34
118
 
@@ -57,13 +141,12 @@ SCHEMA test_schema 'test';
57
141
  END_SCHEMA;
58
142
  ----
59
143
 
60
- And the `lutaml` block:
144
+ And the `lutaml_express` block:
61
145
 
62
146
  [source,adoc]
63
147
  -----
64
- [lutaml,example.exp,my_context]
148
+ [lutaml_express,example.exp,my_context]
65
149
  ----
66
-
67
150
  {% for schema in my_context.schemas %}
68
151
  == {{schema.id}}
69
152
 
@@ -75,6 +158,11 @@ And the `lutaml` block:
75
158
  ----
76
159
  -----
77
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
+
78
166
  Where:
79
167
 
80
168
  * content within the block is called the "`template`";
@@ -107,28 +195,27 @@ ____
107
195
  === my_type5
108
196
  ____
109
197
 
110
- This command also supports `.lutaml` files.
111
198
 
112
- Instead of using the direct path to the file one can use `lutaml-express-index`
199
+ Instead of using the direct path to the file one can use `:lutaml-express-index:`
113
200
  document attribute to supply directory with express files or YAML index file to
114
201
  parse as well as the cache file location.
115
202
 
116
- The syntax is as follows:
203
+ Syntax:
117
204
 
118
205
  [source,adoc]
119
- -----
206
+ ----
120
207
  :lutaml-express-index: my_custom_name; dir_or_index_path[; cache=cache_path]
121
- -----
208
+ ----
122
209
 
123
210
  Where:
124
211
 
125
- * `my_custom_name` - is name of the parsed EXPRESS files context for the later
126
- use with lutaml macro
212
+ `my_custom_name`:: is name of the parsed EXPRESS files context for the later
213
+ use with lutaml command
127
214
 
128
- * `dir_or_index_path` - location of directory with EXPRESS files or path to the
215
+ `dir_or_index_path`:: location of directory with EXPRESS files or path to the
129
216
  YAML index file to parse
130
217
 
131
- * `cache_path` - optional, location of the Expressir cache file to use
218
+ `cache_path`:: (optional) location of the Expressir cache file to use
132
219
 
133
220
  Example of usage:
134
221
 
@@ -146,22 +233,22 @@ Author
146
233
  ----
147
234
  -----
148
235
 
149
- === Using `config.yaml`
236
+ === Filtering EXPRESS schemas defined in an index for `lutaml_express`
150
237
 
151
238
  This functionality allows `[lutaml_express]` blocks to load a full set of
152
239
  EXPRESS schemas in one index, and then provide a select ("filter") option
153
240
  per-block via a separate YAML file.
154
241
 
155
242
  [source,adoc]
156
- ----
243
+ -----
157
244
  :lutaml-express-index: all_schemas; ../schemas_all.yaml;
158
245
 
159
246
  [lutaml_express,all_schemas,context,leveloffset=+1,config_yaml=schemas.yaml]
160
- ---
247
+ ----
161
248
  {% assign selected = context.schemas | where: "selected" %}
162
249
  {% render "templates/resources/schema" for selected as schema %}
163
- ---
164
250
  ----
251
+ -----
165
252
 
166
253
  Where `schemas_all.yml` provides all schemas:
167
254
 
@@ -195,18 +282,25 @@ The resulting block adds the `select` attribute to every schema of the the
195
282
  via Liquid:
196
283
 
197
284
  [source,liquid]
198
- ----
285
+ -----
199
286
  [lutaml_express,schemas_1,repo,leveloffset=+1,config_yaml=select.yaml]
200
- ---
287
+ ----
201
288
  {% assign selected = repo.schemas | where: "selected" %}
202
289
  ... do things with `selected` ...
203
- ----
290
+ ---
291
+ -----
204
292
 
205
293
  NOTE: This functionality is used in the ISO 10303 SRL to load the full schema
206
294
  set at once but only render the selected schemas in individual documents.
207
295
 
208
296
 
209
- == Usage with UML
297
+ == Usage with Lutaml-UML
298
+
299
+ === General
300
+
301
+ The LutaML plugin supports working with LutaML UML files to render UML diagrams
302
+ and class definitions.
303
+
210
304
 
211
305
  === Rendering a LutaML view: `lutaml_diagram`
212
306
 
@@ -239,9 +333,9 @@ diagram MyView {
239
333
  The `lutaml_diagram` command will add the image to the document.
240
334
 
241
335
  [source,adoc]
242
- -----
336
+ ----
243
337
  lutaml_diagram::example.lutaml[]
244
- -----
338
+ ----
245
339
 
246
340
  The `lutaml_diagram` command can also be used to denote a block with an embedded
247
341
  LutaML view.
@@ -273,172 +367,7 @@ diagram MyView {
273
367
  ....
274
368
  ----
275
369
 
276
- === Rendering a LutaML Enterprise Architect diagram from XMI: `lutaml_ea_diagram`
277
-
278
- This command allows to quickly render a LutaML diagram as an image file by
279
- specifying the name of diagram.
280
-
281
- [source,adoc]
282
- -----
283
- lutaml_ea_diagram::[name="name_of_diagram",base_path="/path/to/xmi-images",format="png"]
284
- -----
285
-
286
- The code will search the diagram with name `name_of_diagram` and then
287
- render it as:
288
-
289
- [source,adoc]
290
- -----
291
- [[figure-{{ diagram.xmi_id }}]]
292
- .{{ diagram.name }}
293
- image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[]
294
- -----
295
-
296
- === Rendering a LutaML GML Dictionary: `lutaml_gml_dictionary`
297
-
298
- This command allows to render a LutaML GML Dictionary by using Liquid Drop.
299
-
300
- GmlDictionaryDrop has the following attributes:
301
-
302
- * name
303
- * file_name
304
- * dictionary_entry
305
-
306
- Each `dictionary_entry` has the following attributes:
307
-
308
- * name
309
- * description
310
-
311
- [source,adoc]
312
- -----
313
- lutaml_gml_dictionary::/path/to/dictionary.xml[template="/path/to/template.liquid",context=dict]
314
- -----
315
-
316
- The command accepts the options listed below:
317
-
318
- * `/path/to/dictionary.xml` specifies the path of xml file of the
319
- GML Dictionary.
320
-
321
- * `template="/path/to/template.liquid"` specifies the liquid template.
322
- For example, you can create a liquid template and link it by `template`.
323
-
324
- * `context=dict` define the context in the template.
325
-
326
- [source,adoc]
327
- -----
328
- [cols="3a,22a"]
329
- |===
330
- | Name | {{ dict.file_name }}
331
-
332
- h| Code h| Description
333
- {% for entry in dict.dictionary_entry %}
334
- | {{ entry.name }} | {{ entry.description }}
335
- {% endfor %}
336
- |===
337
-
338
- [.source]
339
- <<source_link>>
340
- -----
341
-
342
- In spite of specifying the path of the template, you can also define an inline
343
- template within a block by
344
- `[lutaml_gml_dictionary,"/path/to/dictionary.xml",context=dict]`.
345
-
346
- [source,adoc]
347
- -----
348
- [lutaml_gml_dictionary,"/path/to/dictionary.xml",context=dict]
349
- --
350
- {% capture link %}https://www.test.com/{{ dict.file_name }}{% endcapture %}
351
-
352
- [cols="3a,22a"]
353
- |===
354
- | File Name | {{ dict.file_name }}
355
- h| URL | {{ link }}
356
- h| Help | Description
357
- {% for entry in dict.dictionary_entry %}
358
- | {{ entry.name }} | {{ entry.description }}
359
- {% endfor %}
360
- |===
361
-
362
- [.source]
363
- <<source_link>>
364
- --
365
- -----
366
-
367
- === Rendering a LutaML table of a class: `lutaml_klass_table`
368
-
369
- This command allows to render a LutaML table of a class by using Liquid Drop.
370
-
371
- The table will show:
372
-
373
- * Class Name
374
- * Class Definition
375
- * Inherited Properties
376
- * Self-defined Properties
377
- * Properties Inherited from Association
378
- * Properties Defined in Association
379
-
380
- [source,adoc]
381
- -----
382
- lutaml_klass_table::/path/to/example.xmi[name="NameOfClass",template="/path/to/templates/_my_klass_table.liquid"]
383
- -----
384
-
385
- The command accepts the options listed below:
386
-
387
- * `/path/to/example.xmi` specifies the path of xmi file.
388
-
389
- * `name` option only, `name` option with `package` option or `path` option.
390
- One of 3 forms of options can be used to specify the name of the class.
391
-
392
- ** `name="NameOfClass"` specifies the name of the `class`.
393
- (e.g. `name="Building"`)
394
- If there are multiple classes with the same name, other form of options
395
- are recommended to specify the class.
396
-
397
- ** `package="NameOfPackage"name="NameOfClass"` specifies the name of the
398
- `class` (specified by `name` option) inside the `package`
399
- (specified by `package` option).
400
- The `package` option must be used with the `name` option.
401
- (e.g. `package="uro",name="_BoundarySurface"`)
402
-
403
- ** `path="PathOfClass"` specifies the `absolute` path of the `class`
404
- which is started with `::`
405
- (e.g. `path="::EA_Model::Conceptual Models::i-UR::Urban Planning ADE 3.
406
- 1::uro::_BoundarySurface"`)
407
- or `relative` path of the `class` which is not started with `::`
408
- (e.g. `path="uro::_BoundarySurface"`).
409
- The last part of the path separated by `::` is the name of the `class`.
410
- The other parts of the path are the names of the `packages`.
411
-
412
- * `template="/path/to/templates/_my_klass_table.liquid"` specifies the path of
413
- the liquid template. (Optional)
414
- By default, it will look for the template `_klass_table.liquid` defined in
415
- `lib/metanorma/plugin/lutaml/templates`. This template can be customized by
416
- changing the template path in the `template` option.
417
-
418
- * `guidance="/path/to/my_guidance.yml"` specifies the path of
419
- the yaml file of the guidance. (Optional)
420
-
421
- The guidance file should be in the following format:
422
-
423
- [source,yaml]
424
- ----
425
- ---
426
- classes:
427
- - name: Name Of Class
428
- attributes:
429
- - name: Name Of Attribute (e.g. gml:boundedBy)
430
- used: false
431
- guidance: |
432
- Drop guidance message here.
433
- ...
434
- ----
435
-
436
- If you want to define the guidance, you can define the `name` of the class
437
- under `classes`. Then define which `attributes` you want to add guidance by the
438
- `name`. Set `used` to show the attribute is used or not. Drop the message of
439
- guidance in `guidance`.
440
-
441
- === Generating UML class and attributes: `lutaml_uml_class`
370
+ === Generating a UML class and attributes clause: `lutaml_uml_class`
442
371
 
443
372
  This command allows rendering a definition clause for a UML class.
444
373
 
@@ -503,17 +432,17 @@ ____
503
432
 
504
433
  The command accepts two options:
505
434
 
506
- * `skip_headers=true` (or just `skip_headers`). The initial heading (the UML class name)
435
+ `skip_headers=true`:: (or just `skip_headers`) The initial heading (the UML class name)
507
436
  will not be generated. This is useful if additional content is to be supplied
508
437
  to the clause, such as diagrams that are defined outside the UML model.
509
438
 
510
- * `depth={n}`. (default: `2`) This determines the depth of the generated headings.
439
+ `depth={n}`:: (default: `2`) This determines the depth of the generated headings.
511
440
  A depth of `2` means the initial heading will have 2 equal signs, and so forth.
512
441
  The heading depth of the attributes are in relation to the initial depth, so
513
442
  a depth of `2` will have the "Attributes" section at depth `3`.
514
443
 
515
444
 
516
- === `lutaml_uml_attributes_table`
445
+ === Generating a UML attributes table: `lutaml_uml_attributes_table`
517
446
 
518
447
  This command allows rendering definition tables for a UML model.
519
448
 
@@ -541,12 +470,12 @@ diagram MyView {
541
470
  }
542
471
  ----
543
472
 
544
- And the `lutaml_uml_attributes_table` macro:
473
+ And the `lutaml_uml_attributes_table` command:
545
474
 
546
475
  [source,adoc]
547
- -----
476
+ ----
548
477
  [lutaml_uml_attributes_table, example.lutaml, AttributeProfile]
549
- -----
478
+ ----
550
479
 
551
480
  Will produce this output:
552
481
 
@@ -568,9 +497,9 @@ ____
568
497
  In case of "enumeration" (AddressClassProfile) entity:
569
498
 
570
499
  [source,adoc]
571
- -----
500
+ ----
572
501
  [lutaml_uml_attributes_table, example.lutaml, AddressClassProfile]
573
- -----
502
+ ----
574
503
 
575
504
  Will produce this output:
576
505
 
@@ -586,20 +515,305 @@ ____
586
515
  |===
587
516
  ____
588
517
 
589
- === Usage of `lutaml_uml_datamodel_description` macro
590
518
 
591
- This command allows to quickly render data model packages and its dependent
592
- objects for supplied XMI file.
519
+ == Usage with Enterprise Architect (UML in XMI)
593
520
 
594
- Given an Enterprise Architect `example.xmi` file with 2 packages:
521
+ === General
595
522
 
596
- * 'Another'
597
- * 'CityGML'
523
+ The LutaML plugin supports working with Enterprise Architect exported XMI files
524
+ to render UML diagrams and class definitions.
598
525
 
599
- The `lutaml_uml_datamodel_description` macro can be used:
526
+ The commands are prefixed as `lutaml_ea_*` to denote their specific use with
527
+ Enterprise Architect XMI files.
528
+
529
+
530
+ === Document attribute `:lutaml-xmi-index:`
531
+
532
+ This attribute allows specifying one or more XMI files to defined names
533
+ for later use with `lutaml_ea_*` commands.
534
+
535
+ Syntax:
600
536
 
601
537
  [source,adoc]
602
- -----
538
+ ----
539
+ :lutaml-xmi-index: index_name; index_path[; config=config_path]
540
+ ----
541
+
542
+ where:
543
+
544
+ `index_name`:: name of index
545
+ `index_path`:: path to XMI file for the later use with `lutaml_ea_*` command
546
+ `config_path`:: optional, location of YAML configuration file that specifies
547
+ what packages to include in the render, what render style is desired and
548
+ location of the root package.
549
+
550
+
551
+ [example]
552
+ .Define two indexes in the document and use them in the `lutaml_ea_xmi` command
553
+ ====
554
+ [source,adoc]
555
+ ----
556
+ :lutaml-xmi-index: first-xmi-index; /path/to/first.xmi
557
+ :lutaml-xmi-index: second-xmi-index; /path/to/second.xmi; config=/path/to/config.yml
558
+
559
+ [lutaml_ea_xmi,index=first-xmi-index]
560
+ --
561
+ ...
562
+ --
563
+
564
+ lutaml_ea_diagram::[name="NameOfDiagramInSecondXmiIndex",base_path="./xmi-images",format="png",index="second-xmi-index"]
565
+ ...
566
+ ----
567
+
568
+ The command `lutaml_ea_xmi` will load the XMI file from the path
569
+ `/path/to/first.xmi` which is specified by the `index`: `first-xmi-index`.
570
+
571
+ The command `lutaml_ea_diagram` will load the XMI file from the path
572
+ `/path/to/second.xmi` which is specified by the `index`: `second-xmi-index`.
573
+ ====
574
+
575
+
576
+ === Rendering a Enterprise Architect diagram from XMI: `lutaml_ea_diagram`
577
+
578
+ This command allows to quickly render a LutaML diagram as an image file by
579
+ specifying the name of diagram.
580
+
581
+ Syntax:
582
+
583
+ [source,adoc]
584
+ ----
585
+ lutaml_ea_diagram::[{options}]
586
+ ----
587
+
588
+ where `{options}` is a hash of options, where:
589
+
590
+ `name`:: (mandatory) name of the diagram to render.
591
+ `base_path`:: (mandatory) base path where the diagram images are located.
592
+ `format`:: (optional) format of the image file. Defaults to `png`.
593
+ `index`:: (optional) index name of the XMI file. If the index is not provided,
594
+ the command will look for the diagram in the first XMI file specified through
595
+ the `lutaml_ea_xmi` command.
596
+ `package`:: (optional) name of the package which contains the diagram. If the
597
+ package is not provided, the command will look for the diagram across all
598
+ packages in the XMI file.
599
+
600
+ The diagram with name `name_of_diagram` will be converted into the following
601
+ Metanorma block:
602
+
603
+ [source,adoc]
604
+ ----
605
+ [[figure-{{ diagram.xmi_id }}]]
606
+ .{{ diagram.name }}
607
+ image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[]
608
+ ----
609
+
610
+ [example]
611
+ .Specifying a diagram within an XMI file
612
+ ====
613
+ [source,adoc]
614
+ ----
615
+ lutaml_ea_diagram::[name="name_of_diagram",base_path="/path/to/xmi-images",format="png"]
616
+ ----
617
+
618
+ Renders the diagram with name `name_of_diagram` from the XMI file in PNG format,
619
+ where the EA images exported with the XMI file are at `/path/to/xmi-images`.
620
+ ====
621
+
622
+ [example]
623
+ .Specifying a diagram within a specific package (if there are multiple diagrams with the same name)
624
+ ====
625
+ [source,adoc]
626
+ ----
627
+ lutaml_ea_diagram::[name="DiagramName",package="PackageA",base_path="/path/to/xmi-images"]
628
+ ----
629
+
630
+ The search wil be restricted to the diagrams named `DiagramName` in the
631
+ `PackageA` package.
632
+ ====
633
+
634
+ [example]
635
+ .Specifying a diagram using a specific index
636
+ ====
637
+ [source,adoc]
638
+ ----
639
+ :lutaml-xmi-index: index_name; /path/to/xmi-file.xmi
640
+
641
+ ...
642
+
643
+ lutaml_ea_diagram::[name="name_of_diagram",base_path="/path/to/xmi-images",format="png",index="index_name"]
644
+ ----
645
+
646
+ Renders the diagram with name `name_of_diagram` from the XMI file in PNG format,
647
+ where the EA images exported with the XMI file are at `/path/to/xmi-images` and
648
+ the XMI file defined in the index `index_name`.
649
+ ====
650
+
651
+
652
+
653
+ === Generating a class definition table for a class: `lutaml_klass_table`
654
+
655
+ This command allows to render a LutaML table of a class by using Liquid Drop.
656
+
657
+ The table will show:
658
+
659
+ * Class Name
660
+ * Class Definition
661
+ * Inherited Properties
662
+ * Self-defined Properties
663
+ * Properties Inherited from Association
664
+ * Properties Defined in Association
665
+
666
+ [source,adoc]
667
+ ----
668
+ lutaml_klass_table::/path/to/example.xmi[name="NameOfClass",template="/path/to/templates/_my_klass_table.liquid"]
669
+ ----
670
+
671
+ The command accepts the options listed below:
672
+
673
+ * `/path/to/example.xmi` specifies the path of xmi file.
674
+
675
+ * `name` option only, `name` option with `package` option or `path` option.
676
+ One of 3 forms of options can be used to specify the name of the class.
677
+
678
+ ** `name="NameOfClass"` specifies the name of the `class`.
679
+ (e.g. `name="Building"`)
680
+ If there are multiple classes with the same name, other form of options
681
+ are recommended to specify the class.
682
+
683
+ ** `package="NameOfPackage"name="NameOfClass"` specifies the name of the
684
+ `class` (specified by `name` option) inside the `package`
685
+ (specified by `package` option).
686
+ The `package` option must be used with the `name` option.
687
+ (e.g. `package="uro",name="_BoundarySurface"`)
688
+
689
+ ** `path="PathOfClass"` specifies the `absolute` path of the `class`
690
+ which is started with `::`
691
+ (e.g. `path="::EA_Model::Conceptual Models::i-UR::Urban Planning ADE 3.
692
+ 1::uro::_BoundarySurface"`)
693
+ or `relative` path of the `class` which is not started with `::`
694
+ (e.g. `path="uro::_BoundarySurface"`).
695
+ The last part of the path separated by `::` is the name of the `class`.
696
+ The other parts of the path are the names of the `packages`.
697
+
698
+ * `template="/path/to/templates/_my_klass_table.liquid"` specifies the path of
699
+ the liquid template. (Optional)
700
+ By default, it will look for the template `_klass_table.liquid` defined in
701
+ `lib/metanorma/plugin/lutaml/templates`. This template can be customized by
702
+ changing the template path in the `template` option.
703
+
704
+ * `guidance="/path/to/my_guidance.yml"` specifies the path of
705
+ the yaml file of the guidance. (Optional)
706
+
707
+ The guidance file should be in the following format:
708
+
709
+ [source,yaml]
710
+ ----
711
+ ---
712
+ classes:
713
+ - name: Name Of Class
714
+ attributes:
715
+ - name: Name Of Attribute (e.g. gml:boundedBy)
716
+ used: false
717
+ guidance: |
718
+ Drop guidance message here.
719
+ ...
720
+ ----
721
+
722
+ If you want to define the guidance, you can define the `name` of the class
723
+ under `classes`. Then define which `attributes` you want to add guidance by the
724
+ `name`. Set `used` to show the attribute is used or not. Drop the message of
725
+ guidance in `guidance`.
726
+
727
+
728
+
729
+
730
+ === Usage of `lutaml_ea_xmi` command
731
+
732
+ The `lutaml_ea_xmi` command supersedes the `lutaml_uml_datamodel_description`
733
+ command which it is functionally equivalent to.
734
+
735
+ This command renders data model packages and its dependent objects for supplied
736
+ XMI file, by using Liquid Drop objects.
737
+
738
+ NOTE: The performance of `lutaml_ea_xmi` exceeds
739
+ `lutaml_uml_datamodel_description` by 10~20 times (Tested with a 10.6MB XMI file
740
+ with 120,000+ lines).
741
+
742
+ NOTE: To migrate to this command from `lutaml_uml_datamodel_description`, just
743
+ replace the command `lutaml_uml_datamodel_description` by `lutaml_ea_xmi`.
744
+
745
+ Replace:
746
+
747
+ [source,adoc]
748
+ ----
749
+ [lutaml_uml_datamodel_description, path/to/example.xmi]
750
+ ...
751
+ ----
752
+
753
+ By:
754
+
755
+ [source,adoc]
756
+ ----
757
+ [lutaml_ea_xmi, path/to/example.xmi]
758
+ ...
759
+ ----
760
+
761
+ You can define guidance in the configuration file as well. The configuration
762
+ file will looks like:
763
+
764
+ [source,yaml]
765
+ ----
766
+ packages:
767
+ - my_package
768
+ guidance: "path/to/guidance.yaml"
769
+ ----
770
+
771
+ The guidance file should be in the following format:
772
+
773
+ [source,yaml]
774
+ ----
775
+ ---
776
+ classes:
777
+ - name: "NameOfClass"
778
+ attributes:
779
+ - name: Name Of Attribute (e.g. gml:boundedBy)
780
+ used: false
781
+ guidance: |
782
+ Drop guidance message here.
783
+ ...
784
+ ----
785
+
786
+ If you want to define the guidance, you can define the `name` of the class
787
+ under `classes`. Then define which `attributes` you want to add guidance by the
788
+ `name`. Set `used` to show the attribute is used or not. Drop the message of
789
+ guidance in `guidance`.
790
+
791
+ The `name` of class can be defined in the following ways:
792
+
793
+ * `name: "NameOfClass"` specifies the name of the `class`.
794
+ (e.g. `name: "Building"`)
795
+ If there are multiple classes with the same name, it is recommended to
796
+ specify the class by absolute path.
797
+
798
+ * `name: "::NameOfPackage::NameOfClass"` specifies the name of the `class` in
799
+ `absolute` path.
800
+ (e.g. `name: "::EA_Model::Conceptual Models::CityGML2.0::bldg::Building"`)
801
+
802
+
803
+ === Usage of `lutaml_uml_datamodel_description` command
804
+
805
+ This command allows to quickly render data model packages and its dependent
806
+ objects for supplied XMI file.
807
+
808
+ Given an Enterprise Architect `example.xmi` file with 2 packages:
809
+
810
+ * 'Another'
811
+ * 'CityGML'
812
+
813
+ The `lutaml_uml_datamodel_description` command can be used:
814
+
815
+ [source,adoc]
816
+ ----
603
817
  [lutaml_uml_datamodel_description, path/to/example.xmi]
604
818
  --
605
819
  [.before]
@@ -643,15 +857,15 @@ footer text
643
857
  ....
644
858
  --
645
859
  --
646
- -----
860
+ ----
647
861
 
648
862
  Where:
649
863
 
650
864
  * `path/to/example.xmi` - required, path to the XMI file to render
651
865
 
652
- * `[.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 `....`)
866
+ * `[.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 `....`)
653
867
 
654
- * `[.after]` - block text that adds additional text after the rendered output, can be used only once, additional occurrences of macro will overwrite text
868
+ * `[.after]` - block text that adds additional text after the rendered output, can be used only once, additional occurrences of command will overwrite text
655
869
 
656
870
  * `[.after, package="Another"]` - block text to be inserted before(after in case of `.before` name) the package
657
871
 
@@ -663,7 +877,7 @@ Where:
663
877
  +
664
878
  The logic is as follows:
665
879
  [source,adoc]
666
- -----
880
+ ----
667
881
  {% for diagram in package.diagrams %}
668
882
  [[figure-{{ diagram.xmi_id }}]]
669
883
  .{{ diagram.name }}
@@ -673,18 +887,21 @@ image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[
673
887
  {{ diagram.definition | html2adoc }}
674
888
  {% endif %}
675
889
  {% endfor %}
676
- -----
890
+ ----
677
891
 
678
- 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.
892
+ 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.
679
893
 
680
894
  * `[.diagram_include_block, package="Another"]` - same as above, but diagram will be included only for supplied package name
681
895
 
682
- * `[.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`.
896
+ * `[.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`.
683
897
 
684
898
  * `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but include block will be included only for supplied package name
685
899
 
686
900
 
687
- 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
901
+ 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
902
+
903
+
904
+ === Referencing objects generated by LutaML
688
905
 
689
906
 
690
907
  There are two other commands that are used to refer to LutaML generated document elements:
@@ -695,10 +912,11 @@ There are two other commands that are used to refer to LutaML generated document
695
912
  * `lutaml_table`. Provides a reference anchor to the definition tables of a
696
913
  particular package, class, enumeration or data type object in the XMI.
697
914
 
915
+
698
916
  The syntax is as follows:
699
917
 
700
918
  [source,adoc]
701
- -----
919
+ ----
702
920
  // For lutaml_figure
703
921
  This is lutaml_figure::[package="Wrapper root package", name="Fig B1 Full model"] figure
704
922
 
@@ -707,14 +925,14 @@ This is lutaml_table::[package="Wrapper root package"] package
707
925
  This is lutaml_table::[package="Wrapper root package", class="my name"] class
708
926
  This is lutaml_table::[package="Wrapper root package", enum="my name"] enumeration
709
927
  This is lutaml_table::[package="Wrapper root package", data_type="my name"] data type
710
- -----
928
+ ----
711
929
 
712
- 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.
930
+ 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.
713
931
 
714
932
  Will produce this output:
715
933
 
716
934
  [source,adoc]
717
- -----
935
+ ----
718
936
  my text
719
937
  == CityGML package
720
938
  === CityGML overview
@@ -785,9 +1003,9 @@ h|Constraints: 7+| (none)
785
1003
  === Additional Information
786
1004
 
787
1005
  text after CityGML package
788
- -----
1006
+ ----
789
1007
 
790
- In addition to the XMI file, this macro also supports a YAML configuration file
1008
+ In addition to the XMI file, this command also supports a YAML configuration file
791
1009
  that specifies:
792
1010
 
793
1011
  * What packages to include in the render;
@@ -853,7 +1071,7 @@ equal to 2, root package will be `one-1`.
853
1071
  ]
854
1072
  ----
855
1073
 
856
- Usage with macro:
1074
+ Usage with command:
857
1075
 
858
1076
  [source,adoc]
859
1077
  --
@@ -870,73 +1088,82 @@ and iterate through packages according to the order supplied in the file. All
870
1088
  packages that matches `skip` in the YAML config file will be skipped during
871
1089
  render.
872
1090
 
873
- === Usage of `lutaml_ea_xmi` macro
874
1091
 
875
- This command is a replacement for `lutaml_uml_datamodel_description` to perform
876
- the same functionalities of `lutaml_uml_datamodel_description`, which is to
877
- render data model packages and its dependent objects for supplied XMI file, by
878
- using Liquid Drop. The performance of `lutaml_ea_xmi` can be improved by
879
- 10~20 times. (Tested with a 10.6MB XMI file with 120000+ lines)
880
1092
 
881
- To use this macro, you only need to replace `lutaml_uml_datamodel_description`
882
- by `lutaml_ea_xmi`.
883
1093
 
884
- Replace:
1094
+ == Usage with GML
885
1095
 
886
- [source,adoc]
887
- -----
888
- [lutaml_uml_datamodel_description, path/to/example.xmi]
889
- ...
890
- -----
1096
+ === Rendering a LutaML GML Dictionary: `lutaml_gml_dictionary`
891
1097
 
892
- By:
1098
+ This command allows to render a LutaML GML Dictionary by using Liquid Drop.
1099
+
1100
+ GmlDictionaryDrop has the following attributes:
1101
+
1102
+ * name
1103
+ * file_name
1104
+ * dictionary_entry
1105
+
1106
+ Each `dictionary_entry` has the following attributes:
1107
+
1108
+ * name
1109
+ * description
893
1110
 
894
1111
  [source,adoc]
895
- -----
896
- [lutaml_ea_xmi, path/to/example.xmi]
897
- ...
898
- -----
1112
+ ----
1113
+ lutaml_gml_dictionary::/path/to/dictionary.xml[template="/path/to/template.liquid",context=dict]
1114
+ ----
899
1115
 
900
- You can define guidance in the configuration file as well. The configuration
901
- file will looks like:
1116
+ The command accepts the options listed below:
902
1117
 
903
- [source,yaml]
904
- -----
905
- packages:
906
- - my_package
907
- guidance: "path/to/guidance.yaml"
908
- -----
1118
+ * `/path/to/dictionary.xml` specifies the path of xml file of the
1119
+ GML Dictionary.
909
1120
 
910
- The guidance file should be in the following format:
1121
+ * `template="/path/to/template.liquid"` specifies the liquid template.
1122
+ For example, you can create a liquid template and link it by `template`.
911
1123
 
912
- [source,yaml]
1124
+ * `context=dict` define the context in the template.
1125
+
1126
+ [source,adoc]
913
1127
  ----
914
- ---
915
- classes:
916
- - name: "NameOfClass"
917
- attributes:
918
- - name: Name Of Attribute (e.g. gml:boundedBy)
919
- used: false
920
- guidance: |
921
- Drop guidance message here.
922
- ...
1128
+ [cols="3a,22a"]
1129
+ |===
1130
+ | Name | {{ dict.file_name }}
1131
+
1132
+ h| Code h| Description
1133
+ {% for entry in dict.dictionary_entry %}
1134
+ | {{ entry.name }} | {{ entry.description }}
1135
+ {% endfor %}
1136
+ |===
1137
+
1138
+ [.source]
1139
+ <<source_link>>
923
1140
  ----
924
1141
 
925
- If you want to define the guidance, you can define the `name` of the class
926
- under `classes`. Then define which `attributes` you want to add guidance by the
927
- `name`. Set `used` to show the attribute is used or not. Drop the message of
928
- guidance in `guidance`.
1142
+ In spite of specifying the path of the template, you can also define an inline
1143
+ template within a block by
1144
+ `[lutaml_gml_dictionary,"/path/to/dictionary.xml",context=dict]`.
929
1145
 
930
- The `name` of class can be defined in the following ways:
1146
+ [source,adoc]
1147
+ ----
1148
+ [lutaml_gml_dictionary,"/path/to/dictionary.xml",context=dict]
1149
+ --
1150
+ {% capture link %}https://www.test.com/{{ dict.file_name }}{% endcapture %}
931
1151
 
932
- * `name: "NameOfClass"` specifies the name of the `class`.
933
- (e.g. `name: "Building"`)
934
- If there are multiple classes with the same name, it is recommended to
935
- specify the class by absolute path.
1152
+ [cols="3a,22a"]
1153
+ |===
1154
+ | File Name | {{ dict.file_name }}
1155
+ h| URL | {{ link }}
1156
+ h| Help | Description
1157
+ {% for entry in dict.dictionary_entry %}
1158
+ | {{ entry.name }} | {{ entry.description }}
1159
+ {% endfor %}
1160
+ |===
1161
+
1162
+ [.source]
1163
+ <<source_link>>
1164
+ --
1165
+ ----
936
1166
 
937
- * `name: "::NameOfPackage::NameOfClass"` specifies the name of the `class` in
938
- `absolute` path.
939
- (e.g. `name: "::EA_Model::Conceptual Models::CityGML2.0::bldg::Building"`)
940
1167
 
941
1168
  == Documentation
942
1169
 
@@ -28,7 +28,7 @@ h| Property Name h| Property Type and Multiplicity h| Definition
28
28
  ({{ attr.gen_name }})
29
29
  {%- endcapture -%}
30
30
  | {{ name_col | newline_to_br }}
31
- | {{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
31
+ | {{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
32
32
  | {{ attr.definition }}
33
33
  {%- endif -%}
34
34
  {% endfor %}
@@ -42,7 +42,7 @@ h| Property Name h| Property Type and Multiplicity h| Definition
42
42
  ({{ attr.gen_name }})
43
43
  {%- endcapture -%}
44
44
  | {{ name_col | newline_to_br }}
45
- | {{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
45
+ | {{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
46
46
  | {{ attr.definition }}
47
47
  {%- endif -%}
48
48
  {% endfor %}
@@ -56,7 +56,7 @@ h| Property Name h| Property Type and Multiplicity h| Definition
56
56
  ({{ attr.gen_name }})
57
57
  {%- endcapture -%}
58
58
  | {{ name_col | newline_to_br }}
59
- | {{ attr.type_ns }}:{{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
59
+ | {{ attr.type_ns }}:{{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
60
60
  | {{ attr.definition }}
61
61
  {%- endif -%}
62
62
  {% endfor %}
@@ -70,7 +70,7 @@ h| Property Name h| Property Type and Multiplicity h| Definition
70
70
  ({{ attr.gen_name }})
71
71
  {%- endcapture -%}
72
72
  | {{ name_col | newline_to_br }}
73
- | {{ attr.type_ns }}:{{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
73
+ | {{ attr.type_ns }}:{{ attr.type }} [{{ attr.cardinality.min }}..{{ attr.cardinality.max }}]
74
74
  | {{ attr.definition }}
75
75
  {%- endif -%}
76
76
  {% endfor %}
@@ -7,13 +7,14 @@ module Metanorma
7
7
  module Lutaml
8
8
  class LutamlEaDiagramBlockMacro < ::Asciidoctor::Extensions::BlockMacroProcessor
9
9
  include LutamlDiagramBase
10
+ include LutamlEaXmiBase
10
11
 
11
12
  use_dsl
12
13
  named :lutaml_ea_diagram
13
14
 
14
15
  def process(parent, _target, attrs)
15
- orig_doc = get_original_document(parent)
16
- diagram = fetch_diagram_by_name(orig_doc, attrs["name"])
16
+ orig_doc = get_original_document(parent, attrs["index"])
17
+ diagram = fetch_diagram_by_name(orig_doc, attrs)
17
18
  return if diagram.nil?
18
19
 
19
20
  through_attrs = generate_attrs(attrs)
@@ -26,13 +27,43 @@ module Metanorma
26
27
 
27
28
  private
28
29
 
29
- def get_original_document(parent)
30
- doc = parent.document.attributes["lutaml_xmi_cache"].values.first
30
+ def parse_result_document(full_path, guidance = nil)
31
+ ::Lutaml::XMI::Parsers::XML.serialize_xmi_to_liquid(
32
+ File.new(full_path, encoding: "UTF-8"),
33
+ guidance,
34
+ )
35
+ end
36
+
37
+ def get_original_document(parent, index = nil)
38
+ path = get_path_from_index(parent, index) if index
39
+
40
+ if index && path
41
+ doc = lutaml_document_from_file_or_cache(parent.document, path, {})
42
+ end
43
+
44
+ doc ||= parent.document.attributes["lutaml_xmi_cache"].values.first
31
45
  return doc if doc.instance_of?(::Lutaml::XMI::RootDrop)
32
46
 
33
47
  doc.original_document
34
48
  end
35
49
 
50
+ def get_path_from_index(parent, index_name) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
51
+ lutaml_xmi_index = parent.document
52
+ .attributes["lutaml_xmi_index"][index_name]
53
+
54
+ if lutaml_xmi_index.nil? || lutaml_xmi_index[:path].nil?
55
+ ::Metanorma::Util.log(
56
+ "[metanorma-plugin-lutaml] lutaml_xmi_index error: " \
57
+ "XMI index #{index_name} path not found!",
58
+ :error,
59
+ )
60
+
61
+ return nil
62
+ end
63
+
64
+ lutaml_xmi_index[:path]
65
+ end
66
+
36
67
  def img_src_path(document, attrs, diagram)
37
68
  base_path = attrs["base_path"]
38
69
  format = attrs["format"] || "png"
@@ -41,19 +72,30 @@ module Metanorma
41
72
  "#{img_path}/#{diagram.xmi_id}.#{format}"
42
73
  end
43
74
 
44
- def fetch_diagram_by_name(orig_doc, name)
75
+ def fetch_diagram_by_name(orig_doc, attrs)
76
+ name = attrs["name"]
77
+ package_name = attrs["package"]
45
78
  found_diagrams = []
46
- loop_sub_packages(orig_doc.packages.first, name, found_diagrams)
79
+
80
+ loop_sub_packages(
81
+ orig_doc.packages.first, name, found_diagrams, package_name
82
+ )
83
+
47
84
  found_diagrams.first
48
85
  end
49
86
 
50
- def loop_sub_packages(package, name, found_diagrams)
87
+ def loop_sub_packages(package, name, found_diagrams, package_name) # rubocop:disable Metrics/CyclomaticComplexity
51
88
  found_diagram = package.diagrams.find { |diag| diag.name == name }
52
89
 
90
+ if found_diagram && package_name &&
91
+ found_diagram.package_name != package_name
92
+ found_diagram = nil
93
+ end
94
+
53
95
  found_diagrams << found_diagram if found_diagram
54
96
 
55
97
  package.packages.each do |sub_package|
56
- loop_sub_packages(sub_package, name, found_diagrams)
98
+ loop_sub_packages(sub_package, name, found_diagrams, package_name)
57
99
  end
58
100
  end
59
101
  end
@@ -27,6 +27,7 @@ module Metanorma
27
27
  SUPPORTED_NESTED_MACRO = %w[
28
28
  before diagram_include_block after include_block package_text
29
29
  ].freeze
30
+ XMI_INDEX_REGEXP = /^:lutaml-xmi-index:(?<index_name>.+?);(?<index_path>.+?);?(\s*config=(?<config_path>.+))?$/.freeze # rubocop:disable Lint/MixedRegexpCaptureTypes,Layout/LineLength
30
31
 
31
32
  # search document for block `lutaml_ea_xmi`
32
33
  # or `lutaml_uml_datamodel_description`
@@ -92,16 +93,38 @@ module Metanorma
92
93
  self.class.const_get(:MACRO_REGEXP)
93
94
  end
94
95
 
95
- def process_text_blocks(document, input_lines) # rubocop:disable Metrics/MethodLength
96
+ def process_xmi_index_lines(document, line)
97
+ block_match = line.match(XMI_INDEX_REGEXP)
98
+
99
+ return if block_match.nil?
100
+
101
+ name = block_match[:index_name]&.strip
102
+ path = block_match[:index_path]&.strip
103
+ config = block_match[:config_path]&.strip
104
+
105
+ document.attributes["lutaml_xmi_index"] ||= {}
106
+ document.attributes["lutaml_xmi_index"][name] = {
107
+ path: path,
108
+ config: config,
109
+ }
110
+ end
111
+
112
+ def process_text_blocks(document, input_lines) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
96
113
  line = input_lines.next
114
+ process_xmi_index_lines(document, line)
97
115
  block_match = line.match(get_macro_regexp)
98
116
 
99
117
  return [line] if block_match.nil?
100
118
 
101
- yaml_config = parse_yaml_config_file(document, block_match[2])
102
- lutaml_document = lutaml_document_from_file_or_cache(document,
103
- block_match[1],
104
- yaml_config)
119
+ config_yaml_path = block_match[2]&.strip
120
+ xmi_or_index = block_match[1]&.strip
121
+
122
+ lutaml_document, yaml_config = load_lutaml_doc_and_config(
123
+ document,
124
+ xmi_or_index,
125
+ config_yaml_path,
126
+ )
127
+
105
128
  fill_in_diagrams_attributes(document, lutaml_document)
106
129
  model_representation(
107
130
  lutaml_document, document,
@@ -110,6 +133,35 @@ module Metanorma
110
133
  )
111
134
  end
112
135
 
136
+ def load_lutaml_doc_and_config(document, xmi_or_index, config_yaml_path)
137
+ index = xmi_or_index.match(/index=(.*)/)
138
+
139
+ if index
140
+ # load lutaml index
141
+ index_name = index[1]
142
+
143
+ if document.attributes["lutaml_xmi_index"][index_name].nil? ||
144
+ document.attributes["lutaml_xmi_index"][index_name][:path].nil?
145
+ ::Metanorma::Util.log(
146
+ "[metanorma-plugin-lutaml] lutaml_xmi_index error: " \
147
+ "XMI index #{index_name} path not found!",
148
+ :error,
149
+ )
150
+ end
151
+
152
+ xmi_or_index = document
153
+ .attributes["lutaml_xmi_index"][index_name][:path]
154
+ config_yaml_path = document
155
+ .attributes["lutaml_xmi_index"][index_name][:config]
156
+ end
157
+
158
+ yaml_config = parse_yaml_config_file(document, config_yaml_path)
159
+ lutaml_document = lutaml_document_from_file_or_cache(document,
160
+ xmi_or_index,
161
+ yaml_config)
162
+ [lutaml_document, yaml_config]
163
+ end
164
+
113
165
  def get_original_document(wrapper)
114
166
  doc = wrapper
115
167
  return doc if doc.instance_of?(::Lutaml::XMI::RootDrop)
@@ -4,7 +4,12 @@ require "expressir/express/cache"
4
4
  require "metanorma/plugin/lutaml/liquid/custom_filters"
5
5
  require "metanorma/plugin/lutaml/liquid/multiply_local_file_system"
6
6
 
7
- ::Liquid::Template.register_filter(Metanorma::Plugin::Lutaml::Liquid::CustomFilters)
7
+ liquid_klass = if Object.const_defined?("Liquid::Environment")
8
+ Object.const_get("Liquid::Environment").default
9
+ else
10
+ Object.const_get("Liquid::Template")
11
+ end
12
+ liquid_klass.register_filter(Metanorma::Plugin::Lutaml::Liquid::CustomFilters)
8
13
 
9
14
  module Metanorma
10
15
  module Plugin
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.16".freeze
4
+ VERSION = "0.7.17".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-plugin-lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.16
4
+ version: 0.7.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-21 00:00:00.000000000 Z
11
+ date: 2025-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -354,7 +354,7 @@ homepage: https://github.com/metanorma/metanorma-plugin-lutaml
354
354
  licenses:
355
355
  - BSD-2-Clause
356
356
  metadata: {}
357
- post_install_message:
357
+ post_install_message:
358
358
  rdoc_options: []
359
359
  require_paths:
360
360
  - lib
@@ -370,7 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
370
370
  version: '0'
371
371
  requirements: []
372
372
  rubygems_version: 3.3.27
373
- signing_key:
373
+ signing_key:
374
374
  specification_version: 4
375
375
  summary: Metanorma plugin for LutaML
376
376
  test_files: []