summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml4
-rw-r--r--src/compiler/scala/tools/nsc/doc/Settings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala13
3 files changed, 15 insertions, 4 deletions
diff --git a/build.xml b/build.xml
index aca2b66106..62fa2ce01f 100644
--- a/build.xml
+++ b/build.xml
@@ -1401,7 +1401,7 @@ DOCUMENTATION
destdir="${build-docs.dir}/library"
doctitle="Scala Standard Library"
docversion="${version.number}"
- docsourceurl="https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/"
+ docsourceurl="https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/€{FILE_PATH}.scala#L1"
sourcepath="${src.dir}"
classpathref="pack.classpath">
<src>
@@ -1489,7 +1489,7 @@ DOCUMENTATION
destdir="${build-docs.dir}/compiler"
doctitle="Scala Compiler"
docversion="${version.number}"
- docsourceurl="https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/"
+ docsourceurl="https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/€{FILE_PATH}.scala#L1"
sourcepath="${src.dir}"
classpathref="pack.classpath"
srcdir="${src.dir}/compiler">
diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala
index b628b3b19c..e567602fae 100644
--- a/src/compiler/scala/tools/nsc/doc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/doc/Settings.scala
@@ -27,7 +27,7 @@ class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) {
/** A setting that defines a URL to be concatenated with source locations and show a link to source files.
* If needed the sourcepath option can be used to exclude undesired initial part of the link to sources */
- val docsourceurl = StringSetting ("-doc-source-url", "url", "The URL prefix where documentation will link to sources", "")
+ val docsourceurl = StringSetting ("-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')", "")
val useStupidTypes = BooleanSetting ("-Yuse-stupid-types", "Print the types of inherited members as seen from their original definition context. Hint: you don't want to do that!")
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index f14bbf4099..fca26e69ce 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -7,6 +7,7 @@ package model
import comment._
import scala.collection._
+import scala.util.matching.Regex
import symtab.Flags
@@ -169,7 +170,17 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory
}
if (!settings.docsourceurl.isDefault)
inSource map { case (file, _) =>
- new java.net.URL(settings.docsourceurl.value + "/" + fixPath(file.path).replaceFirst("^" + assumedSourceRoot, ""))
+ val filePath = fixPath(file.path).replaceFirst("^" + assumedSourceRoot, "").stripSuffix(".scala")
+ val tplOwner = this.inTemplate.qualifiedName
+ val tplName = this.name
+ val patches = new Regex("""€\{(FILE_PATH|TPL_OWNER|TPL_NAME)\}""")
+ val patchedString = patches.replaceAllIn(settings.docsourceurl.value, { m => m.group(1) match {
+ case "FILE_PATH" => filePath
+ case "TPL_OWNER" => tplOwner
+ case "TPL_NAME" => tplName
+ }
+ })
+ new java.net.URL(patchedString)
}
else None
}