我想这Scaladoc生成下面的代码片段类型层次结构图:
trait A
trait B extends A
但是,当我执行scaladoc <file>.scala
没有显示出有类型的层次结构-既不A
也不在B
。 我怎样才能产生这样的图表?
我想这Scaladoc生成下面的代码片段类型层次结构图:
trait A
trait B extends A
但是,当我执行scaladoc <file>.scala
没有显示出有类型的层次结构-既不A
也不在B
。 我怎样才能产生这样的图表?
首先,需要Scaladoc2这一点,这是斯卡拉2.10的一部分。
如果安装了2.10,人们还需要通过-diagrams
选项Scaladoc以生成图表。 但是,如果你做到这一点,可以是出现以下错误信息:
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...
错误发生,因为Scaladoc不会产生自身的图表,但试图调用Graphviz的 ,做这个工作。 当我们添加-diagrams-debug
标志,我们也尤其得到确切的错误信息:
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
为了解决一个需要安装的程序的问题dot
,这是Graphviz的一部分。 这样做之后应该能够执行scaladoc -diagrams <file>.scala
成功和看其结果,变量“类型层次”所生成的文档中的构件搜索栏的上方。
执行scaladoc -help
显示图表选项的详细信息:
-diagrams Create inheritance diagrams for classes, traits and packages.
-diagrams-dot-path <path> The path to the dot executable used to generate the inheritance diagrams. Eg: /usr/bin/dot
-diagrams-dot-restart <n> The number of times to restart a malfunctioning dot process before disabling diagrams (default: 5)
-diagrams-dot-timeout <n> The timeout before the graphviz dot util is forcefully closed, in seconds (default: 10)
-diagrams-max-classes <n> The maximum number of superclasses or subclasses to show in a diagram
-diagrams-max-implicits <n> The maximum number of implicitly converted classes to show in a diagram