diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala
index 55234b2da..98ca55d39 100644
--- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala
+++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala
@@ -134,12 +134,13 @@ object DependencyGraphSettings {
}
def dependencyDotStringTask =
(moduleGraph, dependencyDotHeader, dependencyDotNodeLabel).map {
- (graph, dotHead, nodeLabel) ⇒ rendering.DOT.dotGraph(graph, dotHead, nodeLabel)
+ (graph, dotHead, nodeLabel) ⇒ rendering.DOT.dotGraph(graph, dotHead, nodeLabel, rendering.DOT.AngleBrackets)
}
def browseGraphHTMLTask =
- (dependencyDotString, dependencyBrowseGraphTarget, streams).map { (graph, target, streams) ⇒
- val link = DagreHTML.createLink(graph, target)
+ (moduleGraph, dependencyDotHeader, dependencyDotNodeLabel, dependencyBrowseGraphTarget, streams).map { (graph, dotHead, nodeLabel, target, streams) ⇒
+ val dotGraph = rendering.DOT.dotGraph(graph, dotHead, nodeLabel, rendering.DOT.LabelTypeHtml)
+ val link = DagreHTML.createLink(dotGraph, target)
streams.log.info(s"HTML graph written to $link")
link
}
diff --git a/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala b/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala
index 181e8b7eb..368cf9e2d 100644
--- a/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala
+++ b/src/main/scala/net/virtualvoid/sbt/graph/rendering/DOT.scala
@@ -22,12 +22,14 @@ object DOT {
def dotGraph(graph: ModuleGraph,
dotHead: String,
- nodeFormation: (String, String, String) ⇒ String): String = {
+ nodeFormation: (String, String, String) ⇒ String,
+ labelRendering: HTMLLabelRendering): String = {
val nodes = {
for (n ← graph.nodes) yield {
val style = if (n.isEvicted) EvictedStyle else ""
- """ "%s"[labelType="html" label="%s" style="%s"]""".format(n.id.idString,
- nodeFormation(n.id.organisation, n.id.name, n.id.version),
+ val label = nodeFormation(n.id.organisation, n.id.name, n.id.version)
+ """ "%s"[%s style="%s"]""".format(n.id.idString,
+ labelRendering.renderLabel(label),
style)
}
}.mkString("\n")
@@ -60,4 +62,22 @@ object DOT {
"%s\n%s\n%s\n}".format(dotHead, nodes, edges)
}
+
+ sealed trait HTMLLabelRendering {
+ def renderLabel(labelText: String): String
+ }
+ /**
+ * Render HTML labels in Angle brackets as defined at http://graphviz.org/content/node-shapes#html
+ */
+ case object AngleBrackets extends HTMLLabelRendering {
+ def renderLabel(labelText: String): String = s"label=<$labelText>"
+ }
+
+ /**
+ * Render HTML labels with `labelType="html"` and label content in double quotes as supported by
+ * dagre-d3
+ */
+ case object LabelTypeHtml extends HTMLLabelRendering {
+ def renderLabel(labelText: String): String = s"""labelType="html" label="$labelText""""
+ }
}
diff --git a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala
index 720d27ddf..d5081feb1 100644
--- a/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala
+++ b/src/sbt-test/sbt-dependency-graph/testDotFileGeneration/project/Build.scala
@@ -34,10 +34,10 @@ object Build extends sbt.Build {
| edge [
| arrowtail="none"
| ]
- | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT"[labelType="html" label="test-dot-file-generation
test-dot-file-generation_2.9.2
0.1-SNAPSHOT" style=""]
- | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT"[labelType="html" label="just-a-transitive-dependency
just-a-transitive-dependency_2.9.2
0.1-SNAPSHOT" style=""]
- | "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT"[labelType="html" label="just-a-transitive-dependency-endpoint
just-a-transitive-dependency-endpoint_2.9.2
0.1-SNAPSHOT" style=""]
- | "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT"[labelType="html" label="just-a-dependency
just-a-dependency_2.9.2
0.1-SNAPSHOT" style=""]
+ | "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT"[label=test-dot-file-generation_2.9.2
0.1-SNAPSHOT> style=""]
+ | "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency_2.9.2
0.1-SNAPSHOT> style=""]
+ | "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT"[label=just-a-transitive-dependency-endpoint_2.9.2
0.1-SNAPSHOT> style=""]
+ | "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT"[label=just-a-dependency_2.9.2
0.1-SNAPSHOT> style=""]
| "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT"
| "just-a-transitive-dependency:just-a-transitive-dependency_2.9.2:0.1-SNAPSHOT" -> "just-a-transitive-dependency-endpoint:just-a-transitive-dependency-endpoint_2.9.2:0.1-SNAPSHOT"
| "test-dot-file-generation:test-dot-file-generation_2.9.2:0.1-SNAPSHOT" -> "just-a-dependency:just-a-dependency_2.9.2:0.1-SNAPSHOT"