Class: Suma::SchemaDocument
- Inherits:
-
SchemaAttachment
- Object
- SchemaAttachment
- Suma::SchemaDocument
- Defined in:
- lib/suma/schema_document.rb
Instance Attribute Summary
Attributes inherited from SchemaAttachment
#config, #id, #output_path, #schema
Instance Method Summary collapse
- #bookmark(anchor) ⇒ Object
-
#output_extensions ⇒ Object
//// TODO: % render “templates/entities”, schema: schema, schema_id: schema.id, things: schema.entities, thing_prefix: root_thing_prefix, depth: 2 %.
- #schema_anchors ⇒ Object
-
#to_adoc(path_to_schema_yaml) ⇒ Object
#.gsub(/2,/, ”).
Methods inherited from SchemaAttachment
#clean_artifacts, #compile, #filename_adoc, #filename_config, #initialize, #output_folder, #output_xml_path, #save_adoc, #save_config, #to_config
Constructor Details
This class inherits a constructor from Suma::SchemaAttachment
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
////
TODO:
% render "templates/entities", schema: schema, schema_id: schema.id, things: schema.entities, thing_prefix: root_thing_prefix, depth: 2 %
% render "templates/subtype_constraints", schema_id: schema.id, things: schema.subtype_constraints, thing_prefix: root_thing_prefix, depth: 2 %
% render "templates/functions", schema_id: schema.id, things: schema.functions, thing_prefix: root_thing_prefix, depth: 2 %
% render "templates/procedures", schema_id: schema.id, things: schema.procedures, thing_prefix: root_thing_prefix, depth: 2 %
% render "templates/rules", schema_id: schema.id, things: schema.rules, thing_prefix: root_thing_prefix, depth: 2 %
////
101 102 103 |
# File 'lib/suma/schema_document.rb', line 101 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
#.gsub(/2,/, ”)
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/suma/schema_document.rb', line 106 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 |