Steve H.
Steve H.

Reputation: 253

How to specify additional source directory for scaladoc?

I have a bit of a nonstandard sbt build setup due to the need to use both Eclipse and sbt.

My sources are in src/main/scala and src/com/companyname/[folder1, folder2, etc] directories.

How can I set up sbt so it also generates documentation for these additional folderX folders under src/com/companyname?

Upvotes: 1

Views: 574

Answers (1)

Jacek Laskowski
Jacek Laskowski

Reputation: 74659

tl;dr Use the following in build.sbt:

unmanagedSourceDirectories in Compile += sourceDirectory.value

inspect is your friend.

> 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

Under Dependencies you'll find that doc task depends on compile:doc::sources among other things. Use inspect again with the setting.

> 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

Under Dependencies you find that it depends on compile:sources and following along you find that you should change unmanagedSourceDirectories setting to have what you want.

Upvotes: 1

Related Questions