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 %
////
65 66 67 |
# File 'lib/suma/schema_document.rb', line 65 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 |
# File 'lib/suma/schema_document.rb', line 12 def schema_anchors " // _fund_cons.liquid\n [[\#{@id}_funds]]\n\n // _constants.liquid\n {% if schema.constants.size > 0 %}\n \#{bookmark(\"constants\")}\n {% for thing in schema.constants %}\n \#{bookmark(\"{{thing.id}}\")}\n {% endfor %}\n {% endif %}\n\n // _types.liquid\n {% if schema.types.size > 0 %}\n \#{bookmark(\"types\")}\n // _type.liquid\n {% for thing in schema.types %}\n \#{bookmark(\"{{thing.id}}\")}\n {% if thing.items.size > 0 %}\n // _type_items.liquid\n \#{bookmark(\"{{thing.id}}.items\")}\n {% for item in thing.items %}\n \#{bookmark(\"{{thing.id}}.items.{{item.id}}\")}\n {% endfor %}\n {% endif %}\n {% endfor %}\n {% endif %}\n\n // _entities.liquid\n {% if schema.entities.size > 0 %}\n \#{bookmark(\"entities\")}\n {% for thing in schema.entities %}\n // _entity.liquid\n \#{bookmark(\"{{thing.id}}\")}\n {% endfor %}\n {% endif %}\n HEREDOC\nend\n" |
#to_adoc(path_to_schema_yaml) ⇒ Object
#.gsub(/2,/, ”)
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/suma/schema_document.rb', line 70 def to_adoc(path_to_schema_yaml) " = \#{@schema.id}\n :lutaml-express-index: schemas; \#{path_to_schema_yaml};\n :bare: true\n :mn-document-class: iso\n :mn-output-extensions: xml,html\n\n [lutaml,schemas,context]\n ----\n {% for schema in context.schemas %}\n\n [[\#{@id}]]\n [%unnumbered,type=express]\n == \#{@id} \#{schema_anchors.gsub(%r{//[^\\r\\n]+}, \"\").gsub(/[\\n\\r]+/, \"\").gsub(/^[\\n\\r]/, \"\")}\n\n [source%unnumbered]\n --\n {{ schema.formatted }}\n --\n {% endfor %}\n ----\n\n HEREDOC\nend\n" |