I'd like the ScalaDoc I generate with sbt to link to external libraries, and in sbt 0.13 we have autoAPIMappings
which is supposed to add these links for libraries that declare their apiURL
. In practice though, none of the libraries I use provide this in their pom/ivy metadata, and I suspect some of these libraries will never do so.
The apiMappings
setting is supposed to help with just that, but it is typed as Map[File, URL]
and hence geared towards setting doc urls for unmanaged dependencies. Managed dependencies are declared as instances of sbt.ModuleID
and cannot be inserted directly in that map.
Can I somehow populate the apiMappings
setting with something that will associate an URL with a managed dependency ?
A related question is: does sbt provide an idiomatic way of getting a File
from a ModuleID
? I guess I could try to evaluate some classpaths and get back File
s to try and map them to ModuleID
s but I hope there is something simpler.
Note: this is related to https://stackoverflow.com/questions/18747265/sbt-scaladoc-configuration-for-the-standard-library/18747266, but that question differs by linking to the scaladoc for the standard library, for which there is a well known File
scalaInstance.value.libraryJar
, which is not the case in this instance.
I managed to get this working for referencing scalaz and play by doing the following:
YMMV of course.
Alternatively to my last suggestion, the sbt-api-mappings plugin by ThoughtWorks shows a lot of promise. Long term, that's a far more sustainable route than each project maintaining its own set of mappings.
The accepted answer is good, but it'll fail when assumptions about exact project dependencies don't hold. Here's a variation that might prove useful:
(Including
scala-library
here is redundant, but useful for illustration purposes.)If you perform
mappings foreach println
, you'll get output like (note that I don't have Akka in my dependencies):This approach:
Nil
provided tonames
, all modules for an organization.Those improvements allow you to create a separate SBT file (call it
scaladocMappings.sbt
) that can be maintained in a single location and easily copy and pasted into any project.