Skip to content

Commit

Permalink
feat: added optional description to Icon Items (#1)
Browse files Browse the repository at this point in the history
feat: added optional description to Icon Items
  • Loading branch information
chalmagr authored Aug 2, 2022
1 parent 27f0ecd commit bc9f6d9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cmd/library/generate/tasks/item/item_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod test {
.unwrap();
assert!(content.contains("LX_6N8UPcPbT0G"));
assert!(content.contains(
r"IconElement($id, 'IconElement', 'Package/Module/Family/BuiltInItem', $name, $tech)"
r"IconElement($id, 'IconElement', 'Package/Module/Family/BuiltInItem', $name, $tech, $desc)"
));
assert!(content.contains(
r"IconCardElement($id, 'IconCardElement', '<$ItemLg>', 'Family', $funcName, $content)"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/library/generate/templates/item_snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include('{{ data.item_urn }}')
{%- block procedures %}
' renders the element
{%- if data.element_shape == "Icon" %}
{{ data.procedure_name }}('{{ data.variable_name }}', '{{ data.primary_label }}', '{{ data.technical_label | default(value="an optional tech label") }}')
{{ data.procedure_name }}('{{ data.variable_name }}', '{{ data.primary_label }}', '{{ data.technical_label | default(value="an optional tech label") }}', '{{ data.description_label | default(value="an optional description") }}')
{% elif data.element_shape == "IconCard" %}
{{ data.procedure_name }}('{{ data.variable_name }}', '{{ data.primary_label }}', '{{ data.description_label | default(value="an optional description") }}')
{% elif data.element_shape == "IconGroup" %}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/library/generate/templates/item_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub const TEMPLATE: &str = r##"{% block header -%}
{%- block elements %}
{%- for element in data.elements %}
{%- if element.type == "Icon" %}
!procedure {{ element.procedure_name }}($id, $name="", $tech="")
IconElement($id, '{{ element.stereotype_name }}', '{{ element.icon_urn }}', $name, $tech)
!procedure {{ element.procedure_name }}($id, $name="", $tech="", $desc="")
IconElement($id, '{{ element.stereotype_name }}', '{{ element.icon_urn }}', $name, $tech, $desc)
!endprocedure
{%- elif element.type == "IconCard" %}
!procedure {{ element.procedure_name }}($id, $funcName="", $content="")
Expand Down
5 changes: 4 additions & 1 deletion src/cmd/library/generate/templates/library_bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,17 @@ skinparam DefaultFontColor $FONT_COLOR
' IconElement
{% block procedure_IconElement %}
!procedure IconElement($id, $stereotype, $icon, $name="", $tech="")
!procedure IconElement($id, $stereotype, $icon, $name="", $tech="", $desc="")
!local $H="<img:" + getIcon($icon)+ ">"
!if ($name != "")
!$H=$H + "\n" + $name
!endif
!if ($tech != "")
!$H=$H + "\n" + "<size:" + $FONT_SIZE_XS + "><color:" + $FONT_COLOR_LIGHT + ">[" + $tech + "]</color></size>"
!endif
!if ($desc != "")
!$H=$H + "\n\n" + $desc
!endif
card $id <<$stereotype>> as "$H"
!endprocedure
{% endblock procedure_IconElement %}
Expand Down

0 comments on commit bc9f6d9

Please sign in to comment.