Class: Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor

Inherits:
LutamlUmlClassPreprocessor
  • Object
show all
Defined in:
lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb

Overview

Macro for quick rendering of datamodel attributes/values table

@example [lutaml_uml_attributes_table,path/to/lutaml,EntityName]

Constant Summary collapse

MACRO_REGEXP =
/\[lutaml_uml_attributes_table,([^,]+),?([^,]+),?(.+?)?\]/

Instance Method Summary collapse

Methods inherited from LutamlUmlClassPreprocessor

#get_macro_regexp, #process

Instance Method Details

#template(options) ⇒ Object

rubocop:disable Layout/IndentHeredoc



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
# File 'lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb', line 15

def template(options)
  skip_headers = options[:skip_headers]

  <<~TEMPLATE
  #{"=== {{ definition.name }}" unless skip_headers}
  {{ definition.definition }}

  {% if definition.attributes %}
  {% if definition.keyword == 'enumeration' %}
  .{{ definition.name }} values
  |===
  |Name |Definition

  {% for item in definition.attributes %}
  |{{ item.name }} |{{ item.definition }}
  {% endfor %}
  |===
  {% else %}
  .{{ definition.name }} attributes
  |===
  |Name |Definition |Mandatory / Optional / Conditional |Max Occur |Data Type

  {% for item in definition.attributes %}
  |{{ item.name }} |{% if item.definition %}{{ item.definition }}{% endif %} |{% if item.cardinality.min == "0" %}O{% else %}M{% endif %} |{% if item.cardinality.max == "*" %}N{% else %}1{% endif %} |{% if item.origin %}<<{{ item.origin }}>>{% endif %} `{{ item.type }}`
  {% endfor %}
  |===
  {% endif %}
  {% endif %}

  TEMPLATE
end