如何为scaladoc指定其他源目录?

时间:2014-07-23 21:11:15

标签: sbt scaladoc

由于需要同时使用Eclipse和sbt,我有一些非标准的sbt构建设置。

我的来源位于src/main/scalasrc/com/companyname/[folder1, folder2, etc]目录中。

如何设置sbt,以便为folderX下的其他src/com/companyname文件夹生成文档?

1 个答案:

答案 0 :(得分:1)

tl; dr build.sbt中使用以下内容:

unmanagedSourceDirectories in Compile += sourceDirectory.value

inspect是你的朋友。

> inspect doc
[info] Task: java.io.File
[info] Description:
[info]  Generates API documentation.
[info] Provided by:
[info]  {file:/Users/jacek/sandbox/scaladoc/}scaladoc/compile:doc
[info] Defined at:
[info]  (sbt.Defaults) Defaults.scala:706
[info] Dependencies:
[info]  compile:doc::configuration
[info]  compile:doc::sources
[info]  compile:doc::apiMappings
[info]  compile:doc::target
[info]  compile:doc::fileInputOptions
[info]  compile:doc::streams
[info]  compile:doc::compilers
[info]  compile:doc::scalacOptions
[info]  compile:doc::dependencyClasspath
[info]  compile:doc::maxErrors
[info]  compile:doc::javacOptions
[info] Reverse dependencies:
[info]  *:copyDocAssetsTask
[info] Delegates:
[info]  compile:doc
[info]  *:doc
[info]  {.}/compile:doc
[info]  {.}/*:doc
[info]  */compile:doc
[info]  */*:doc
[info] Related:
[info]  test:doc

Dependencies下,您会发现doc任务取决于compile:doc::sources等。再次使用inspect设置。

> inspect compile:doc::sources
[info] Task: scala.collection.Seq[java.io.File]
[info] Description:
[info]  All sources, both managed and unmanaged.
[info] Provided by:
[info]  {file:/Users/jacek/sandbox/scaladoc/}scaladoc/compile:sources
[info] Defined at:
[info]  (sbt.Defaults) Defaults.scala:187
[info] Reverse dependencies:
[info]  compile:doc
[info] Delegates:
[info]  compile:doc::sources
[info]  compile:sources
[info]  *:doc::sources
[info]  *:sources
[info]  {.}/compile:doc::sources
[info]  {.}/compile:sources
[info]  {.}/*:doc::sources
[info]  {.}/*:sources
[info]  */compile:doc::sources
[info]  */compile:sources
[info]  */*:doc::sources
[info]  */*:sources
[info] Related:
[info]  compile:sources
[info]  test:sources

Dependencies下,您发现它取决于compile:sources,并且您发现应该更改unmanagedSourceDirectories设置以获得您想要的内容。