Skip to main content

A simple dsl for creating mermaid graphs!

Project description

Siren

Examples

Flowchart

Python currently not running due to: https://github.com/fable-compiler/Fable/issues/3808

diagram.flowchart(flowchartDirection.bt, [
    flowchart.subgraph ("space", [
        flowchart.directionBT
        flowchart.linkDottedArrow("earth", "moon", formatting.unicode "🚀", 6)
        flowchart.nodeRound "moon"
        flowchart.subgraph ("atmosphere", [
            flowchart.nodeCircle "earth"
        ])
    ])
])
|> siren.write
flowchart BT
    subgraph space
        direction BT
        earth-......->|"🚀"|moon
        moon(moon)
        subgraph atmosphere
            earth((earth))
        end
    end

Class Diagram

let duck,animal,zebra,fish = "Duck","Animal","Zebra", "Fish"
siren.classDiagram [
    classDiagram.note "From Duck till Zebra"
    classDiagram.relationshipInheritance(duck, animal)
    classDiagram.note(@"can fly\ncan swim\ncan dive\ncan help in debugging", duck)
    classDiagram.relationshipInheritance(fish, animal)
    classDiagram.relationshipInheritance(zebra, animal)
    classDiagram.classMember(animal,"+int age")
    classDiagram.classMember(animal,"+String gender")
    classDiagram.classMember(animal,"+isMammal()")
    classDiagram.classMember(animal,"+mate()")
    classDiagram.class'(duck,members=[
        "+String beakColor"
        "+swim()"
        "+quack()"
    ])
    classDiagram.class'(fish,members=[
        "-int sizeInFeet"
        "-canEat()"
    ])
    classDiagram.class'(zebra,members=[
        "+bool is_wild"
        "+run()"
    ])
    classDiagram.namespace'("Mammals", [
        classDiagram.class'(zebra)
    ])
]
|> siren.write
classDiagram
    note "From Duck till Zebra"
    Duck --|> Animal
    note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging"
    Fish --|> Animal
    Zebra --|> Animal
    Animal : +int age
    Animal : +String gender
    Animal : +isMammal()
    Animal : +mate()
    class Duck{
        +String beakColor
        +swim()
        +quack()
    }
    class Fish{
        -int sizeInFeet
        -canEat()
    }
    class Zebra{
        +bool is_wild
        +run()
    }
    namespace Mammals {
        class Zebra
    }

Entity Relationship Diagram

let CAR, NAMED_DRIVER, PERSON, MANUFACTURER = "CAR", "NAMED-DRIVER", "PERSON", "MANUFACTURER"
siren.erDiagram [
    erDiagram.relationship (CAR, erCardinality.onlyOne, NAMED_DRIVER, erCardinality.zeroOrMany, "allows")
    erDiagram.entity (CAR,attr=[
        erDiagram.attribute("string", "registrationNumber", [erKey.pk])
        erDiagram.attribute("string", "make")
        erDiagram.attribute("string", "model")
        erDiagram.attribute("string[]", "parts")
    ])
    erDiagram.relationship (PERSON, erCardinality.onlyOne, NAMED_DRIVER, erCardinality.zeroOrMany, "is")
    erDiagram.entity (PERSON,attr=[
        erDiagram.attribute("string", "driversLicense", [erKey.pk], "The license is #")
        erDiagram.attribute("string(99)", "firstName", comment="Only 99 characters are allowed")
        erDiagram.attribute("string", "lastName")
        erDiagram.attribute("string", "phone", [erKey.uk])
        erDiagram.attribute("int", "age")
    ])
    erDiagram.entity(NAMED_DRIVER, attr=[
        erDiagram.attribute("string", "carRegistrationNumber", [erKey.pk; erKey.fk])
        erDiagram.attribute("string", "driverLicence", [erKey.pk; erKey.fk])
    ])
    erDiagram.relationship(MANUFACTURER,erCardinality.onlyOne,CAR,erCardinality.zeroOrMany,"makes")
]
|> siren.write
erDiagram
    CAR only one to zero or many NAMED-DRIVER : allows
    CAR {
        string registrationNumber PK
        string make
        string model
        string[] parts
    }
    PERSON only one to zero or many NAMED-DRIVER : is
    PERSON {
        string driversLicense PK "The license is #"
        string(99) firstName "Only 99 characters are allowed"
        string lastName
        string phone UK
        int age
    }
    NAMED-DRIVER {
        string carRegistrationNumber PK, FK
        string driverLicence PK, FK
    }
    MANUFACTURER only one to zero or many CAR : makes

Project details


Download files

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

Source Distribution

siren_dsl-0.2.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

siren_dsl-0.2.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file siren_dsl-0.2.0.tar.gz.

File metadata

  • Download URL: siren_dsl-0.2.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.9 Windows/10

File hashes

Hashes for siren_dsl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 186e39d8a015a92d12ee2515cbb823dc0c96a3b09f8bc117fe6c952ad7eb4829
MD5 2f95f6d68294a6b041073ff1780ce0ff
BLAKE2b-256 61f2488191fd967e90f15f9c75e173dac7fc0a3fa9f3a4b3877687b2b763033f

See more details on using hashes here.

Provenance

File details

Details for the file siren_dsl-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: siren_dsl-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.9 Windows/10

File hashes

Hashes for siren_dsl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b738b1817ecc52663621e41638b5e46ba14d02e5ba36cb40cb6b8bc2adcdd8e2
MD5 a2bbc89147eeae905988985de645fb24
BLAKE2b-256 caf6e76b7637acb45ed794aeffc75ed55b1655bb9ddd1ccb7cf7961eb2d398fa

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page