From 3f8e752968509c769b9beecf7e06d7b433242bc8 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 5 Feb 2023 00:19:14 -0800 Subject: [PATCH 1/5] add links --- ci/release/template/man/d2.1 | 9 +++++++++ help.go | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ci/release/template/man/d2.1 b/ci/release/template/man/d2.1 index 2d4876a23..90a7abec7 100644 --- a/ci/release/template/man/d2.1 +++ b/ci/release/template/man/d2.1 @@ -41,6 +41,15 @@ render anyway to enable iteration on a broken diagram. .Pp See more docs, the source code and license at .Lk https://oss.terrastruct.com/d2 +.Ns . +.Pp +Hosted icons at +.Lk https://icons.terrastruct.com +.Ns . +.Pp +Playground runner at +.Lk https://play.d2lang.com +.Ns . .Sh OPTIONS .Bl -tag -width Fl .It Fl w , -watch Ar false diff --git a/help.go b/help.go index 7a5446047..05be4b4ab 100644 --- a/help.go +++ b/help.go @@ -35,7 +35,9 @@ Subcommands: %[1]s layout [name] - Display long help for a particular layout engine, including its configuration options %[1]s fmt file.d2 ... - Format passed files -See more docs and the source code at https://oss.terrastruct.com/d2 +See more docs and the source code at https://oss.terrastruct.com/d2. +Hosted icons at https://icons.terrastruct.com. +Playground runner at https://play.d2lang.com. `, filepath.Base(ms.Name), ms.Opts.Defaults()) } From bec0332619b1aec76162ed87c50e0ab72a6c7f6a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 5 Feb 2023 00:34:43 -0800 Subject: [PATCH 2/5] update cli docs --- ci/release/template/man/d2.1 | 5 +++-- help.go | 6 ++++++ main.go | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ci/release/template/man/d2.1 b/ci/release/template/man/d2.1 index 90a7abec7..d6d3f3cc4 100644 --- a/ci/release/template/man/d2.1 +++ b/ci/release/template/man/d2.1 @@ -64,8 +64,7 @@ Port listening address when used with .Ar watch .Ns . .It Fl t , -theme Ar 0 -Set the diagram theme to the passed integer. For a list of available options, see -.Lk https://oss.terrastruct.com/d2 +Set the diagram theme ID .Ns . .It Fl s , -sketch Ar false Renders the diagram to look like it was sketched by hand @@ -92,6 +91,8 @@ Print version information and exit. Lists available layout engine options with short help. .It Ar layout Op Ar name Display long help for a particular layout engine, including its configuration options. +.It Ar themes +Lists available themes. .It Ar fmt Ar file.d2 ... Format all passed files. .El diff --git a/help.go b/help.go index 05be4b4ab..f78369f07 100644 --- a/help.go +++ b/help.go @@ -12,6 +12,7 @@ import ( "oss.terrastruct.com/util-go/xmain" "oss.terrastruct.com/d2/d2plugin" + "oss.terrastruct.com/d2/d2themes/d2themescatalog" ) func help(ms *xmain.State) { @@ -33,6 +34,7 @@ Flags: Subcommands: %[1]s layout - Lists available layout engine options with short help %[1]s layout [name] - Display long help for a particular layout engine, including its configuration options + %[1]s themes - Lists available themes %[1]s fmt file.d2 ... - Format passed files See more docs and the source code at https://oss.terrastruct.com/d2. @@ -51,6 +53,10 @@ func layoutCmd(ctx context.Context, ms *xmain.State, ps []d2plugin.Plugin) error } } +func themesCmd(ctx context.Context, ms *xmain.State) { + fmt.Fprintf(ms.Stdout, "Available themes:\n%s", d2themescatalog.CLIString()) +} + func shortLayoutHelp(ctx context.Context, ms *xmain.State, ps []d2plugin.Plugin) error { var pluginLines []string pinfos, err := d2plugin.ListPluginInfos(ctx, ps) diff --git a/main.go b/main.go index f2b4bcd82..08673a0cf 100644 --- a/main.go +++ b/main.go @@ -60,7 +60,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { return err } layoutFlag := ms.Opts.String("D2_LAYOUT", "layout", "l", "dagre", `the layout engine used`) - themeFlag, err := ms.Opts.Int64("D2_THEME", "theme", "t", 0, "the diagram theme ID. For a list of available options, see https://oss.terrastruct.com/d2") + themeFlag, err := ms.Opts.Int64("D2_THEME", "theme", "t", 0, "the diagram theme ID") if err != nil { return err } @@ -102,6 +102,9 @@ func run(ctx context.Context, ms *xmain.State) (err error) { return initPlaywright() case "layout": return layoutCmd(ctx, ms, ps) + case "themes": + themesCmd(ctx, ms) + return nil case "fmt": return fmtCmd(ctx, ms) case "version": From 2a7febde3d06d3c0f29b142b0cfb43f3bce0169d Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 5 Feb 2023 00:35:55 -0800 Subject: [PATCH 3/5] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index bfadf2bd1..bdd885715 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -24,6 +24,7 @@ - Improves package shape dimensions with short height. [#702](https://github.com/terrastruct/d2/pull/702) - Keeps person shape from becoming too distorted. [#702](https://github.com/terrastruct/d2/pull/702) - Ensures shapes with icons have enough padding for their labels. [#702](https://github.com/terrastruct/d2/pull/702) +- `d2 themes` command added to list themes. [#760](https://github.com/terrastruct/d2/pull/760) #### Bugfixes ⛑️ From 8e27d798632eba41e79d2acf926bd72f761db4bf Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 5 Feb 2023 00:36:31 -0800 Subject: [PATCH 4/5] update --- ci/release/changelogs/next.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index bdd885715..d4a0ec177 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -24,7 +24,7 @@ - Improves package shape dimensions with short height. [#702](https://github.com/terrastruct/d2/pull/702) - Keeps person shape from becoming too distorted. [#702](https://github.com/terrastruct/d2/pull/702) - Ensures shapes with icons have enough padding for their labels. [#702](https://github.com/terrastruct/d2/pull/702) -- `d2 themes` command added to list themes. [#760](https://github.com/terrastruct/d2/pull/760) +- `d2 themes` subcommand to list themes. [#760](https://github.com/terrastruct/d2/pull/760) #### Bugfixes ⛑️ From e3355bfac0ea2d612952da0945545703c70abfb2 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 5 Feb 2023 00:41:00 -0800 Subject: [PATCH 5/5] update layout link --- d2plugin/plugin_dagre.go | 4 ++-- d2plugin/plugin_elk.go | 4 ++-- help.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/d2plugin/plugin_dagre.go b/d2plugin/plugin_dagre.go index c3f16a8f1..37c18a268 100644 --- a/d2plugin/plugin_dagre.go +++ b/d2plugin/plugin_dagre.go @@ -68,9 +68,9 @@ func (p dagrePlugin) Info(ctx context.Context) (*PluginInfo, error) { Name: "dagre", ShortHelp: "The directed graph layout library Dagre", LongHelp: fmt.Sprintf(`dagre is a directed graph layout library for JavaScript. -See https://github.com/dagrejs/dagre +See https://d2lang.com/tour/dagre for more. -Flags correspond to ones found at https://github.com/dagrejs/dagre/wiki. See dagre's reference for more on each. +Flags correspond to ones found at https://github.com/dagrejs/dagre/wiki. Flags: %s diff --git a/d2plugin/plugin_elk.go b/d2plugin/plugin_elk.go index 631e953ba..3f5210249 100644 --- a/d2plugin/plugin_elk.go +++ b/d2plugin/plugin_elk.go @@ -89,9 +89,9 @@ func (p elkPlugin) Info(ctx context.Context) (*PluginInfo, error) { ShortHelp: "Eclipse Layout Kernel (ELK) with the Layered algorithm.", LongHelp: fmt.Sprintf(`ELK is a layout engine offered by Eclipse. Originally written in Java, it has been ported to Javascript and cross-compiled into D2. -See https://github.com/kieler/elkjs for more. +See https://d2lang.com/tour/elk for more. -Flags correspond to ones found at https://www.eclipse.org/elk/reference.html. See ELK's reference for more on each. +Flags correspond to ones found at https://www.eclipse.org/elk/reference.html. Flags: %s diff --git a/help.go b/help.go index f78369f07..fb3be9a1b 100644 --- a/help.go +++ b/help.go @@ -85,7 +85,7 @@ Example: Subcommands: %s layout [layout name] - Display long help for a particular layout engine, including its configuration options -See more docs at https://oss.terrastruct.com/d2 +See more docs at https://d2lang.com/tour/layouts `, strings.Join(pluginLines, "\n"), ms.Name) return nil }