metanorma-plugin-lutaml 0.7.34 → 0.7.35

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdcd6f308c7b6b9aedf946aaf6c83524cc53fe0d861376b2f27488bdc66f03ea
4
- data.tar.gz: 950763731a5d2712b15ae1f98fd06f173ffbab4e520243a8474ef652839455b5
3
+ metadata.gz: 0bfc071fedc2ba0801f8c50024ffd3e4370b356b0d78991cb9ae776b749ee4fc
4
+ data.tar.gz: 1badb8034821908be57039d87755a3937a8b93bc63c22f9b99d87344c57a4ed9
5
5
  SHA512:
6
- metadata.gz: c7f843aa5286d1b952437b330749ade1854e510a33f2ec100e7a384c3049838f60fb099339c23c66ef54cad12c862ca29c7e5138eca3a8306ed326ba9e55e615
7
- data.tar.gz: fbb5cbe113944fb2106143b8ad653dd39daca164df59b99b2564292132cd3b29c634c939589c4ce8de303aad30d9316b9e943ef6c3b90d3a71ff3258b60745fd
6
+ metadata.gz: ed2e7d2becf9296bff55b12a2c29aae7d7875ab4b1972ec76b6aa364aefb5b836bbc80fe1e201bb6f5eec3347b530c555cc8e9c70f7a6ed7e6bd5ef4e649a2fe
7
+ data.tar.gz: 2632e92cc22255166f2e32fb8492244f75b85582dc35919ac0deff75c360a4f6d5316de2cb68f9b683505dae9034c2d029b37f87cb730c6c6327a0407b5a6f06
@@ -12,7 +12,7 @@ Enterprise Architect XMI files.
12
12
 
13
13
  === Document attribute `:lutaml-xmi-index:`
14
14
 
15
- This attribute allows specifying one or more XMI files to defined names
15
+ This attribute allows specifying one or more XMI files to define names
16
16
  for later use with `lutaml_ea_*` commands.
17
17
 
18
18
  Syntax:
@@ -56,10 +56,10 @@ The command `lutaml_ea_diagram` will load the XMI file from the path
56
56
  ====
57
57
 
58
58
 
59
- === Rendering a Enterprise Architect diagram from XMI: `lutaml_ea_diagram`
59
+ === Rendering an Enterprise Architect diagram from XMI: `lutaml_ea_diagram`
60
60
 
61
- This command allows to quickly render a LutaML diagram as an image file by
62
- specifying the name of diagram.
61
+ This command allows you to quickly render a LutaML diagram as an image file by
62
+ specifying the name of the diagram.
63
63
 
64
64
  Syntax:
65
65
 
@@ -110,7 +110,7 @@ where the EA images exported with the XMI file are at `/path/to/xmi-images`.
110
110
  lutaml_ea_diagram::[name="DiagramName",package="PackageA",base_path="/path/to/xmi-images"]
111
111
  ----
112
112
 
113
- The search wil be restricted to the diagrams named `DiagramName` in the
113
+ The search will be restricted to the diagrams named `DiagramName` in the
114
114
  `PackageA` package.
115
115
  ====
116
116
 
@@ -135,7 +135,7 @@ the XMI file defined in the index `index_name`.
135
135
 
136
136
  === Generating a class definition table for a class: `lutaml_klass_table`
137
137
 
138
- This command allows to render a LutaML table of a class by using Liquid Drop.
138
+ This command allows you to render a LutaML table of a class by using Liquid Drop.
139
139
 
140
140
  The table will show:
141
141
 
@@ -153,27 +153,27 @@ lutaml_klass_table::/path/to/example.xmi[name="NameOfClass",template="/path/to/t
153
153
 
154
154
  The command accepts the options listed below:
155
155
 
156
- * `/path/to/example.xmi` specifies the path of xmi file.
156
+ * `/path/to/example.xmi` specifies the path of the XMI file.
157
157
 
158
158
  * `name` option only, `name` option with `package` option or `path` option.
159
159
  One of 3 forms of options can be used to specify the name of the class.
160
160
 
161
161
  ** `name="NameOfClass"` specifies the name of the `class`.
162
162
  (e.g. `name="Building"`)
163
- If there are multiple classes with the same name, other form of options
163
+ If there are multiple classes with the same name, other forms of options
164
164
  are recommended to specify the class.
165
165
 
166
- ** `package="NameOfPackage"name="NameOfClass"` specifies the name of the
166
+ ** `package="NameOfPackage",name="NameOfClass"` specifies the name of the
167
167
  `class` (specified by `name` option) inside the `package`
168
168
  (specified by `package` option).
169
169
  The `package` option must be used with the `name` option.
170
170
  (e.g. `package="uro",name="_BoundarySurface"`)
171
171
 
172
172
  ** `path="PathOfClass"` specifies the `absolute` path of the `class`
173
- which is started with `::`
173
+ which starts with `::`
174
174
  (e.g. `path="::EA_Model::Conceptual Models::i-UR::Urban Planning ADE 3.
175
175
  1::uro::_BoundarySurface"`)
176
- or `relative` path of the `class` which is not started with `::`
176
+ or `relative` path of the `class` which does not start with `::`
177
177
  (e.g. `path="uro::_BoundarySurface"`).
178
178
  The last part of the path separated by `::` is the name of the `class`.
179
179
  The other parts of the path are the names of the `packages`.
@@ -208,19 +208,50 @@ under `classes`. Then define which `attributes` you want to add guidance by the
208
208
  guidance in `guidance`.
209
209
 
210
210
 
211
+ === Generating a definition table for an enumeration: `lutaml_enum_table`
212
+
213
+ This command allows you to render a LutaML table of a class by using Liquid Drop.
214
+
215
+ The table will show:
216
+
217
+ * Enumeration Name
218
+ * Enumeration Definition
219
+ * Subtype of superclass
220
+ * Enumeration Stereotype
221
+ * Enumeration Values
222
+ ** Code
223
+ ** Value
224
+ ** Definition
225
+
226
+ [source,adoc]
227
+ ----
228
+ lutaml_enum_table::/path/to/example.xmi[name="NameOfEnum",template="/path/to/templates/_my_enum_table.liquid"]
229
+ ----
230
+
231
+ The command accepts the options listed below:
232
+
233
+ * `/path/to/example.xmi` specifies the path of the XMI file.
234
+
235
+ * `name` of the name of the enumeration.
236
+
237
+ * `template="/path/to/templates/_my_enum_table.liquid"` specifies the path of
238
+ the liquid template. (Optional)
239
+ By default, it will look for the template `_enum_table.liquid` defined in
240
+ `lib/metanorma/plugin/lutaml/templates`. This template can be customized by
241
+ changing the template path in the `template` option.
211
242
 
212
243
 
213
244
  === Usage of `lutaml_ea_xmi` command
214
245
 
215
- The `lutaml_ea_xmi` command supersedes the `lutaml_uml_datamodel_description`
216
- command which it is functionally equivalent to.
246
+ The `lutaml_ea_xmi` command performs the same function as the
247
+ `lutaml_uml_datamodel_description` command starting from version 0.7.21.
217
248
 
218
- This command renders data model packages and its dependent objects for supplied
249
+ This command renders data model packages and their dependent objects for the supplied
219
250
  XMI file, by using Liquid Drop objects.
220
251
 
221
252
  NOTE: The performance of `lutaml_ea_xmi` exceeds
222
- `lutaml_uml_datamodel_description` by 10~20 times (Tested with a 10.6MB XMI file
223
- with 120,000+ lines).
253
+ `lutaml_uml_datamodel_description` by 10~20 times when tested with a 10.6MB XMI
254
+ file with 120,000+ lines using version 0.7.20 of the plugin.
224
255
 
225
256
  NOTE: To migrate to this command from `lutaml_uml_datamodel_description`, just
226
257
  replace the command `lutaml_uml_datamodel_description` by `lutaml_ea_xmi`.
@@ -242,7 +273,7 @@ By:
242
273
  ----
243
274
 
244
275
  You can define guidance in the configuration file as well. The configuration
245
- file will looks like:
276
+ file will look like:
246
277
 
247
278
  [source,yaml]
248
279
  ----
@@ -271,7 +302,7 @@ under `classes`. Then define which `attributes` you want to add guidance by the
271
302
  `name`. Set `used` to show the attribute is used or not. Drop the message of
272
303
  guidance in `guidance`.
273
304
 
274
- The `name` of class can be defined in the following ways:
305
+ The `name` of the class can be defined in the following ways:
275
306
 
276
307
  * `name: "NameOfClass"` specifies the name of the `class`.
277
308
  (e.g. `name: "Building"`)
@@ -285,8 +316,8 @@ The `name` of class can be defined in the following ways:
285
316
 
286
317
  === Usage of `lutaml_uml_datamodel_description` command
287
318
 
288
- This command allows to quickly render data model packages and its dependent
289
- objects for supplied XMI file.
319
+ This command allows you to quickly render data model packages and their dependent
320
+ objects for the supplied XMI file.
290
321
 
291
322
  Given an Enterprise Architect `example.xmi` file with 2 packages:
292
323
 
@@ -346,17 +377,17 @@ Where:
346
377
 
347
378
  * `path/to/example.xmi` - required, path to the XMI file to render
348
379
 
349
- * `[.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 `....`)
380
+ * `[.before]` - block text that adds additional text before the rendered output, can be used only once, additional occurrences of the command will overwrite text, note that `literal` block style must be used there (e.g. `....`)
350
381
 
351
- * `[.after]` - block text that adds additional text after the rendered output, can be used only once, additional occurrences of command will overwrite text
382
+ * `[.after]` - block text that adds additional text after the rendered output, can be used only once, additional occurrences of the command will overwrite text
352
383
 
353
- * `[.after, package="Another"]` - block text to be inserted before(after in case of `.before` name) the package
384
+ * `[.after, package="Another"]` - block text to be inserted after the package (before in case of `.before` name)
354
385
 
355
- * `[.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.
386
+ * `[.package_text, position="after", package="Another"]` - include custom adoc code into the package rendered body, `position` is a required attribute which tells where to insert the code.
356
387
 
357
- * `[.package_text, package="Another"]` - same as above, but include block will be included only for supplied package name
388
+ * `[.package_text, package="Another"]` - same as above, but the include block will be included only for the supplied package name
358
389
 
359
- * `[.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.
390
+ * `[.diagram_include_block]` - block text to automatically include diagram images. Attribute `base_path` is a required attribute to supply the path prefix where to look for a diagram image. `format` is an optional attribute that tells what file extension to use when including the diagram file.
360
391
  +
361
392
  The logic is as follows:
362
393
  [source,adoc]
@@ -372,16 +403,16 @@ image::{{ image_base_path }}/{{ diagram.xmi_id }}.{{ format | default: 'png' }}[
372
403
  {% endfor %}
373
404
  ----
374
405
 
375
- 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.
406
+ For instance, the script will take package diagrams supplied in the XMI file and will try to include `image` with the name equal to the diagram's 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.
376
407
 
377
- * `[.diagram_include_block, package="Another"]` - same as above, but diagram will be included only for supplied package name
408
+ * `[.diagram_include_block, package="Another"]` - same as above, but the diagram will be included only for the supplied package name
378
409
 
379
- * `[.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`.
410
+ * `[.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 the path prefix where to look for file to include. The command will look for a file called `base_path` + `/` `_package_name`(downcase, replace : -> '', ' ' -> '_') + `.adoc`[`.liquid`], e.g. for package 'My Package name' and `base_path` eq to `my/path`, the command will look for the following file path: `my/path/_my_package_name.adoc`.
380
411
 
381
- * `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but include block will be included only for supplied package name
412
+ * `[.include_block, package="Another", base_path="spec/fixtures"]` - same as above, but the include block will be included only for the supplied package name
382
413
 
383
414
 
384
- 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
415
+ NOTE: .after, .before, package_text and include_block commands all can be used with additional option - `liquid`, if this option is supplied then the code inside block will be interpolated in liquid context
385
416
 
386
417
 
387
418
  === Referencing objects generated by LutaML
@@ -410,7 +441,7 @@ This is lutaml_table::[package="Wrapper root package", enum="my name"] enumerati
410
441
  This is lutaml_table::[package="Wrapper root package", data_type="my name"] data type
411
442
  ----
412
443
 
413
- 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.
444
+ This code will be transformed into `<<figure-{diagram.xmi_id}>>` and will point to diagram figure. One can only use this command when the document has rendered `lutaml_uml_datamodel_description` command as it needs diagram lookup table in order to reference package diagram.
414
445
 
415
446
  Will produce this output:
416
447
 
@@ -514,6 +545,8 @@ packages:
514
545
  - skip: four
515
546
  render_style: entity_list | data_dictionary | default
516
547
  section_depth: 2
548
+ template_path: "path/to/custom/liquid/templates"
549
+ skip_unrecognized_connector: true
517
550
  ea_extension:
518
551
  - "CityGML_MDG_Technology.xml"
519
552
  - "xmi_definition_for_some_standard.xml"
@@ -559,6 +592,32 @@ equal to 2, root package will be `one-1`.
559
592
  ]
560
593
  ----
561
594
 
595
+ * `template_path` - optional, path to custom Liquid templates directory for
596
+ rendering the output. When specified, the processor will use custom templates
597
+ from this directory instead of the default built-in templates. This allows for
598
+ complete customization of the rendered output format and structure.
599
+
600
+ * `skip_unrecognized_connector` - optional, boolean flag that shows in liquid
601
+ templates as context variable `context.skip_unrecognized_connector`, which
602
+ allows to control whether the associations with unrecognized connectors should
603
+ be included in the output. By making use of this context variable and
604
+ `association.connector.recognized?` in the liquid templates, you can
605
+ conditionally skip rendering of associations that have unrecognized connectors.
606
+ +
607
+ EXAMPLE: Given that `associations` is a list of association objects of a class
608
+ named `klass`, if you want to skip rendering of associations that have
609
+ unrecognized connectors when `skip_unrecognized_connector` is set to `true`,
610
+ then in the liquid template you can use:
611
+ +
612
+ [source,liquid]
613
+ ----
614
+ {% for assoc in klass.associations %}
615
+ {% if context.skip_unrecognized_connector != true or assoc.connector.recognized? == true %}
616
+ ...do something with association that has recognized connector...
617
+ {% endif %}
618
+ {% endfor %}
619
+ ----
620
+
562
621
  * `ea_extension` - optional, list of EA extensions to load. Some XMI files may
563
622
  contain elements that cannot be resolved by default, for example CityGML
564
623
  elements. You can use `ea_extension` to load the definition of these elements
@@ -579,5 +638,5 @@ Usage with command:
579
638
 
580
639
  The processor will read the supplied YAML config file (`path/to/config.yml`),
581
640
  and iterate through packages according to the order supplied in the file. All
582
- packages that matches `skip` in the YAML config file will be skipped during
641
+ packages that match `skip` in the YAML config file will be skipped during
583
642
  render.
@@ -0,0 +1,24 @@
1
+ {% capture enum_stereotype -%}&#x00AB;{{ enum.stereotype }}&#x00BB;{%- endcapture -%}
2
+ {%- if enum_stereotype == "&#x00AB;&#x00BB;" -%}
3
+ {%- assign enum_stereotype = " " -%}
4
+ {%- endif %}
5
+
6
+ [cols="29,195,535"]
7
+ |===
8
+ 3+^h| Enumeration: {{ enum.name }}
9
+ 3+| Definition: {{ enum.definition }}
10
+ 3+| Subtype of: {{ enum.upper_packaged_element }}
11
+ 3+| Stereotypes: {{ enum_stereotype }}
12
+
13
+ {% if enum.values.size > 0 %}
14
+ {% assign code_num = 0 %}
15
+
16
+ h| Code h| Value h| Definition
17
+
18
+ {% for value in enum.values %}
19
+ {% assign code_num = code_num | plus: 1 %}
20
+ | {{ code_num }} | {{ value.name }} | {{ value.definition }}
21
+ {% endfor %}
22
+
23
+ {% endif %}
24
+ |===
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module Plugin
5
+ module Lutaml
6
+ class LutamlEnumTableBlockMacro <
7
+ ::Asciidoctor::Extensions::BlockMacroProcessor
8
+ include LutamlEaXmiBase
9
+
10
+ DEFAULT_TEMPLATE = File.join(
11
+ Gem::Specification.find_by_name("metanorma-plugin-lutaml").gem_dir,
12
+ "lib", "metanorma", "plugin", "lutaml", "liquid_templates",
13
+ "_enum_table.liquid"
14
+ )
15
+
16
+ use_dsl
17
+ named :lutaml_enum_table
18
+
19
+ def process(parent, target, attrs) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
20
+ xmi_path = get_xmi_path(parent, target, attrs)
21
+
22
+ if attrs["template"]
23
+ attrs["template"] = Utils.relative_file_path(
24
+ parent.document, attrs["template"]
25
+ )
26
+ end
27
+
28
+ path = if !attrs["path"].nil?
29
+ attrs["path"]
30
+ elsif !attrs["package"].nil? && !attrs["name"].nil?
31
+ "#{attrs['package']}::#{attrs['name']}"
32
+ else
33
+ attrs["name"]
34
+ end
35
+
36
+ enum = ::Lutaml::XMI::Parsers::XML.serialize_enumeration_by_name(
37
+ xmi_path, path
38
+ )
39
+
40
+ render(enum, parent, attrs)
41
+ end
42
+
43
+ private
44
+
45
+ def render(enum, parent, attrs)
46
+ rendered_table = render_table(enum, parent, attrs)
47
+
48
+ block = create_open_block(parent, "", attrs)
49
+ parse_content(block, rendered_table, attrs)
50
+ end
51
+
52
+ def render_table(enum, parent, attrs)
53
+ table_tmpl = get_template(parent.document, attrs)
54
+ table_tmpl.assigns["enum"] = enum
55
+ table_tmpl.render
56
+ end
57
+
58
+ def get_template(document, attrs)
59
+ template = DEFAULT_TEMPLATE
60
+ if attrs["template"]
61
+ template = attrs["template"]
62
+ end
63
+
64
+ rel_tmpl_path = Utils.relative_file_path(
65
+ document, template
66
+ )
67
+
68
+ ::Liquid::Template.parse(File.read(rel_tmpl_path))
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.34".freeze
4
+ VERSION = "0.7.35".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -15,6 +15,7 @@ require "metanorma/plugin/lutaml/lutaml_gml_dictionary_base"
15
15
  require "metanorma/plugin/lutaml/lutaml_gml_dictionary_block_macro"
16
16
  require "metanorma/plugin/lutaml/lutaml_gml_dictionary_block"
17
17
  require "metanorma/plugin/lutaml/lutaml_klass_table_block_macro"
18
+ require "metanorma/plugin/lutaml/lutaml_enum_table_block_macro"
18
19
 
19
20
  module Metanorma
20
21
  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.7.34
4
+ version: 0.7.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-02 00:00:00.000000000 Z
11
+ date: 2025-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -170,6 +170,7 @@ files:
170
170
  - lib/metanorma/plugin/lutaml/liquid_drops/gml_dictionary_drop.rb
171
171
  - lib/metanorma/plugin/lutaml/liquid_drops/gml_dictionary_entry_drop.rb
172
172
  - lib/metanorma/plugin/lutaml/liquid_templates/_diagrams_block.liquid
173
+ - lib/metanorma/plugin/lutaml/liquid_templates/_enum_table.liquid
173
174
  - lib/metanorma/plugin/lutaml/liquid_templates/_klass_table.liquid
174
175
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages.liquid
175
176
  - lib/metanorma/plugin/lutaml/liquid_templates/_packages_class.liquid
@@ -187,6 +188,7 @@ files:
187
188
  - lib/metanorma/plugin/lutaml/lutaml_ea_diagram_block_macro.rb
188
189
  - lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb
189
190
  - lib/metanorma/plugin/lutaml/lutaml_ea_xmi_preprocessor.rb
191
+ - lib/metanorma/plugin/lutaml/lutaml_enum_table_block_macro.rb
190
192
  - lib/metanorma/plugin/lutaml/lutaml_figure_inline_macro.rb
191
193
  - lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_base.rb
192
194
  - lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_block.rb