Skip to main content

Library to generate plantuml code from python objects

Example

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=[
        # i1
        Relation(
            obj1="i1",
            rel_type=RelationType.Association,
            obj2="A",
            orientation=Orientation.DOWN
        ),
        # A
        Relation(
            obj1="A",
            rel_type=RelationType.Call,
            obj2="F",
            orientation=Orientation.DOWN
        ),
        Relation(
            obj1="A",
            rel_type=RelationType.Association,
            obj2="i2",
            orientation=Orientation.RIGHT
        ),

        # i2
        Relation(
            obj1="i2",
            rel_type=RelationType.Call,
            obj2="B",
            orientation=Orientation.RIGHT
        ),

        # B
        Relation(
            obj1="B",
            rel_type=RelationType.Call,
            obj2="D",
            orientation=Orientation.DOWN
        ),
        Relation(
            obj1="B",
            rel_type=RelationType.Call,
            obj2="C",
            orientation=Orientation.RIGHT
        ),

        # C
        Relation(
            obj1="C",
            rel_type=RelationType.Call,
            obj2="E",
            orientation=Orientation.DOWN
        ),
        Relation(
            obj1="C",
            rel_type=RelationType.Dependency,
            obj2="BD",
            orientation=Orientation.DOWN
        ),

        # D
        Relation(
            obj1="D",
            rel_type=RelationType.Call,
            obj2="E",
            orientation=Orientation.RIGHT
        ),

        # E
        # EMPTY

        # F
        Relation(
            obj1="F",
            rel_type=RelationType.Call,
            obj2="B",
            orientation=Orientation.UP
        ),

        # G
        Relation(
            obj1="G",
            rel_type=RelationType.Dependency,
            obj2="BD",
            orientation=Orientation.DOWN
        ),
    ],
)
plantuml_code, got_errors = diagram.gen_code(CodeGenerator.Context(code_style=style))

Generated code:
@startuml
title "Example 1"


/' OBJECTS '/
package "c1" {
    interface "i1" as i1 #FF0000
    component "A" as A #ADD8E6
}
package "c3" {
    cloud " " {
    component "F" as F #90EE90
}
}
package "c2" {
    interface "i2" as i2
    component "B" as B #F08080
    component "C" as C #F08080
}
package "c4" {
    component "D" as D #E0FFFF
    component "E" as E 
}
database "BD" as BD #FA8072
component "G" as G #ADD8E6
/' RELATIONS '/
i1 -down- A
A -down-> F
A -right- i2
i2 -right-> B
B -down-> D
B -right-> C
C -down-> E
C -down-> BD
D -right-> E
F -up-> B
G -down-> BD
@enduml

Rendered img

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plantuml_creator-1.0.7.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plantuml_creator-1.0.7-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file plantuml_creator-1.0.7.tar.gz.

File metadata

  • Download URL: plantuml_creator-1.0.7.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for plantuml_creator-1.0.7.tar.gz
Algorithm Hash digest
SHA256 5fc244a08abccd8d8aa7bb2080ed03f0fb7cd0c69135cbcb956eed6ad90af32c
MD5 1c339ee0fb0c6248504eb48bcc40e072
BLAKE2b-256 c21fdeadf71dce85e7befdfde7f8c339f8bc84693c0312b7c044e00bfe627cac

See more details on using hashes here.

File details

Details for the file plantuml_creator-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: plantuml_creator-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for plantuml_creator-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 264a0fae7accaed85f5fa5fb962fec33b48c9531ad141215575f131d44b28aea
MD5 1c6b04787de40ae23711a177d82887a2
BLAKE2b-256 398426a9251231e683d33b469acf2ded18dd9c12449a4be921453f59fd8b046d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page