@@ -21,15 +21,16 @@ import net.virtualvoid.sbt.graph.{ModuleTree, ModuleTreeNode}
2121import org .pegdown .Printer
2222import org .pegdown .ast .{DirectiveNode , Visitor }
2323
24- class DependenciesDirective (projectIdToDependencies : String => ModuleTree ) extends LeafBlockDirective (" dependencies" ) {
24+ class DependenciesDirective (showLicenses : Boolean )(projectIdToDependencies : String => ModuleTree )
25+ extends LeafBlockDirective (" dependencies" ) {
2526 def render (node : DirectiveNode , visitor : Visitor , printer : Printer ): Unit = {
2627 val projectId = node.attributes.value(" projectId" )
2728 val tree = projectIdToDependencies(projectId)
2829 printer.println()
2930 val classes = Seq (" dependencies" , node.attributes.classesString).filter(_.nonEmpty)
3031 printer.print(s """ <dl class=" ${classes.mkString(" " )}"> """ )
3132 if (tree.roots.flatMap(_.children).nonEmpty) {
32- renderDirect(node, tree.roots, printer)
33+ renderDirect(node, tree.roots, showLicenses, printer)
3334 renderTree(node, tree.roots, printer)
3435 } else {
3536 printer.print(" <dt>Direct dependencies</dt><dd>This module has no dependencies.</dd>" )
@@ -38,10 +39,12 @@ class DependenciesDirective(projectIdToDependencies: String => ModuleTree) exten
3839 printer.println()
3940 }
4041
41- private def renderDirect (node : DirectiveNode , roots : Seq [ModuleTreeNode ], p : Printer ): Unit = {
42+ private def renderDirect (node : DirectiveNode , roots : Seq [ModuleTreeNode ], showLicenses : Boolean , p : Printer ): Unit = {
4243 p.print(" <dt>Direct dependencies</dt><dd><table>" )
4344 p.indent(2 ).println()
44- p.print(" <thead><tr><th>Organization</th><th>Artifact</th><th>Version</th><th>License</th></tr></thead>" ).println()
45+ p.print(" <thead><tr><th>Organization</th><th>Artifact</th><th>Version</th>" )
46+ if (showLicenses) p.print(" <th>License</th></tr>" )
47+ p.print(" </thead>" ).println()
4548 p.print(" <tbody>" )
4649 p.indent(2 )
4750 for {
@@ -61,7 +64,7 @@ class DependenciesDirective(projectIdToDependencies: String => ModuleTree) exten
6164 )
6265 .print(moduleId.version)
6366 .print(" </a></td>" )
64- d.node.license.foreach(l => p.print(" <td>" ).print(l).print(" </td>" ))
67+ if (showLicenses) d.node.license.foreach(l => p.print(" <td>" ).print(l).print(" </td>" ))
6568 p.print(" </tr>" )
6669 }
6770 p.indent(- 2 ).println()
0 commit comments