2022-11-14 18:26:37 +00:00
.Dd $Mdocdate$
.Dt d2 1
.Os
.Sh NAME
.Nm d2
.Nd compiles and renders d2 diagrams into svgs.
.Sh SYNOPSIS
.Nm d2
.Op Fl -watch Ar false
.Op Fl -theme Em 0
.Ar file.d2
2022-11-30 11:01:13 +00:00
.Op Ar file.svg | file.png
2022-11-14 18:26:37 +00:00
.Nm d2
.Ar layout Op Ar name
2022-12-01 10:48:30 +00:00
.Nm d2
2023-01-27 14:48:01 +00:00
.Ar fmt Ar file.d2 ...
2022-11-14 18:26:37 +00:00
.Sh DESCRIPTION
.Nm
compiles and renders
.Ar file.d2
2022-11-21 21:24:10 +00:00
to
2022-11-21 18:46:54 +00:00
.Ar file.svg
2022-11-21 19:02:17 +00:00
|
2022-11-21 18:46:54 +00:00
.Ar file.png
.Ns .
2022-11-14 18:26:37 +00:00
.Pp
2022-11-30 11:01:13 +00:00
It defaults to
.Ar file.svg
if no output path is passed.
.Pp
2022-11-14 18:26:37 +00:00
Pass - to have
.Nm
read from stdin or write to stdout.
.Pp
2022-11-30 11:01:13 +00:00
Never use the presence of the output file to check for success.
Always use the exit status of
.Nm d2
.Ns .
This is because sometimes when errors occur while rendering, d2 still write out a partial
render anyway to enable iteration on a broken diagram.
.Pp
2022-11-14 18:26:37 +00:00
See more docs, the source code and license at
.Lk https://oss.terrastruct.com/d2
2023-02-05 08:19:14 +00:00
.Ns .
.Pp
Hosted icons at
.Lk https://icons.terrastruct.com
.Ns .
.Pp
Playground runner at
.Lk https://play.d2lang.com
.Ns .
2022-11-14 18:26:37 +00:00
.Sh OPTIONS
.Bl -tag -width Fl
.It Fl w , -watch Ar false
Watch for changes to input and live reload. Use
.Ev $PORT and Ev $HOST to specify the listening address.
2022-11-17 06:45:08 +00:00
.It Fl h , -host Ar localhost
Host listening address when used with
.Ar watch
.Ns .
.It Fl p , -port Ar 0
Port listening address when used with
.Ar watch
.Ns .
2022-11-14 18:26:37 +00:00
.It Fl t , -theme Ar 0
2023-02-05 08:34:43 +00:00
Set the diagram theme ID
2022-11-17 06:45:08 +00:00
.Ns .
2023-02-21 08:53:19 +00:00
.It Fl -dark-theme Ar -1
2023-02-25 18:39:21 +00:00
The theme to use when the viewer's browser is in dark mode. When left unset
.Fl -theme
is used for both light and dark mode. Be aware that explicit styles set in D2 code will
still be applied and this may produce unexpected results. We plan on resolving this by
making style maps in D2 light/dark mode specific. See
.Lk https://github.com/terrastruct/d2/issues/831
2023-02-21 08:48:17 +00:00
.Ns .
2022-12-21 07:43:45 +00:00
.It Fl s , -sketch Ar false
Renders the diagram to look like it was sketched by hand
.Ns .
2023-03-18 05:29:51 +00:00
.It Fl -center Ar flag
Center the SVG in the containing viewbox, such as your browser screen
.Ns .
2023-03-30 00:20:41 +00:00
.It Fl -font-regular
Path to .ttf file to use for the regular font. If none provided, Source Sans Pro Regular is used
.Ns .
.It Fl -font-italic
Path to .ttf file to use for the italic font. If none provided, Source Sans Pro Regular-Italic is used
.Ns .
.It Fl -font-bold
Path to .ttf file to use for the bold font. If none provided, Source Sans Pro Bold is used
.Ns .
2022-12-12 07:31:01 +00:00
.It Fl -pad Ar 100
Pixels padded around the rendered diagram
.Ns .
2023-03-23 20:37:28 +00:00
.It Fl -animate-interval Ar 0
If given, multiple boards are packaged as 1 SVG which transitions through each board at the interval (in milliseconds). Can only be used with SVG exports
.Ns .
2023-03-18 03:10:44 +00:00
.It Fl -browser Ar true
2023-03-18 07:48:18 +00:00
Browser executable that watch opens. Setting to 0 opens no browser
2023-03-18 03:10:44 +00:00
.Ns .
2022-11-17 01:13:38 +00:00
.It Fl l , -layout Ar dagre
Set the diagram layout engine to the passed string. For a list of available options, run
.Ar layout
2022-11-17 06:45:08 +00:00
.Ns .
2022-11-14 18:26:37 +00:00
.It Fl b , -bundle Ar true
Bundle all assets and layers into the output svg.
2023-02-05 09:16:24 +00:00
.It Fl -force-appendix Ar false
An appendix for tooltips and links is added to PNG exports since they are not interactive. Setting this to true adds an appendix to SVG exports as well
.Ns .
2022-11-14 18:26:37 +00:00
.It Fl d , -debug
Print debug logs.
.It Fl h , -help
Print usage information and exit.
.It Fl v , -version
Print version information and exit.
.El
.Sh SUBCOMMANDS
.Bl -tag -width Fl
.It Ar layout
Lists available layout engine options with short help.
.It Ar layout Op Ar name
2022-12-30 21:22:45 +00:00
Display long help for a particular layout engine, including its configuration options.
2023-02-05 08:34:43 +00:00
.It Ar themes
Lists available themes.
2023-01-27 14:48:01 +00:00
.It Ar fmt Ar file.d2 ...
Format all passed files.
2022-11-14 18:26:37 +00:00
.El
.Sh SEE ALSO
.Xr d2plugin-tala 1
.Sh AUTHORS
Terrastruct Inc.