从python库生成uml对象
plantuml-creator的Python项目详细描述
从python对象生成plantuml代码的库
示例
diagram1=Diagram(name="Example 1",opts={DiagramOptName.AUTO_NUMBER:True,DiagramOptName.AUTO_NUMBER_START:1,DiagramOptName.ADD_SEPARATORS:True,DiagramOptName.TITLE:"Example 1",},type_=DiagramType.COMPONENT,objs=[Container(name="c1",objs=[Class(name="i1",type_=ClassType.INTERFACE_LOLLIPOP,shape_attrs={ShapeAttributeName.COLOR:Color.RED.value,}),Component(name="A",shape_attrs={ShapeAttributeName.COLOR:Color.LIGHT_BLUE.value,})]),Container(name="c3",objs=[Container(name=" ",objs=[Component(name="F",shape_attrs={ShapeAttributeName.COLOR:Color.LIGHT_GREEN.value,}),],container_type=ContainerShapeType.CLOUD),],),Container(name="c2",objs=[Class(name="i2",type_=ClassType.INTERFACE_LOLLIPOP),Component(name="B",shape_attrs={ShapeAttributeName.COLOR:Color.LIGHT_CORAL.value,}),Component(name="C",shape_attrs={ShapeAttributeName.COLOR:Color.LIGHT_CORAL.value,}),]),Container(name="c4",objs=[Component(name="D",shape_attrs={ShapeAttributeName.COLOR:Color.LIGHT_CYAN.value,}),Component(name="E",),]),Component(name="BD",shape_attrs={ShapeAttributeName.COLOR:Color.SALMON.value,ShapeAttributeName.CONTAINER_SHAPE_TYPE:ContainerShapeType.DATABASE.value},),Component(name="G",shape_attrs={ShapeAttributeName.COLOR:Color.LIGHT_BLUE.value,},),],relations=[# i1Relation(obj1="i1",rel_type=RelationType.Association,obj2="A",orientation=Orientation.DOWN),# ARelation(obj1="A",rel_type=RelationType.Call,obj2="F",orientation=Orientation.DOWN),Relation(obj1="A",rel_type=RelationType.Association,obj2="i2",orientation=Orientation.RIGHT),# i2Relation(obj1="i2",rel_type=RelationType.Call,obj2="B",orientation=Orientation.RIGHT),# BRelation(obj1="B",rel_type=RelationType.Call,obj2="D",orientation=Orientation.DOWN),Relation(obj1="B",rel_type=RelationType.Call,obj2="C",orientation=Orientation.RIGHT),# CRelation(obj1="C",rel_type=RelationType.Call,obj2="E",orientation=Orientation.DOWN),Relation(obj1="C",rel_type=RelationType.Dependency,obj2="BD",orientation=Orientation.DOWN),# DRelation(obj1="D",rel_type=RelationType.Call,obj2="E",orientation=Orientation.RIGHT),# E# EMPTY# FRelation(obj1="F",rel_type=RelationType.Call,obj2="B",orientation=Orientation.UP),# GRelation(obj1="G",rel_type=RelationType.Dependency,obj2="BD",orientation=Orientation.DOWN),],)plantuml_code,got_errors=diagram.gen_code(CodeGenerator.Context(code_style=style))
生成代码:
^{pr2}$
渲染图像
- 项目
标签: