本文章描述基于 C4-Model + PlantUML + VSCode 开发设计软件架构,相关环境搭建参看:C4-Model 开发环境搭建
- 1. Container
- 2. ContainerDb
- 3. ContainerQueue
- 4. Container_Ext
- 5. ContainerDb_Ext
- 6. ContainerQueue_Ext
- 7. Container_Boundary
- 8. AddContainerTag
- 9. AddExternalContainerTag
- 10. 代码示例
| 函数名 | Container($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") | |
| 参数 | ||
| alias(必须) | 定义Person的一个别名,用于后续设计的调用 | |
| label(必须) | 用于定义在图形上显示的标签, 可以使用字符串,也可以直接输入 | |
| techn | 为容器增加技术栈,如 [C/C++] [JS/TS] | |
| descr | 增加对Container的详细描述 | |
| sprite | 为容器增加图标,C4 容器默认无图标 | |
| tags | 增加一个自定义的 tag, 默认tag为 Container | |
| link | 增加一个链接,实现点击跳转的功能 | |
2. ContainerDb
| 函数名 | ContainerDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") | |
| 参数 | 参见:Container | |
3. ContainerQueue
| 函数名 | ContainerQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") | |
| 参数 | 参见:Container | |
4. Container_Ext
| 函数名 | Container_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") | |
| 参数 | 参见:Container | |
5. ContainerDb_Ext
| 函数名 | ContainerDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") | |
| 参数 | 参见:Container | |
6. ContainerQueue_Ext
| 函数名 | ContainerQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") | |
| 参数 | 参见:Container | |
7. Container_Boundary
| 函数名 | Container_Boundary($alias, $label, $tags="", $link="") | |
| 参数 | 参见:Container | |
8. AddContainerTag
| 函数名 | AddContainerTag ( $tagStereo, $bgColor=$CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$CONTAINER_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") | |
| 参数 | ||
| tagStereo(必须) | 设置一个标签的名称,用于后续的调用与显示,设置值为显示值 | |
| bgColor | 设置容器的背景颜色 | |
| fontColor | 设置容器的字体颜色 | |
| borderColor | 设置边框的颜色 | |
| shadowing | 是否显示阴影,true 或者 false | |
| shape | 为容器设置一个图标, 默认为直角 roundedBox 圆角 eightSided 斜角 | |
| sprite | 设置一个图标 | |
| techn | 为容器增加一个技术栈,如果在容器定义中重新声明则显示容器中的定义 | |
| legendText | 设置在图例中显示的标题 | |
| legendSprite | 设置一个在图例中显示的图标,默认为上面参数sprite设置的图标 | |
9. AddExternalContainerTag
| 函数名 | AddExternalContainerTag( $tagStereo, $bgColor=$CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$CONTAINER_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") | |
| 参数 | 参见:AddContainerTag | |
10. 代码示例
@startuml ' 定义宏 RELATIVE_INCLUDE 指定 C4-PlantUML 仓库 !define RELATIVE_INCLUDE /Users/xxx/C4-PlantUML !include RELATIVE_INCLUDE/C4_Container.puml ' 引用 office 标准裤,扩展图标 ' https://github.com/plantuml/plantuml-stdlib/tree/master/office !include!include !include !include ' 隐藏标签 HIDE_STEREOTYPE() AddContainerTag("云端", $shadowing=true, $sprite="cloud", $shape="roundedBox", $techn="mysql", $legendText="云",$legendSprite="") AddContainerTag("APP服务器", $shadowing=true, $sprite="application_server", $shape="roundedBox", $techn="Java", $legendText="APP服务器",$legendSprite="") AddContainerTag("第三方服务器", $shadowing=true, $bgColor=$EXTERNAL_CONTAINER_BG_COLOR, $sprite="3rd_party_mail_server", $shape="roundedBox", $techn="Java", $legendText="第三方服务器",$legendSprite="") AddContainerTag("客户端应用", $shadowing=true, $sprite="my_site", $shape="", $techn="C/C++", $legendText="客户端",$legendSprite="") ContainerDb(cloud, "云端", $descr="数据备份与存储", $tags="云端") Container_Boundary(server, "本地服务器"){ Container(server_app, "APP服务器",, $descr="APP1的服务器", $tags="APP服务器") ContainerQueue(app_Queue, "APP数据队列服务器",, $descr="APP1的服务器", $tags="APP服务器") } Container_Ext(3rd_app_server, "第三方服务器",, $descr="第三方服务器,提供第三方功能支持", $tags="第三方服务器") Container(pc_app, "电脑应用程序",, $descr="客户交互界面", $tags="客户端应用") Rel_Neighbor(cloud, 3rd_app_server, "备份数据", "http/RestAPI") BiRel_U(server_app, cloud, "获取云端数据", "http/RestAPI") BiRel_U(pc_app, server_app, "获取服务器数据", "http/RestAPI") Rel_U(pc_app, 3rd_app_server, "获取数据", "http/RestAPI") Rel_R(server_app, app_Queue,"数据队列","FIFO") SHOW_LEGEND() @enduml



