Generate diagrams with Go+/Go code.
cdor vs d2
cdor is inspired and powered by d2, the difference is:
d2 is a DSL (Domain Specific Language), But cdor is SDF (Specific Domain Friendliness), we just write common programming laguages (Go+/Go) to generate diagrams.
see doc for details.
Initialize your diagram project
mkdir demo
cd demo
gop mod init demo
gop get github.com/zrcoder/cdor@latestcreate main_cdor.gox, with content like:
con "x", "y"
saveFile "hi.svg"then run:
gop mod tidy
gop run .create hi1_cdor.gox with content:
con "x", "y"create hi2_cdor.gox with content:
con "a", "b"modify main_cdor.gox to:
saveFiles ""after gop run, you'll find hi1.svg and hi2.svg generated.
you can merge all diagrams into a single diagram, and even creat more nodes and connections based on the sub diagrams, for example, modify main_cdor.gox to:
con "a", "x"
merge().saveFile "merged.svg"after gop run, we got a generated merged.svg.
we can also merge specific diagrams by their names:
merge("hi1", "hi2").saveFile("res.svg")you can range all the diagrams:
rangeCdors (name, cdor, err) => {
// do something with cdor
}or range part of the diagrams:
rangeCdors (name, cdor, err) => {
// do somthing with cdor
}, "hi1", "hi2"