UML Class Diagram for Scala
Inspired by xuwei-k/sbt-class-diagram
Table of Contents
Table of content generated by gh-md-toc
Setup
Requirements
You are required to install Graphviz to generate the SVG from the dot file.
If you do not need the generation of the SVG file, you can apply this setting:
classDiagramSettings := classDiagramSettings.value.copy(generateSvg = false)
in your build.sbt
.
Enable plugin
First add
addSbtPlugin("com.leobenkel" % "umlclassdiagram" % "[VERSION]")
to project/plugin.sbt
and then
enablePlugins(UmlClassDiagramPlugin)
to build.sbt
Which connections would you like to show?
To change which connection you would like to display, add this:
classDiagramSettings :=
classDiagramSettings
.value
.copy(
enabledConnectionTypes =
Set(
com.leobenkel.umlclassdiagram.internal.ConnectionType.Inherit,
com.leobenkel.umlclassdiagram.internal.ConnectionType.Produce,
com.leobenkel.umlclassdiagram.internal.ConnectionType.Consume,
com.leobenkel.umlclassdiagram.internal.ConnectionType.Throw,
com.leobenkel.umlclassdiagram.internal.ConnectionType.Enclosing,
),
)
to your build.sbt
.
The possibilities are:
- Inherit
- will connect the classes with their parent trait and classes
- This is the default behavior.
- Produce
- Will connect the classes to the classes that can be returned
- Will not find out about generic type like
Seq[A]
orFoo[A]
- Consume
- Will connect the classes to the classes that are used as arguments
- Throw
- Will connect the classes to the classes being thrown
- Enclosing
- Will connect the classes to the parent class where the class is defined is it exist.
Styling
You can read more about the key/values available for dot graph styling with this document: https://www.graphviz.org/pdf/dotguide.pdf .
Use
To analyze a specific class:
sbt classDiagram path.to.Class
To browse entire package:
sbt classDiagram path.to.package.*
And those can be combined:
sbt classDiagram path.to.Class path.to.package.* pack.to.other.Class
Settings
To open the folder with output files and/or the SVG image
classDiagramSettings := classDiagramSettings.value.copy(openFolder = true, openSvg = true)
in your build.sbt
.
To change the name of the file
classDiagramSettings := classDiagramSettings.value.copy(name = "foo")
in your build.sbt
.