From ffb7152e2ea31718201a18658f06786dbb43dd10 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:24:44 +0000 Subject: [PATCH] Bump github.com/emicklei/dot from 1.6.3 to 1.6.4 Bumps [github.com/emicklei/dot](https://github.com/emicklei/dot) from 1.6.3 to 1.6.4. - [Changelog](https://github.com/emicklei/dot/blob/master/CHANGES.md) - [Commits](https://github.com/emicklei/dot/compare/v1.6.3...v1.6.4) --- updated-dependencies: - dependency-name: github.com/emicklei/dot dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/emicklei/dot/CHANGES.md | 3 ++ vendor/github.com/emicklei/dot/mermaid.go | 58 +++++++++++++++++++++-- vendor/modules.txt | 2 +- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index e597074..2a7c76d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/frapposelli/wwhrd go 1.22 require ( - github.com/emicklei/dot v1.6.3 + github.com/emicklei/dot v1.6.4 github.com/google/licensecheck v0.3.1 github.com/jessevdk/go-flags v1.6.1 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index f887a61..952ab4d 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/dot v1.6.3 h1:MW9eLeJWaN+QZVSPlrargGd/l92IA6d4fmo39/YD2cQ= -github.com/emicklei/dot v1.6.3/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= +github.com/emicklei/dot v1.6.4 h1:cG9ycT67d9Yw22G+mAb4XiuUz6E6H1S0zePp/5Cwe/c= +github.com/emicklei/dot v1.6.4/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/google/licensecheck v0.3.1 h1:QoxgoDkaeC4nFrtGN1jV7IPmDCHFNIVh54e5hSt6sPs= github.com/google/licensecheck v0.3.1/go.mod h1:ORkR35t/JjW+emNKtfJDII0zlciG9JgbT7SmsohlHmY= github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4= diff --git a/vendor/github.com/emicklei/dot/CHANGES.md b/vendor/github.com/emicklei/dot/CHANGES.md index 7bfb1b6..9f20a43 100644 --- a/vendor/github.com/emicklei/dot/CHANGES.md +++ b/vendor/github.com/emicklei/dot/CHANGES.md @@ -1,5 +1,8 @@ # Change history of the dot package +## v1.6.4 + +- fix mermaid generation with string shape in node (issue #40) ## v1.6.3 diff --git a/vendor/github.com/emicklei/dot/mermaid.go b/vendor/github.com/emicklei/dot/mermaid.go index 9b2d3a6..df4fa07 100644 --- a/vendor/github.com/emicklei/dot/mermaid.go +++ b/vendor/github.com/emicklei/dot/mermaid.go @@ -80,11 +80,28 @@ func diagramGraph(g *Graph, sb *strings.Builder) { nodeShape := MermaidShapeRound each := g.nodes[key] if s := each.GetAttr("shape"); s != nil { - nodeShape = s.(shape) + // could be a shape or a string + shapeString, ok := s.(string) + if ok { + // see if we can map the string to a shape + mermaidShape, ok := lookupShape(shapeString) + if ok { + nodeShape = mermaidShape + } + } + // could be a shape + mermaidShape, ok := s.(shape) + if ok { + nodeShape = mermaidShape + } } txt := "?" if label := each.GetAttr("label"); label != nil { - txt = label.(string) + // take string only + slabel, ok := label.(string) + if ok { + txt = slabel + } } fmt.Fprintf(sb, "\tn%d%s%s%s;\n", each.seq, nodeShape.open, escape(txt), nodeShape.close) if style := each.GetAttr("style"); style != nil { @@ -103,11 +120,16 @@ func diagramGraph(g *Graph, sb *strings.Builder) { // The edge can override the link style link := denoteEdge if l := each.GetAttr("link"); l != nil { - link = l.(string) + // take string only + slink, ok := l.(string) + if ok { + link = slink + } } if label := each.GetAttr("label"); label != nil { slabel, ok := label.(string) if !ok { + // make it a string slabel = fmt.Sprintf("%v", label) } if label != "" { @@ -124,3 +146,33 @@ func diagramGraph(g *Graph, sb *strings.Builder) { func writeEnd(sb *strings.Builder) { sb.WriteString(";\n") } + +func lookupShape(shapeName string) (shape, bool) { + switch shapeName { + case "round", "box": + return MermaidShapeRound, true + case "asymmetric": + return MermaidShapeAsymmetric, true + case "circle": + return MermaidShapeCircle, true + case "cylinder": + return MermaidShapeCylinder, true + case "rhombux": + return MermaidShapeRhombus, true + case "stadium": + return MermaidShapeStadium, true + case "subroutine": + return MermaidShapeSubroutine, true + case "trapezoid": + return MermaidShapeTrapezoid, true + case "trapezoid-alt": + return MermaidShapeTrapezoidAlt, true + case "hexagon": + return MermaidShapeHexagon, true + case "parallelogram": + return MermaidShapeParallelogram, true + case "parallelogram-alt": + return MermaidShapeParallelogramAlt, true + } + return shape{}, false +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d5c9194..7440e81 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/emicklei/dot v1.6.3 +# github.com/emicklei/dot v1.6.4 ## explicit; go 1.13 github.com/emicklei/dot # github.com/google/licensecheck v0.3.1