Linking to sources from scaladoc?

sbt, scala

Solution

From the output of `scaladoc help`:

-doc-source-url <url>        A URL pattern used to build links to template
                             sources; use variables, for example:
                               €{TPL_NAME} ('Seq'),
                               €{TPL_OWNER} ('scala.collection'),
                               €{FILE_PATH} ('scala/collection/Seq')

(Yes that is the euro symbol.)

Something like the following should work as an argument to sourceUrl if all of your sources are defined in a package:

https://raw.github.com/Rogach/scallop/master/src/main/scala/€{TPL_OWNER}.€{TPL_NAME}.scala

Problem

I need to link to sources on github from my scaladoc. I build those docs with the sbt's `doc` task. There are two problems - first, I do not like creating several nested empty directories for my `.scala` files, so I usually pack them all in one - like `src/main/scala/org.rogach.scallop` instead of `src/main/scala/org/rogach/scallop`. Is there a way to make links to docs work without splitting that directory? Second, when I put this line in my build.sbt: ``` scalacOptions in (Compile, doc) ++= Opts.doc.sourceUrl("https://raw.github.com/Rogach/scallop/master/src/main/scala/") ``` docs contain links to sources, but all those links just point to the source root url, not files themselves. What am I doing wrong?

Original source