diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-08-15 17:58:41 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-08-19 15:37:34 +0200 |
commit | d6b5c3e0404b754c2bef432b3227cf8f61bc8896 (patch) | |
tree | 4a09f037bd64d474f4f880dbf5baa99b497cfb4a /bridge/src | |
parent | bd7751924d9c145accf04b69e71621347d2b77f6 (diff) | |
download | dotty-d6b5c3e0404b754c2bef432b3227cf8f61bc8896.tar.gz dotty-d6b5c3e0404b754c2bef432b3227cf8f61bc8896.tar.bz2 dotty-d6b5c3e0404b754c2bef432b3227cf8f61bc8896.zip |
Implement dotty bridge for doc
Diffstat (limited to 'bridge/src')
-rw-r--r-- | bridge/src/main/scala/xsbt/ScaladocInterface.scala | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/bridge/src/main/scala/xsbt/ScaladocInterface.scala b/bridge/src/main/scala/xsbt/ScaladocInterface.scala index 42f4296fe..3ad9c7941 100644 --- a/bridge/src/main/scala/xsbt/ScaladocInterface.scala +++ b/bridge/src/main/scala/xsbt/ScaladocInterface.scala @@ -5,6 +5,7 @@ package xsbt import xsbti.Logger import dotty.tools.dottydoc.api.scala.Dottydoc +import java.net.URL class ScaladocInterface { def run(args: Array[String], log: Logger, delegate: xsbti.Reporter) = @@ -14,8 +15,8 @@ class ScaladocInterface { class DottydocRunner(args: Array[String], log: Logger, delegate: xsbti.Reporter) extends Dottydoc { def run(): Unit = getOutputFolder(args).map { outputFolder => val index = createIndex(args) - val template = getTemplate(args) val resources = getResources(args) + val template = getTemplate(resources) template.fold(writeJson(index, outputFolder)) { tpl => buildDocs(outputFolder, tpl, resources, index) @@ -44,15 +45,28 @@ class DottydocRunner(args: Array[String], log: Logger, delegate: xsbti.Reporter) private def getOutputFolder(args: Array[String]): Option[String] = args sliding(2) find { case Array(x, _) => x == "-d" } map (_.tail.head.trim) - private def getTemplate(args: Array[String]): Option[String] = - getStringSetting("-template:") + private def getTemplate(resources: List[URL]): Option[URL] = + resources.find(_.getFile.endsWith("template.html")) - private def getResources(args: Array[String]): List[String] = - getStringSetting("-resources:").map { path => - val dir = new java.io.File(path) - if (dir.exists && dir.isDirectory) - dir.listFiles.filter(_.isFile).map(_.getAbsolutePath).toList - else Nil - }.getOrElse(Nil) + private def getResources(args: Array[String]): List[URL] = { + val cp = args sliding (2) find { case Array(x, _) => x == "-classpath" } map (_.tail.head.trim) getOrElse "" + cp.split(":").find(_.endsWith("dottydoc-client.jar")).map { resourceJar => + import java.util.jar.JarFile + val jarEntries = (new JarFile(resourceJar)).entries + var entries: List[URL] = Nil + + while (jarEntries.hasMoreElements) { + val entry = jarEntries.nextElement() + + if (!entry.isDirectory()) { + val path = s"jar:file:$resourceJar!/${entry.getName}" + val url = new URL(path) + entries = url :: entries + } + } + + entries + } getOrElse (Nil) + } } |