10

I'm trying to configure the Scaladoc in SBT, specifically the title, output directory and classpath.

I managed to define the title by adding the following to build.sbt:

scalacOptions in (Compile, doc) ++= Opts.doc.title("Scala-Tools")

I can't figure out how to change the doc output directory.

I also can't figure out how to add jars to classpath. The reason I want to edit the classpath is because it appears the standard Scala library is not getting picked up by scaladoc when I refer to its classes, i.e. [[scala.Option]] leads to a warning "Could not find any member to link for "scala.Option"."

Any help, even in the form of an example SBT configuration would be appreciated!

I'm using Scala 2.10-RC3 and SBT 0.12.1.

user510159
  • 1,379
  • 14
  • 26

1 Answers1

6

The Scala library is on the classpath, otherwise scaladoc would bail out with an error pretty quickly. The warning you see means that scaladoc doesn't know how to link to Option. For this, you need to use either the -external-urls option or the -doc-external-doc option coming in 2.10.1. The output of scaladoc -help for the upcoming 2.10.1 shows:

-doc-external-doc:<external-doc>  comma-separated list of classpath_entry_path#doc_URL pairs describing external dependencies.
-external-urls:<externalUrl(s)>   (deprecated) comma-separated list of package_names=doc_URL for external dependencies, where package names are ':'-separated

The solution until 2.10.1 is out is to use -external-uris:

-external-urls:scala=http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/library/
Mark Harrah
  • 6,999
  • 1
  • 26
  • 31
  • Thanks Mark! However, using this solution, I get an error: `[error] source file 'http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/library/' could not be found` – user510159 Dec 12 '12 at 21:25
  • Also, looking at `scaladoc -help`, I can't seem to find anything regarding output directory (the other part of my question). – user510159 Dec 13 '12 at 06:41
  • You should show how you are passing that. I tried it from the command line before posting and it worked. The error message seems to imply that it is getting interpreted as a source file. As for changing the output directory, it is the `-d` option on the command line, but sbt handles it for you with the `docDirectory in Compile` (or `in Test`) setting. Why do you want to change the output directory, though? – Mark Harrah Dec 14 '12 at 18:08
  • @MarkHarrah, your answer works but it's inconvenient; 0.13 has better features, but `autoAPIMappings` doesn't seem to work. Could you take a look at http://stackoverflow.com/q/18747265/53974? – Blaisorblade Sep 11 '13 at 17:31
  • A separate question: http://www.scala-sbt.org/release/docs/Howto/scaladoc.html#manual-api-links suggests these option require 2.10.2, not .1, and this seems to contradict your answer. Should the docs be fixed? – Blaisorblade Sep 11 '13 at 17:36
  • Scala 2.10.2 is the first version that provides the right information in its pom.xml. Scala 2.10.1 is the first version with `-doc-external-doc`. – Mark Harrah Sep 11 '13 at 20:00