Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Descriptions for boundaries #350

Closed
NathanDotTo opened this issue Apr 30, 2024 · 8 comments
Closed

Descriptions for boundaries #350

NathanDotTo opened this issue Apr 30, 2024 · 8 comments
Assignees
Milestone

Comments

@NathanDotTo
Copy link

Hi

It seems to me that adding a description to a boundary would be a good thing. That way we could describe what the boundary contains in a general sense. This also seems like an obvious idea, so I am wondering why it is not already possible.

To explore whether boundary descriptions might be possible, I am looking at the Enterprise_Boundary, System_Boundary, and Container_Boundary procedures. For example:

!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="")
  !if ($tags != "")
    !$allTags = $tags + '+enterprise'
  !else
    !$allTags = 'enterprise'
  !endif
  ' $type defined via $tag style
  Boundary($alias, $label, "", $allTags, $link)
!endprocedure

Which leads to, in C4.puml:

!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="")
!$boundaryTags = $addBoundaryPostfix($tags)
' nodes $type reuses $techn definition of $boundaryTags
!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary")
rectangle "$getBoundary($label, $type)" $toStereos("boundary", $boundaryTags) as $alias $getLink($link)
!endprocedure

Which leads to:

!function $getBoundary($label, $type)
  !if ($type == "")
    !return '== ' + $breakLabel($label)
  !endif
  !if (type != "")
    !return '== ' + $breakLabel($label) + '\n<size:' + $TECHN_FONT_SIZE + '>[' + $type + ']</size>'
  !endif
!endfunction

Does anyone reading this know whether/how a rectangle can have a description?

Am I thinking about this in the right way please?

Thanks

Nathan

@kirchsth
Copy link
Member

kirchsth commented Apr 30, 2024

HI @NathanDotTo,

I will try to implement it in one of the next weekends.
But in the meantime you could use following workaround for e.g. System_Boundary:

  • extend { at the end of System(...) and combine it with $tags="system_boundary" to
    System(..., $tags="system_boundary") {
  • close the boundary with a } after all included elements

like (follow the image link then you see the code)

BR Helmut

@kirchsth kirchsth added this to the v2.10.0 milestone Apr 30, 2024
@NathanDotTo
Copy link
Author

Cool, that worked, thanks! :-)

@NathanDotTo
Copy link
Author

I have also had cause to use the type too, like this:

System(a_system, "A Cloud Platform", "X-as-a-Service (XaaS) ", $type="GCP", $tags="system_boundary") {
  Container ...
}

@kirchsth
Copy link
Member

kirchsth commented Apr 30, 2024

Update: correct solution see next comment

If you want a different type, then I would directly use a boundary and define its own $type like

Boundary(anotherBoundary, "Another Boundary", $type="BOUNDARY TYPE", $tags="v1") {

details see https://github.com/plantuml-stdlib/C4-PlantUML?tab=readme-ov-file#sample-with-different-boundary-tag-combinations

BR Helmut

@kirchsth kirchsth self-assigned this May 1, 2024
kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue May 1, 2024
…tags

If a sprite is defined then it displayed in the first line in front of the
(with a smaller size, typically 50%)

- AddBoundaryTag(..., ?sprite, ?legendSprite)
- UpdateBoundaryStyle(..., ?sprite, ?legendSprite)
- UpdateContainerBoundaryStyle(..., ?sprite, ?legendSprite)
- UpdateSystemBoundaryStyle(..., ?sprite, ?legendSprite)
- UpdateEnterpriseBoundaryStyle(..., ?sprite, ?legendSprite)

Default sprite size can be changed via $BOUNDARY_IMAGE_SIZE_FACTOR
@kirchsth
Copy link
Member

kirchsth commented May 1, 2024

Hi @NathanDotTo,

sorry, I forgot my implementation (indention) related to the $type support of a (System/Container/...)Boundary.
You can define it via the tags AddBoundaryTag(tagName, ..., $type="NewType", ...) and then e.g. all (Systems) boundaries which uses the $tag displays the updated $type automatically too.
Sample see below (follow the image link then you see the code):

BR Helmut

kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue May 1, 2024
- Boundary(..., ?descr)
- Enterprise_Boundary(..., ?descr)
- System_Boundary(..., ?descr)
- Container_Boundary(..., ?descr)
kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue May 1, 2024
kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue May 1, 2024
@kirchsth
Copy link
Member

kirchsth commented May 1, 2024

Hi @NathanDotTo,

I implemented a version in my extended branch (details see #352) can you please check it via my branch?
(the only difference is that you have to use my extended branch !include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/...

@startuml
!include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Container.puml

AddBoundaryTag("chatGPT", $type="ChatGPT", $bgColor="red", $fontColor="white", $borderColor="darkred", $sprite="robot2")

Person(admin, "Administrator",$sprite="person2")
System_Boundary(c1, "Sample System", $descr="ChatGPT with model gpt-3.5-turbo. It has been updated to feature higher accuracy", $tags="chatGPT") {
    Container(web_app, "Web Application", "C#, ASP.NET Core 2.1 MVC", "Allows users to compare multiple Twitter timelines")
}
System(twitter, "Twitter")

Rel(admin, web_app, "Uses", "HTTPS")
Rel(web_app, twitter, "Gets tweets from", "HTTPS")

SHOW_LEGEND()
@enduml

Thank you and best regards
Helmut

@NathanDotTo
Copy link
Author

Thank you for this. I will be able to test this next week.

@NathanDotTo
Copy link
Author

NathanDotTo commented May 3, 2024

I have tested this, and it works, thank you :-)

kirchsth added a commit that referenced this issue May 4, 2024
…rite

#350 All boundaries supports descriptions and sprites too
@kirchsth kirchsth closed this as completed May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants