metanorma-plugin-lutaml 0.7.72 → 0.7.74
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 +4 -4
- data/README.adoc +3 -0
- data/docs/usages/lutaml-jsonschema.adoc +77 -0
- data/docs/usages/lutaml-xsd.adoc +59 -0
- data/lib/metanorma/plugin/lutaml/base_preprocessor.rb +9 -2
- data/lib/metanorma/plugin/lutaml/cache_registry.rb +5 -0
- data/lib/metanorma/plugin/lutaml/express_remark_adapter.rb +37 -7
- data/lib/metanorma/plugin/lutaml/express_remark_figures.rb +194 -0
- data/lib/metanorma/plugin/lutaml/express_schema_listing.rb +65 -9
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_attribute.liquid +24 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_attribute_group.liquid +60 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_attribute_value_constraints.liquid +65 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_child_elements.liquid +34 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_complex_type.liquid +109 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_diagram.liquid +25 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_diagram_children.liquid +31 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_element.liquid +110 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xml_example_attribute.liquid +2 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xml_example_child.liquid +26 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xsd_ref.liquid +19 -0
- data/lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xsd_schema.liquid +32 -0
- data/lib/metanorma/plugin/lutaml/lutaml_jsonschema_preprocessor.rb +136 -0
- data/lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb +1 -0
- data/lib/metanorma/plugin/lutaml/lutaml_xsd_preprocessor.rb +33 -6
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- data/lib/metanorma-plugin-lutaml.rb +4 -0
- data/metanorma-plugin-lutaml.gemspec +1 -0
- metadata +37 -2
|
@@ -12,8 +12,18 @@ module Metanorma
|
|
|
12
12
|
# Two syntaxes are supported:
|
|
13
13
|
# Block: [lutaml_xsd, path, context, options] .... ----
|
|
14
14
|
# Direct: lutaml_xsd::path[context, template, options]
|
|
15
|
+
#
|
|
16
|
+
# The bundled default templates (liquid_templates/xsd) are always on
|
|
17
|
+
# the template search path, after the document directory and any
|
|
18
|
+
# `include_path`, so documents can override single partials. The
|
|
19
|
+
# direct syntax renders the default `xsd_schema` template when no
|
|
20
|
+
# template is given.
|
|
15
21
|
class LutamlXsdPreprocessor < BasePreprocessor
|
|
16
22
|
CACHE = CacheStore.new
|
|
23
|
+
DEFAULT_TEMPLATES_DIR = File.expand_path(
|
|
24
|
+
"liquid_templates/xsd", __dir__
|
|
25
|
+
).freeze
|
|
26
|
+
DEFAULT_TEMPLATE = "xsd_schema"
|
|
17
27
|
XSD_PREPROCESSOR_REGEX = %r{
|
|
18
28
|
^ # Start of line
|
|
19
29
|
\[ # Opening bracket
|
|
@@ -31,9 +41,10 @@ module Metanorma
|
|
|
31
41
|
lutaml_xsd:: # Macro prefix
|
|
32
42
|
(?<file_path>[^\[]+?) # XSD file path
|
|
33
43
|
\[ # Opening bracket
|
|
34
|
-
(?<context_name>[
|
|
35
|
-
|
|
36
|
-
(?<template>[^,\]]
|
|
44
|
+
(?<context_name>[^,\]]+) # Context name
|
|
45
|
+
(?:,\s* # Comma separator
|
|
46
|
+
(?<template>[^,\]=]+?))? # Optional template file path
|
|
47
|
+
\s* # Optional whitespace
|
|
37
48
|
(?<options>,[^\]]+)? # Optional options
|
|
38
49
|
\] # Closing bracket
|
|
39
50
|
\s*$ # End of line
|
|
@@ -59,6 +70,12 @@ module Metanorma
|
|
|
59
70
|
end
|
|
60
71
|
end
|
|
61
72
|
|
|
73
|
+
def build_file_system(document, options)
|
|
74
|
+
file_system = super
|
|
75
|
+
file_system.roots.push(DEFAULT_TEMPLATES_DIR)
|
|
76
|
+
file_system
|
|
77
|
+
end
|
|
78
|
+
|
|
62
79
|
def index_type_name
|
|
63
80
|
"XSD"
|
|
64
81
|
end
|
|
@@ -94,17 +111,17 @@ module Metanorma
|
|
|
94
111
|
|
|
95
112
|
file_path = match[:file_path].strip
|
|
96
113
|
context_name = match[:context_name].strip
|
|
97
|
-
template_file = Utils.relative_file_path(document,
|
|
98
|
-
match[:template].strip)
|
|
99
114
|
options = match[:options] ? parse_options(match[:options].strip) : {}
|
|
100
115
|
|
|
101
116
|
schema = load_lutaml_file(document, file_path, options)
|
|
102
117
|
schema_drop = update_repo(options, schema).to_liquid
|
|
103
118
|
|
|
104
|
-
template_source =
|
|
119
|
+
template_source = direct_template_source(document, match[:template],
|
|
120
|
+
context_name)
|
|
105
121
|
tmpl = template([template_source])
|
|
106
122
|
tmpl.registers[:file_system] = build_file_system(document, options)
|
|
107
123
|
tmpl.assigns[context_name] = schema_drop
|
|
124
|
+
tmpl.assigns["diagrams"] = options["diagrams"] != "false"
|
|
108
125
|
|
|
109
126
|
tmpl.render.split("\n", -1)
|
|
110
127
|
rescue StandardError => e
|
|
@@ -115,6 +132,16 @@ module Metanorma
|
|
|
115
132
|
raise e
|
|
116
133
|
end
|
|
117
134
|
|
|
135
|
+
def direct_template_source(document, template_path, context_name)
|
|
136
|
+
if template_path.nil? || template_path.strip.empty?
|
|
137
|
+
return "{% render \"#{DEFAULT_TEMPLATE}\", " \
|
|
138
|
+
"schema: #{context_name}, diagrams: diagrams %}"
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
File.read(Utils.relative_file_path(document, template_path.strip),
|
|
142
|
+
encoding: "UTF-8")
|
|
143
|
+
end
|
|
144
|
+
|
|
118
145
|
def parse_xsd_file(full_path, location)
|
|
119
146
|
content = File.read(full_path, encoding: "UTF-8")
|
|
120
147
|
::Lutaml::Xml::Schema::Xsd.parse(content, location: location)
|
|
@@ -23,6 +23,8 @@ module Metanorma
|
|
|
23
23
|
"metanorma/plugin/lutaml/data2_text_preprocessor"
|
|
24
24
|
autoload :ExpressRemarkAdapter,
|
|
25
25
|
"metanorma/plugin/lutaml/express_remark_adapter"
|
|
26
|
+
autoload :ExpressRemarkFigures,
|
|
27
|
+
"metanorma/plugin/lutaml/express_remark_figures"
|
|
26
28
|
autoload :ExpressRepositoryCache,
|
|
27
29
|
"metanorma/plugin/lutaml/express_repository_cache"
|
|
28
30
|
autoload :ExpressSchemaListing,
|
|
@@ -55,6 +57,8 @@ module Metanorma
|
|
|
55
57
|
"metanorma/plugin/lutaml/lutaml_gml_dictionary_block_macro"
|
|
56
58
|
autoload :LutamlKlassTableBlockMacro,
|
|
57
59
|
"metanorma/plugin/lutaml/lutaml_klass_table_block_macro"
|
|
60
|
+
autoload :LutamlJsonschemaPreprocessor,
|
|
61
|
+
"metanorma/plugin/lutaml/lutaml_jsonschema_preprocessor"
|
|
58
62
|
autoload :LutamlPreprocessor,
|
|
59
63
|
"metanorma/plugin/lutaml/lutaml_preprocessor"
|
|
60
64
|
autoload :LutamlTableInlineMacro,
|
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
spec.add_dependency "expressir", "~> 2.3", ">= 2.3.5"
|
|
35
35
|
spec.add_dependency "isodoc", ">= 3.5.0"
|
|
36
36
|
spec.add_dependency "liquid", "~> 5"
|
|
37
|
+
spec.add_dependency "lutaml-jsonschema", "~> 0.1", ">= 0.1.29"
|
|
37
38
|
spec.add_dependency "lutaml-lml"
|
|
38
39
|
spec.add_dependency "lutaml-model", "~> 0.8.156"
|
|
39
40
|
spec.add_dependency "lutaml-uml", ">= 0.5", "< 2"
|
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.74
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|
|
@@ -100,6 +100,26 @@ dependencies:
|
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
102
|
version: '5'
|
|
103
|
+
- !ruby/object:Gem::Dependency
|
|
104
|
+
name: lutaml-jsonschema
|
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0.1'
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: 0.1.29
|
|
113
|
+
type: :runtime
|
|
114
|
+
prerelease: false
|
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - "~>"
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0.1'
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: 0.1.29
|
|
103
123
|
- !ruby/object:Gem::Dependency
|
|
104
124
|
name: lutaml-lml
|
|
105
125
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -189,6 +209,7 @@ files:
|
|
|
189
209
|
- docs/usages/json_yaml.adoc
|
|
190
210
|
- docs/usages/lutaml-data.adoc
|
|
191
211
|
- docs/usages/lutaml-gml.adoc
|
|
212
|
+
- docs/usages/lutaml-jsonschema.adoc
|
|
192
213
|
- docs/usages/lutaml-uml.adoc
|
|
193
214
|
- docs/usages/lutaml-xsd.adoc
|
|
194
215
|
- docs/usages/xmi_to_uml.adoc
|
|
@@ -465,6 +486,7 @@ files:
|
|
|
465
486
|
- lib/metanorma/plugin/lutaml/data_providers.rb
|
|
466
487
|
- lib/metanorma/plugin/lutaml/express_hotspot_anchor.rb
|
|
467
488
|
- lib/metanorma/plugin/lutaml/express_remark_adapter.rb
|
|
489
|
+
- lib/metanorma/plugin/lutaml/express_remark_figures.rb
|
|
468
490
|
- lib/metanorma/plugin/lutaml/express_repository_cache.rb
|
|
469
491
|
- lib/metanorma/plugin/lutaml/express_schema_listing.rb
|
|
470
492
|
- lib/metanorma/plugin/lutaml/file_not_found_error.rb
|
|
@@ -495,6 +517,18 @@ files:
|
|
|
495
517
|
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list_class.liquid
|
|
496
518
|
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_entity_list_classes.liquid
|
|
497
519
|
- lib/metanorma/plugin/lutaml/liquid_templates/_packages_enum.liquid
|
|
520
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_attribute.liquid
|
|
521
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_attribute_group.liquid
|
|
522
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_attribute_value_constraints.liquid
|
|
523
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_child_elements.liquid
|
|
524
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_complex_type.liquid
|
|
525
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_diagram.liquid
|
|
526
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_diagram_children.liquid
|
|
527
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_element.liquid
|
|
528
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xml_example_attribute.liquid
|
|
529
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xml_example_child.liquid
|
|
530
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xsd_ref.liquid
|
|
531
|
+
- lib/metanorma/plugin/lutaml/liquid_templates/xsd/_xsd_schema.liquid
|
|
498
532
|
- lib/metanorma/plugin/lutaml/lutaml_data_preprocessor.rb
|
|
499
533
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_base.rb
|
|
500
534
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb
|
|
@@ -508,6 +542,7 @@ files:
|
|
|
508
542
|
- lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_base.rb
|
|
509
543
|
- lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_block.rb
|
|
510
544
|
- lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_block_macro.rb
|
|
545
|
+
- lib/metanorma/plugin/lutaml/lutaml_jsonschema_preprocessor.rb
|
|
511
546
|
- lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb
|
|
512
547
|
- lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
|
|
513
548
|
- lib/metanorma/plugin/lutaml/lutaml_table_inline_macro.rb
|