Skip to content

Commit

Permalink
fixed bug + added more debug info pzdr
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr.suwala committed Apr 17, 2024
1 parent b236f20 commit b75fcff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/kotlin/sh/hsp/techtree/graphviz/DSLConverter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class DSLConverter {
.map { registerNode(it) }
.collect(Collectors.joining(" "))

return "digraph { graph [splines=\"ortho\"] node [shape=\"box\"] edge [dir=\"back\"] $nodesAsDSL }"
return "digraph { graph [splines=\"ortho\"] node [shape=\"box\"] edge [dir=\"back\"] \n $nodesAsDSL }"
}

private fun registerNode(node: TreeNode): String {
val pathsToChildren = node.requires?.apply {
stream()
val pathsToChildren = node.requires?.let {require ->
require.stream()
.map { "${node.title.escaped()} -> ${it.escaped()}" }
.collect(Collectors.joining(" "))
} ?: listOf()
return "${node.title.escaped()} ${node.link?.let { "[ href=${it.escaped()} fontcolor=blue]" } ?: ""} $pathsToChildren"
} ?: ""
return "${node.title.escaped()} ${node.link?.let { "[ href=${it.escaped()} fontcolor=blue ]" } ?: ""} $pathsToChildren \n"
}

private fun String.escaped(): String = "\"$this\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class GraphvizCommandRunner {
fun run(dsl: String) {
ProcessBuilder()
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.command("dot", "-Tsvg").start()
.apply {
outputStream.writer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SimpleGraphvizConverter(
) : GraphvizConverter {
override fun convert(model: TreeModel) {
val dsl = dslConverter.convert(model)
System.err.println(dsl)
commandRunner.run(dsl)
}
}

0 comments on commit b75fcff

Please sign in to comment.