Class: Suma::SchemaDocument
Instance Attribute Summary
#config, #id, #output_path, #schema
Instance Method Summary
collapse
#compile, #filename_adoc, #filename_config, #initialize, #output_xml_path, #save_adoc, #save_config, #to_config
Instance Method Details
#bookmark(anchor) ⇒ Object
7
8
9
10
|
# File 'lib/suma/schema_document.rb', line 7
def bookmark(anchor)
a = anchor.gsub("}}", ' | replace: "\", "-"}}')
"[[#{@id}.#{a}]]"
end
|
#output_extensions ⇒ Object
88
89
90
|
# File 'lib/suma/schema_document.rb', line 88
def output_extensions
"xml"
end
|
#schema_anchors ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/suma/schema_document.rb', line 12
def schema_anchors
<<~HEREDOC
// _fund_cons.liquid
[[#{@id}_funds]]
// _constants.liquid
{% if schema.constants.size > 0 %}
#{bookmark('constants')}
{% for thing in schema.constants %}
#{bookmark('{{thing.id}}')}
{% endfor %}
{% endif %}
// _types.liquid
{% if schema.types.size > 0 %}
#{bookmark('types')}
// _type.liquid
{% for thing in schema.types %}
#{bookmark('{{thing.id}}')}
{% if thing.items.size > 0 %}
// _type_items.liquid
#{bookmark('{{thing.id}}.items')}
{% for item in thing.items %}
#{bookmark('{{thing.id}}.items.{{item.id}}')}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
// _entities.liquid
{% if schema.entities.size > 0 %}
#{bookmark('entities')}
{% for thing in schema.entities %}
// _entity.liquid
#{bookmark('{{thing.id}}')}
{% endfor %}
{% endif %}
// _subtype_constraints.liquid
{% if schema.subtype_constraints.size > 0 %}
#{bookmark('subtype_constraints')}
// _subtype_constraint.liquid
{% for thing in schema.subtype_constraints %}
#{bookmark('{{thing.id}}')}
{% endfor %}
{% endif %}
// _functions.liquid
{% if schema.functions.size > 0 %}
#{bookmark('functions')}
// _function.liquid
{% for thing in schema.functions %}
#{bookmark('{{thing.id}}')}
{% endfor %}
{% endif %}
// _procedures.liquid
{% if schema.procedures.size > 0 %}
#{bookmark('procedures')}
// _procedure.liquid
{% for thing in schema.procedures %}
#{bookmark('{{thing.id}}')}
{% endfor %}
{% endif %}
// _rules.liquid
{% if schema.rules.size > 0 %}
#{bookmark('rules')}
// _rule.liquid
{% for thing in schema.rules %}
#{bookmark('{{thing.id}}')}
{% endfor %}
{% endif %}
HEREDOC
end
|
#to_adoc(path_to_schema_yaml) ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/suma/schema_document.rb', line 92
def to_adoc(path_to_schema_yaml)
<<~HEREDOC
= #{@schema.id}
:lutaml-express-index: schemas; #{path_to_schema_yaml};
:bare: true
:mn-document-class: iso
:mn-output-extensions: xml,html
[lutaml_express_liquid,schemas,context]
----
{% for schema in context.schemas %}
[[#{@id}]]
[%unnumbered,type=express]
== #{@id} #{schema_anchors.gsub(%r{//[^\r\n]+}, '').gsub(/[\n\r]+/, '').gsub(/^[\n\r]/, '')}
[source%unnumbered]
--
{{ schema.formatted }}
--
{% endfor %}
----
HEREDOC
end
|