From bab37c1ef8220ab7fb92ea22b98e5941989fa721 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Thu, 21 Aug 2025 11:00:41 -0500 Subject: [PATCH] don't print outline unless used --- main.go | 6 ++++-- testdata/no-outline.txtar | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 testdata/no-outline.txtar diff --git a/main.go b/main.go index 16f5e2d..be49512 100644 --- a/main.go +++ b/main.go @@ -76,8 +76,10 @@ func Main() int { fmt.Printf("\tclick %[1]s-repo href \"https://%s%[1]s\"\n", repo, *prefix) } - fmt.Println("\n\tclassDef outline stroke-dasharray:6,fill:none;") - fmt.Printf("\tclass %s outline\n", strings.Join(subgraphs, ",")) + if len(subgraphs) > 0 { + fmt.Println("\n\tclassDef outline stroke-dasharray:6,fill:none;") + fmt.Printf("\tclass %s outline\n", strings.Join(subgraphs, ",")) + } return 0 } diff --git a/testdata/no-outline.txtar b/testdata/no-outline.txtar new file mode 100644 index 0000000..731e2a9 --- /dev/null +++ b/testdata/no-outline.txtar @@ -0,0 +1,16 @@ +stdin go-mod-graph.txt +exec modgraph -prefix github.com/example/ +cmp stdout go.md + +-- go-mod-graph.txt -- +github.com/example/foo github.com/example/bar +github.com/example/bar github.com/example/baz +github.com/example/foo github.com/example/baz + +-- go.md -- + bar --> baz + click bar href "https://github.com/example/bar" + baz + click baz href "https://github.com/example/baz" + foo --> bar + click foo href "https://github.com/example/foo"