metanorma-plugin-lutaml 0.4.4 → 0.4.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a510a5a23684dee91557fb6047267ca6ac87be25cbe11e0bcad8e4c0d0812b9
|
4
|
+
data.tar.gz: 5d6e5cfc99c66b42ed50b7f6c6b1346fd2887ee9bba4436cacd5fbc56121dde6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea2e863ee349fb9bc5e60c43802569b0592b3437f2aad58f5bdb5591ecd430388566aff7ad8ff6d6c187e64868df9f1f303917afa94e73396e5c6d6564d0571a
|
7
|
+
data.tar.gz: dc8d9a72fbea070f7aec02fa576c59859ce34abf6375e307ef18685cdbd70130edcc3958839e7b82e9e7155befc8b51657c685d5f42cef96e900de0fd4a50532
|
@@ -14,7 +14,7 @@ module Metanorma
|
|
14
14
|
# @example [lutaml_uml_attributes_table,path/to/lutaml,EntityName]
|
15
15
|
class LutamlUmlAttributesTablePreprocessor < Asciidoctor::Extensions::Preprocessor
|
16
16
|
MARCO_REGEXP =
|
17
|
-
/\[lutaml_uml_attributes_table,([^,]+),?(
|
17
|
+
/\[lutaml_uml_attributes_table,([^,]+),?([^,]+),?(.+?)?\]/
|
18
18
|
# search document for block `datamodel_attributes_table`
|
19
19
|
# read include derectives that goes after that in block and transform
|
20
20
|
# into yaml2text blocks
|
@@ -36,15 +36,16 @@ module Metanorma
|
|
36
36
|
input_lines.each_with_object([]) do |line, result|
|
37
37
|
if match = line.match(MARCO_REGEXP)
|
38
38
|
lutaml_path = match[1]
|
39
|
-
entity_name = match[
|
40
|
-
|
39
|
+
entity_name = match[2]
|
40
|
+
skip_headers = match[3]
|
41
|
+
result.push(*parse_marco(lutaml_path, entity_name, document, skip_headers))
|
41
42
|
else
|
42
43
|
result.push(line)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
|
-
def parse_marco(lutaml_path, entity_name, document)
|
48
|
+
def parse_marco(lutaml_path, entity_name, document, skip_headers)
|
48
49
|
lutaml_document = lutaml_document_from_file(document, lutaml_path)
|
49
50
|
.serialized_document
|
50
51
|
entities = [lutaml_document["classes"], lutaml_document["enums"]]
|
@@ -53,12 +54,12 @@ module Metanorma
|
|
53
54
|
entity_definition = entities.detect do |klass|
|
54
55
|
klass["name"] == entity_name.strip
|
55
56
|
end
|
56
|
-
model_representation(entity_definition, document)
|
57
|
+
model_representation(entity_definition, document, skip_headers)
|
57
58
|
end
|
58
59
|
|
59
|
-
def model_representation(entity_definition, document)
|
60
|
+
def model_representation(entity_definition, document, skip_headers)
|
60
61
|
render_result, errors = Utils.render_liquid_string(
|
61
|
-
template_string: table_template,
|
62
|
+
template_string: table_template(skip_headers),
|
62
63
|
context_items: entity_definition,
|
63
64
|
context_name: "definition",
|
64
65
|
document: document
|
@@ -68,9 +69,9 @@ module Metanorma
|
|
68
69
|
end
|
69
70
|
|
70
71
|
# rubocop:disable Layout/IndentHeredoc
|
71
|
-
def table_template
|
72
|
+
def table_template(skip_headers)
|
72
73
|
<<~TEMPLATE
|
73
|
-
=== {{ definition.name }}
|
74
|
+
#{"=== {{ definition.name }}" unless skip_headers}
|
74
75
|
{{ definition.definition }}
|
75
76
|
|
76
77
|
{% if definition.attributes %}
|