I want that Scaladoc generates a type hierarchy diagram for the following code snippet:
trait A trait B extends A
But when I execute scaladoc
there is no type hierarchy shown - neither in A
nor in B
. How can I generate such diagrams?
I want that Scaladoc generates a type hierarchy diagram for the following code snippet:
trait A trait B extends A
But when I execute scaladoc
there is no type hierarchy shown - neither in A
nor in B
. How can I generate such diagrams?
First, one needs Scaladoc2 for this, which is part of Scala 2.10.
If 2.10 is installed, one also needs to pass the -diagrams
option to Scaladoc in order to generate the diagrams. But if you do so it can be that the following error message occurs:
Graphviz dot encountered an error when generating the diagram for: _root_ These are usually spurious errors, but if you notice a persistant error on a diagram, please use the -diagrams-debug flag and report a bug with the output. Graphviz will be restarted...
The error occurs because Scaladoc does not generate the diagrams by itself but tries to call Graphviz, to do this job. When we add the -diagrams-debug
flag we well get among other things the exact error message:
The following is the log of the failure: Main thread in _root_: Exception: java.io.IOException: Cannot run program "dot": java.io.IOException: error=2, No such file or directory
To solve the problem one needs to install the program dot
, which is part of Graphviz. After doing so one should be able to execute scaladoc -diagrams
successfully and see as a result the tag "Type Hierarchy" above the member search bar in the generated documentation.
Executing scaladoc -help
shows further information for the diagrams option:
-diagrams Create inheritance diagrams for classes, traits and packages. -diagrams-dot-path The path to the dot executable used to generate the inheritance diagrams. Eg: /usr/bin/dot -diagrams-dot-restart The number of times to restart a malfunctioning dot process before disabling diagrams (default: 5) -diagrams-dot-timeout The timeout before the graphviz dot util is forcefully closed, in seconds (default: 10) -diagrams-max-classes The maximum number of superclasses or subclasses to show in a diagram -diagrams-max-implicits The maximum number of implicitly converted classes to show in a diagram