Friday, April 26, 2024
HomeGolangA Golang-based trendy diagram scripting language that turns textual content to diagrams

A Golang-based trendy diagram scripting language that turns textual content to diagrams


What does D2 appear like?

# Actors
hans: Hans Niemann

defendants: {
  mc: Magnus Carlsen
  playmagnus: Play Magnus Group
  chesscom: Chess.com
  naka: Hikaru Nakamura

  mc -> playmagnus: Owns majority
  playmagnus <-> chesscom: Merger talks
  chesscom -> naka: Sponsoring
}

# Accusations
hans -> defendants: 'sueing for $100M'

# Offense
defendants.naka -> hans: Accused of dishonest on his stream
defendants.mc -> hans: Misplaced then withdrew with accusations
defendants.chesscom -> hans: 72 web page report of dishonest

There may be syntax highlighting with the editor plugins linked under.

D2 render example

Rendered with the TALA format engine.

For extra examples, see ./docs/examples.

Quickstart

Probably the most handy means to make use of D2 is to simply run it as a CLI executable to supply SVGs from .d2 information.

# First, set up D2
curl -fsSL https://d2lang.com/set up.sh | sh -s --

echo 'x -> y -> z' > in.d2
d2 --watch in.d2 out.svg

A browser window will open with out.svg and live-reload on modifications to in.d2.

Set up

The best strategy to set up is with our set up script:

curl -fsSL https://d2lang.com/set up.sh | sh -s --

You possibly can run the set up script with --dry-run to see the instructions that will probably be used to put in with out executing them.

Or when you’ve got Go put in you may set up from supply although you gained’t get the manpage:

go set up oss.terrastruct.com/[email protected]

You can even set up a launch from supply which can embrace manpages. See ./docs/INSTALL.md#source-release.

To uninstall with the set up script:

curl -fsSL https://d2lang.com/set up.sh | sh -s -- --uninstall

For detailed set up docs, see ./docs/INSTALL.md. We exhibit various strategies and examples for every OS.

As effectively, the functioning of the set up script is described intimately to alleviate any concern of its use. We suggest utilizing your OS’s package deal supervisor immediately as a substitute for improved safety however the set up script is in no way insecure.

D2 as a library

Along with being a runnable CLI device, D2 may also be used to supply diagrams from Go packages.

For examples, see ./docs/examples/lib. This weblog put up additionally demos a whole, runnable instance of utilizing D2 as a library for a real-world use case.

Themes

D2 consists of a wide range of official themes to fashion your diagrams fantastically proper out of the field. See ./d2themes to browse the out there themes and make or contribute your personal creation.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments