Skip to content

Generate code from class diagrams from a Mermaid markdown file

License

Notifications You must be signed in to change notification settings

roberts-pumpurs/mermaid-to-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate code from a mermaid markdown file

Example

From a mermaid code like this:


    A "1" o-- "1..N" B
    B "N" *--* "M" C
    A "0..N" --* "1" C

    class A {
        +int vertejums
        +string atsauksme
    }
    class B {
        +string nosaukums
        +string atrasanas vieta
        +string apraksts
    }
    class C {
        +string tips
    }

which, with the help of Mermaid JS generates a diagram like this

Class diagram

and with the help of this utility code generates this:

from django.db import models

class C(models.Model):
    tips = models.CharField(max_length=100)

class A(models.Model):
    C_fk = models.ForeignKey('C')
    vertejums = models.IntegerField()
    atsauksme = models.CharField(max_length=100)

class B(models.Model):
    A_fk = models.ForeignKey('A')
    C_fk = models.ManyToManyField('C')
    nosaukums = models.CharField(max_length=100)
    atrasanas = models.CharField(max_length=100)
    apraksts = models.CharField(max_length=100)

Usage

Follow the pattern of [executable] [input file] [backend] [output file]

Example:

./target/release/mermaid-parser sample/classes.md django output/models.py

Compilation

cargo build --release

Backends

Currently supported backends:

  • Django

About

Generate code from class diagrams from a Mermaid markdown file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages