I'm trying to link classes from the JDK into the scaladoc-generated doc.
I've used the -doc-external-doc
option of scaladoc 2.10.1 but without success.
I'm using -doc-external-doc:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar#http://docs.oracle.com/javase/7/docs/api/
, but I get links such as index.html#java.io.File
instead of index.html?java/io/File.html
.
Seems like this option only works for scaladoc-generated doc.
Did I miss an option in scaladoc or should I fill a feature request?
I've configured sbt as follows:
scalacOptions in (Compile,doc) += "-doc-external-doc:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar#http://docs.oracle.com/javase/7/docs/api"
Note: I've seen the Opts.doc.externalAPI
util in the upcoming sbt 0.13. I think a nice addition (not sure if it's possible) would be to pass a ModuleID
instead of a File
. The util would figure out which file corresponds to the ModuleID
.
I took the answer by @jacek-laskowski and modified it so that it avoid hard-coded strings and could be used for any number of Java libraries, not just the standard one.
Edit: the location of
rt.jar
is now determined from the runtime usingsun.boot.class.path
and does not have to be hard coded.The only thing you need to modify is the map, which I have called
externalJavadocMap
in the following:I am using SBT 0.13.8.
I use sbt 0.13.5.
There's no out-of-the-box way to have the feature of having Javadoc links inside scaladoc. And as my understanding goes, it's not sbt's fault, but the way scaladoc works. As Josh pointed out in his comment You should report to scaladoc.
There's however a workaround I came up with - postprocess the
doc
-generated scaladoc so the Java URLs get replaced to form proper Javadoc links.The file scaladoc.sbt should be placed inside a sbt project and whenever
doc
task gets executed, the postprocessing viafixJavaLinksTask
task kicks in.NOTE There are lots of hardcoded paths so use it with caution (aka do the polishing however you see fit).