metanorma-plugin-lutaml 0.7.20 → 0.7.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +1 -150
- data/lib/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor.rb +6 -3
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- data/lib/metanorma-plugin-lutaml.rb +0 -2
- data/metanorma-plugin-lutaml.gemspec +1 -1
- metadata +6 -8
- data/lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb +0 -50
- data/lib/metanorma/plugin/lutaml/lutaml_uml_class_preprocessor.rb +0 -168
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aeee60e0c387e0cd418623ff3c351097286d574235e6846e107f89d044b4342
|
4
|
+
data.tar.gz: 5010ee69d52a4ba1d06169224c876734111e9d035aa510565593a67bb997b0f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0e6eade28bb226a39bb2af4adcf45aeb4ed5dbd61385224cfa4c74946990a25da00ce97083fca98903fcaeae4259a0ed20861b6372d81d128e9befa9f36a129
|
7
|
+
data.tar.gz: 762f6d288c6dad65aa3e9f73ba1c0185cb93c4af0308d8816f4c672f9d297d7ab764c32f3c6f6ed2b437bae3a5e355407267ac52447a7e6573e3eaaeb6387b50
|
data/README.adoc
CHANGED
@@ -295,7 +295,7 @@ via Liquid:
|
|
295
295
|
{% assign selected = repo.schemas | where: "selected" %}
|
296
296
|
... do things with `selected` ...
|
297
297
|
---
|
298
|
-
|
298
|
+
----
|
299
299
|
|
300
300
|
NOTE: This functionality is used in the ISO 10303 SRL to load the full schema
|
301
301
|
set at once but only render the selected schemas in individual documents.
|
@@ -374,155 +374,6 @@ diagram MyView {
|
|
374
374
|
....
|
375
375
|
----
|
376
376
|
|
377
|
-
=== Generating a UML class and attributes clause: `lutaml_uml_class`
|
378
|
-
|
379
|
-
This command allows rendering a definition clause for a UML class.
|
380
|
-
|
381
|
-
Given `example.lutaml` with this content:
|
382
|
-
|
383
|
-
[source,java]
|
384
|
-
----
|
385
|
-
class Register {
|
386
|
-
definition {
|
387
|
-
A register of information.
|
388
|
-
}
|
389
|
-
|
390
|
-
identifier: String[1] {
|
391
|
-
definition {
|
392
|
-
Unique identifier of the register.
|
393
|
-
}
|
394
|
-
}
|
395
|
-
|
396
|
-
concepts: Concept[0..*] {
|
397
|
-
definition {
|
398
|
-
Concepts.
|
399
|
-
}
|
400
|
-
}
|
401
|
-
}
|
402
|
-
----
|
403
|
-
|
404
|
-
The command:
|
405
|
-
|
406
|
-
[source,adoc]
|
407
|
-
----
|
408
|
-
[lutaml_uml_class,views/Register_Register.lutaml,Register]
|
409
|
-
----
|
410
|
-
|
411
|
-
Will produce this output:
|
412
|
-
|
413
|
-
____
|
414
|
-
== Register
|
415
|
-
|
416
|
-
A register of information.
|
417
|
-
|
418
|
-
=== Attributes
|
419
|
-
|
420
|
-
==== identifier
|
421
|
-
|
422
|
-
Unique identifier of the register.
|
423
|
-
|
424
|
-
.Specification of `Register.identifier`
|
425
|
-
|===
|
426
|
-
h|Value type and multiplicity | `String [1]`
|
427
|
-
|===
|
428
|
-
|
429
|
-
==== concepts
|
430
|
-
|
431
|
-
Concepts.
|
432
|
-
|
433
|
-
.Specification of `Register.concepts`
|
434
|
-
|===
|
435
|
-
h|Value type and multiplicity | `Concepts [0..*]`
|
436
|
-
|===
|
437
|
-
|
438
|
-
____
|
439
|
-
|
440
|
-
The command accepts two options:
|
441
|
-
|
442
|
-
`skip_headers=true`:: (or just `skip_headers`) The initial heading (the UML class name)
|
443
|
-
will not be generated. This is useful if additional content is to be supplied
|
444
|
-
to the clause, such as diagrams that are defined outside the UML model.
|
445
|
-
|
446
|
-
`depth={n}`:: (default: `2`) This determines the depth of the generated headings.
|
447
|
-
A depth of `2` means the initial heading will have 2 equal signs, and so forth.
|
448
|
-
The heading depth of the attributes are in relation to the initial depth, so
|
449
|
-
a depth of `2` will have the "Attributes" section at depth `3`.
|
450
|
-
|
451
|
-
|
452
|
-
=== Generating a UML attributes table: `lutaml_uml_attributes_table`
|
453
|
-
|
454
|
-
This command allows rendering definition tables for a UML model.
|
455
|
-
|
456
|
-
Given `example.lutaml` file with the content:
|
457
|
-
|
458
|
-
[source,java]
|
459
|
-
----
|
460
|
-
diagram MyView {
|
461
|
-
title "my diagram"
|
462
|
-
|
463
|
-
enum AddressClassProfile {
|
464
|
-
imlicistAttributeProfile: CharacterString [0..1] {
|
465
|
-
definition
|
466
|
-
this is multiline with `ascidoc`
|
467
|
-
end definition
|
468
|
-
}
|
469
|
-
}
|
470
|
-
|
471
|
-
class AttributeProfile {
|
472
|
-
+addressClassProfile: CharacterString [0..1]
|
473
|
-
imlicistAttributeProfile: CharacterString [0..1] {
|
474
|
-
definition this is attribute definition
|
475
|
-
}
|
476
|
-
}
|
477
|
-
}
|
478
|
-
----
|
479
|
-
|
480
|
-
And the `lutaml_uml_attributes_table` command:
|
481
|
-
|
482
|
-
[source,adoc]
|
483
|
-
----
|
484
|
-
[lutaml_uml_attributes_table, example.lutaml, AttributeProfile]
|
485
|
-
----
|
486
|
-
|
487
|
-
Will produce this output:
|
488
|
-
|
489
|
-
____
|
490
|
-
=== AttributeProfile
|
491
|
-
|
492
|
-
.AttributeProfile attributes
|
493
|
-
|===
|
494
|
-
|Name |Definition |Mandatory/ Optional/ Conditional |Max Occur |Data Type
|
495
|
-
|
496
|
-
|addressClassProfile |TODO: enum's definition |M |1 | `CharacterString`
|
497
|
-
|
498
|
-
|imlicistAttributeProfile |this is attribute definition with multiply lines |M |1 | `CharacterString`
|
499
|
-
|
500
|
-
|===
|
501
|
-
____
|
502
|
-
|
503
|
-
|
504
|
-
In case of "enumeration" (AddressClassProfile) entity:
|
505
|
-
|
506
|
-
[source,adoc]
|
507
|
-
----
|
508
|
-
[lutaml_uml_attributes_table, example.lutaml, AddressClassProfile]
|
509
|
-
----
|
510
|
-
|
511
|
-
Will produce this output:
|
512
|
-
|
513
|
-
____
|
514
|
-
=== AddressClassProfile
|
515
|
-
|
516
|
-
.AddressClassProfile values
|
517
|
-
|===
|
518
|
-
|Name |Definition
|
519
|
-
|
520
|
-
|imlicistAttributeProfile |this is multiline with `asciidoc`
|
521
|
-
|
522
|
-
|===
|
523
|
-
____
|
524
|
-
|
525
|
-
|
526
377
|
== Usage with Enterprise Architect (UML in XMI)
|
527
378
|
|
528
379
|
=== General
|
@@ -14,7 +14,7 @@ module Metanorma
|
|
14
14
|
module Plugin
|
15
15
|
module Lutaml
|
16
16
|
# Macro for quick rendering of datamodel attributes/values table
|
17
|
-
#
|
17
|
+
# TODO: merge with lutaml_ea_xmi
|
18
18
|
class LutamlUmlDatamodelDescriptionPreprocessor <
|
19
19
|
::Asciidoctor::Extensions::Preprocessor
|
20
20
|
include LutamlEaXmiBase
|
@@ -24,8 +24,11 @@ module Metanorma
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
def parse_result_document(full_path,
|
28
|
-
::Lutaml::
|
27
|
+
def parse_result_document(full_path, guidance)
|
28
|
+
::Lutaml::XMI::Parsers::XML.serialize_xmi_to_liquid(
|
29
|
+
File.new(full_path, encoding: "UTF-8"),
|
30
|
+
guidance,
|
31
|
+
)
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
require "metanorma/plugin/lutaml/version"
|
2
2
|
require "metanorma/plugin/lutaml/lutaml_preprocessor"
|
3
|
-
require "metanorma/plugin/lutaml/lutaml_uml_class_preprocessor"
|
4
|
-
require "metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor"
|
5
3
|
require "metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor"
|
6
4
|
require "metanorma/plugin/lutaml/lutaml_ea_xmi_preprocessor"
|
7
5
|
require "metanorma/plugin/lutaml/lutaml_diagram_block"
|
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_development_dependency "debug"
|
37
37
|
spec.add_development_dependency "equivalent-xml"
|
38
|
-
spec.add_development_dependency "metanorma-standoc"
|
38
|
+
spec.add_development_dependency "metanorma-standoc", "~> 3.0"
|
39
39
|
spec.add_development_dependency "rake", "~> 13"
|
40
40
|
spec.add_development_dependency "rspec", "~> 3.6"
|
41
41
|
spec.add_development_dependency "rspec-html-matchers"
|
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.
|
4
|
+
version: 0.7.21
|
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-02-
|
11
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -140,16 +140,16 @@ dependencies:
|
|
140
140
|
name: metanorma-standoc
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
145
|
+
version: '3.0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
152
|
+
version: '3.0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -343,8 +343,6 @@ files:
|
|
343
343
|
- lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb
|
344
344
|
- lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
|
345
345
|
- lib/metanorma/plugin/lutaml/lutaml_table_inline_macro.rb
|
346
|
-
- lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb
|
347
|
-
- lib/metanorma/plugin/lutaml/lutaml_uml_class_preprocessor.rb
|
348
346
|
- lib/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor.rb
|
349
347
|
- lib/metanorma/plugin/lutaml/utils.rb
|
350
348
|
- lib/metanorma/plugin/lutaml/version.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "metanorma/plugin/lutaml/asciidoctor/preprocessor"
|
4
|
-
|
5
|
-
module Metanorma
|
6
|
-
module Plugin
|
7
|
-
module Lutaml
|
8
|
-
# Macro for quick rendering of datamodel attributes/values table
|
9
|
-
# @example [lutaml_uml_attributes_table,path/to/lutaml,EntityName]
|
10
|
-
class LutamlUmlAttributesTablePreprocessor < LutamlUmlClassPreprocessor
|
11
|
-
MACRO_REGEXP =
|
12
|
-
/\[lutaml_uml_attributes_table,([^,]+),?([^,]+),?(.+?)?\]/.freeze
|
13
|
-
|
14
|
-
# rubocop:disable Layout/IndentHeredoc
|
15
|
-
def template(options)
|
16
|
-
skip_headers = options[:skip_headers]
|
17
|
-
|
18
|
-
<<~TEMPLATE
|
19
|
-
#{'=== {{ definition.name }}' unless skip_headers}
|
20
|
-
{{ definition.definition }}
|
21
|
-
|
22
|
-
{% if definition.attributes %}
|
23
|
-
{% if definition.keyword == 'enumeration' %}
|
24
|
-
.{{ definition.name }} values
|
25
|
-
|===
|
26
|
-
|Name |Definition
|
27
|
-
|
28
|
-
{% for item in definition.attributes %}
|
29
|
-
|{{ item.name }} |{{ item.definition }}
|
30
|
-
{% endfor %}
|
31
|
-
|===
|
32
|
-
{% else %}
|
33
|
-
.{{ definition.name }} attributes
|
34
|
-
|===
|
35
|
-
|Name |Definition |Mandatory / Optional / Conditional |Max Occur |Data Type
|
36
|
-
|
37
|
-
{% for item in definition.attributes %}
|
38
|
-
|{{ item.name }} |{% if item.definition %}{{ item.definition }}{% endif %} |{% if item.cardinality.min == "0" %}O{% else %}M{% endif %} |{% if item.cardinality.max == "*" %}N{% else %}1{% endif %} |{% if item.origin %}<<{{ item.origin }}>>{% endif %} `{{ item.type }}`
|
39
|
-
{% endfor %}
|
40
|
-
|===
|
41
|
-
{% endif %}
|
42
|
-
{% endif %}
|
43
|
-
|
44
|
-
TEMPLATE
|
45
|
-
end
|
46
|
-
# rubocop:enable Layout/IndentHeredoc
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "liquid"
|
4
|
-
require "asciidoctor"
|
5
|
-
require "asciidoctor/reader"
|
6
|
-
require "lutaml"
|
7
|
-
require "lutaml/uml"
|
8
|
-
require "metanorma/plugin/lutaml/utils"
|
9
|
-
require "metanorma/plugin/lutaml/asciidoctor/preprocessor"
|
10
|
-
|
11
|
-
module Metanorma
|
12
|
-
module Plugin
|
13
|
-
module Lutaml
|
14
|
-
# Macro for quick rendering of datamodel attributes/values table
|
15
|
-
# @example [lutaml_uml_class,path/to/lutaml,EntityName]
|
16
|
-
class LutamlUmlClassPreprocessor < ::Asciidoctor::Extensions::Preprocessor
|
17
|
-
MACRO_REGEXP =
|
18
|
-
/\[lutaml_uml_class,([^,]+),?([^,]+),?(.+?)?\]/.freeze
|
19
|
-
|
20
|
-
def get_macro_regexp
|
21
|
-
self.class.const_get(:MACRO_REGEXP)
|
22
|
-
end
|
23
|
-
|
24
|
-
# search document for block `datamodel_attributes_table`
|
25
|
-
# read include derectives that goes after that in block and transform
|
26
|
-
# into yaml2text blocks
|
27
|
-
def process(document, reader)
|
28
|
-
r = Asciidoctor::PreprocessorNoIfdefsReader.new document, reader.lines
|
29
|
-
input_lines = r.readlines.to_enum
|
30
|
-
Asciidoctor::PreprocessorNoIfdefsReader
|
31
|
-
.new(document, processed_lines(document, input_lines))
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def lutaml_document_from_file(document, file_path)
|
37
|
-
::Lutaml::Parser.parse(
|
38
|
-
File.new(
|
39
|
-
Utils.relative_file_path(document, file_path),
|
40
|
-
encoding: "UTF-8",
|
41
|
-
),
|
42
|
-
).first
|
43
|
-
end
|
44
|
-
|
45
|
-
DEFAULT_OPTIONS = { depth: 2 }.freeze
|
46
|
-
|
47
|
-
def parse_options_to_hash(options_string)
|
48
|
-
return DEFAULT_OPTIONS.dup if options_string.nil? ||
|
49
|
-
options_string.empty?
|
50
|
-
|
51
|
-
opts = options_string.split(",").inject({}) do |acc, pair|
|
52
|
-
key, value = pair.split("=")
|
53
|
-
key = key.to_sym
|
54
|
-
value = true if value.nil?
|
55
|
-
value = value.to_i if key == :depth
|
56
|
-
acc[key] = value if key
|
57
|
-
acc
|
58
|
-
end
|
59
|
-
|
60
|
-
DEFAULT_OPTIONS.dup.merge(opts)
|
61
|
-
end
|
62
|
-
|
63
|
-
def processed_lines(document, input_lines)
|
64
|
-
input_lines.each_with_object([]) do |line, result|
|
65
|
-
if match = line.match(get_macro_regexp)
|
66
|
-
lutaml_path = match[1]
|
67
|
-
entity_name = match[2]
|
68
|
-
options = parse_options_to_hash(match[3])
|
69
|
-
|
70
|
-
result.push(*parse_macro(lutaml_path, entity_name, document,
|
71
|
-
options))
|
72
|
-
else
|
73
|
-
result.push(line)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def parse_macro(lutaml_path, entity_name, document, options)
|
79
|
-
lutaml_document = lutaml_document_from_file(document, lutaml_path)
|
80
|
-
.serialized_document
|
81
|
-
entities = [lutaml_document["classes"], lutaml_document["enums"]]
|
82
|
-
.compact
|
83
|
-
.flatten
|
84
|
-
entity_definition = entities.detect do |klass|
|
85
|
-
klass["name"] == entity_name.strip
|
86
|
-
end
|
87
|
-
model_representation(entity_definition, document, options)
|
88
|
-
end
|
89
|
-
|
90
|
-
def model_representation(entity_definition, document, options)
|
91
|
-
render_result, errors = Utils.render_liquid_string(
|
92
|
-
template_string: template(options),
|
93
|
-
context_items: entity_definition,
|
94
|
-
context_name: "definition",
|
95
|
-
document: document,
|
96
|
-
)
|
97
|
-
Utils.notify_render_errors(document, errors)
|
98
|
-
render_result.split("\n")
|
99
|
-
end
|
100
|
-
|
101
|
-
def equalsigns(depth)
|
102
|
-
"=" * depth
|
103
|
-
end
|
104
|
-
|
105
|
-
# rubocop:disable Layout/IndentHeredoc
|
106
|
-
def template(options)
|
107
|
-
skip_headers = options[:skip_headers]
|
108
|
-
depth = options[:depth]
|
109
|
-
|
110
|
-
<<~TEMPLATE
|
111
|
-
{% if definition.keyword == 'enumeration' %}
|
112
|
-
#{"#{equalsigns(depth)} Enumeration: {{ definition.name }}" unless skip_headers}
|
113
|
-
{% else %}
|
114
|
-
#{"#{equalsigns(depth)} Class: {{ definition.name }}" unless skip_headers}
|
115
|
-
{% endif %}
|
116
|
-
|
117
|
-
#{equalsigns(depth + 1)} Description
|
118
|
-
|
119
|
-
{{ definition.definition }}
|
120
|
-
|
121
|
-
{% if definition.attributes %}
|
122
|
-
{% if definition.keyword == 'enumeration' %}
|
123
|
-
{% for item in definition.attributes %}
|
124
|
-
#{equalsigns(depth + 1)} Enumeration value: {{item.name}}
|
125
|
-
|
126
|
-
{% if item.definition %}
|
127
|
-
{{ item.definition }}
|
128
|
-
{% endif %}
|
129
|
-
|
130
|
-
{% endfor %}
|
131
|
-
|
132
|
-
{% else %}
|
133
|
-
|
134
|
-
{% for item in definition.attributes %}
|
135
|
-
#{equalsigns(depth + 1)} Attribute: {{item.name}}
|
136
|
-
|
137
|
-
{% if item.definition %}
|
138
|
-
{{ item.definition }}
|
139
|
-
{% endif %}
|
140
|
-
|
141
|
-
Value type and multiplicity:
|
142
|
-
{% if item.type -%}{{ item.type }}{% else -%}(no type specified){% endif %}
|
143
|
-
{% if item.cardinality.min -%}
|
144
|
-
{% if item.cardinality.max -%}
|
145
|
-
{blank}[{{item.cardinality.min}}..{{item.cardinality.max}}]
|
146
|
-
{% else -%}
|
147
|
-
{blank}[{{item.cardinality.min}}]
|
148
|
-
{% endif -%}
|
149
|
-
{% else -%}
|
150
|
-
(multiplicity unspecified)
|
151
|
-
{% endif %}
|
152
|
-
|
153
|
-
{% if item.origin %}
|
154
|
-
Origin: <<{{ item.origin }}>>
|
155
|
-
{% endif %}
|
156
|
-
|
157
|
-
{% endfor %}
|
158
|
-
|
159
|
-
{% endif %}
|
160
|
-
{% endif %}
|
161
|
-
|
162
|
-
TEMPLATE
|
163
|
-
end
|
164
|
-
# rubocop:enable Layout/IndentHeredoc
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|