diff options
-rw-r--r-- | bridge/src/main/scala/xsbt/ScaladocInterface.scala | 19 | ||||
-rw-r--r-- | dottydoc/src/dotty/tools/dottydoc/api/java/Dottydoc.java | 4 | ||||
-rw-r--r-- | dottydoc/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala | 4 | ||||
-rw-r--r-- | dottydoc/src/dotty/tools/dottydoc/util/OutputWriter.scala | 9 | ||||
-rw-r--r-- | project/Build.scala | 53 |
5 files changed, 33 insertions, 56 deletions
diff --git a/bridge/src/main/scala/xsbt/ScaladocInterface.scala b/bridge/src/main/scala/xsbt/ScaladocInterface.scala index 4990676f1..39458bd1d 100644 --- a/bridge/src/main/scala/xsbt/ScaladocInterface.scala +++ b/bridge/src/main/scala/xsbt/ScaladocInterface.scala @@ -12,9 +12,20 @@ class ScaladocInterface { } class DottydocRunner(args: Array[String], log: Logger, delegate: xsbti.Reporter) extends Dottydoc { - def run(): Unit = { - println(args.mkString("Args = List (\n ",",\n ",")")) - //val index = createIndex(args) - //buildDocs(outputDir, templatePath, resources, index) + def run(): Unit = getOutputFolder(args).map { outputFolder => + val index = createIndex(args) + val template = getTemplate(args) + val resources = getResources(args) + + template.fold(writeJson(index, outputFolder)) { tpl => + buildDocs(outputFolder, tpl, resources, index) + } } + + private def getOutputFolder(args: Array[String]): Option[String] = + args sliding(2) find { case Array(x, _) => x == "-d" } map (_.tail.head) + + private def getTemplate(args: Array[String]): Option[String] = None + + private def getResources(args: Array[String]): List[String] = Nil } diff --git a/dottydoc/src/dotty/tools/dottydoc/api/java/Dottydoc.java b/dottydoc/src/dotty/tools/dottydoc/api/java/Dottydoc.java index c2ec29395..c50688c77 100644 --- a/dottydoc/src/dotty/tools/dottydoc/api/java/Dottydoc.java +++ b/dottydoc/src/dotty/tools/dottydoc/api/java/Dottydoc.java @@ -24,4 +24,8 @@ public class Dottydoc extends DottyDocDriver { ) { new OutputWriter().writeJava(index, templatePath, outputDir, resources); } + + public void writeJson(Map<String, Package> index, String outputDir) { + new OutputWriter().writeJsonJava(index, outputDir); + } } diff --git a/dottydoc/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala b/dottydoc/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala index 0b144027b..373fae39a 100644 --- a/dottydoc/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala +++ b/dottydoc/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala @@ -6,10 +6,14 @@ import dotty.tools.dottydoc.util.OutputWriter import scala.collection.Map +/** FIXME: document this class plz */ trait Dottydoc extends DottyDocDriver { def createIndex(args: Array[String]): Map[String, Package] = compiledDocs(args) def buildDocs(outDir: String, templatePath: String, resources: List[String], index: Map[String, Package]) = new OutputWriter().write(index, templatePath, outDir, resources) + + def writeJson(index: Map[String, Package], outputDir: String) = + new OutputWriter().writeJson(index, outputDir) } diff --git a/dottydoc/src/dotty/tools/dottydoc/util/OutputWriter.scala b/dottydoc/src/dotty/tools/dottydoc/util/OutputWriter.scala index 8e288ae7f..d5a48912f 100644 --- a/dottydoc/src/dotty/tools/dottydoc/util/OutputWriter.scala +++ b/dottydoc/src/dotty/tools/dottydoc/util/OutputWriter.scala @@ -17,12 +17,11 @@ import _root_.java.util.{ Map => JMap, List => JList } import model.{ Entity, Package } import model.json._ import com.github.mustachejava.DefaultMustacheFactory - +import scala.collection.JavaConverters._ class OutputWriter { def writeJava(packs: JMap[String, Package], templatePath: String, outPath: String, resources: JList[String]): Unit = { - import scala.collection.JavaConverters._ write(packs.asScala, templatePath, outPath, resources.asScala) } @@ -61,6 +60,12 @@ class OutputWriter { println("Done writing static material, building js-app") } + def writeJsonJava(index: JMap[String, Package], outputDir: String): Unit = + writeJson(index.asScala, outputDir) + + def writeJson(index: collection.Map[String, Package], outputDir: String): Unit = + writeFile(index.json, outputDir + "/", "index.json") + def expandTemplate(templatePath: String, entity: Entity, outPath: String): String = try { import model.json._ import model.java._ diff --git a/project/Build.scala b/project/Build.scala index cabc9d07d..7a9d83a50 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -73,7 +73,9 @@ object DottyBuild extends Build { javaSource in Test := baseDirectory.value / "test", resourceDirectory in Compile := baseDirectory.value / "resources", unmanagedSourceDirectories in Compile := Seq((scalaSource in Compile).value), + unmanagedSourceDirectories in Compile += baseDirectory.value / "dottydoc" / "src", unmanagedSourceDirectories in Test := Seq((scalaSource in Test).value), + unmanagedSourceDirectories in Test += baseDirectory.value / "dottydoc" / "test", // set system in/out for repl connectInput in run := true, @@ -100,6 +102,7 @@ object DottyBuild extends Build { "org.scala-lang.modules" %% "scala-partest" % "1.0.11" % "test", "com.novocode" % "junit-interface" % "0.11" % "test", "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0", + "com.github.spullara.mustache.java" % "compiler" % "0.9.3", "com.typesafe.sbt" % "sbt-interface" % sbtVersion.value), // enable improved incremental compilation algorithm incOptions := incOptions.value.withNameHashing(true), @@ -206,7 +209,6 @@ object DottyBuild extends Build { lazy val `dotty-bridge` = project.in(file("bridge")). dependsOn(dotty). - dependsOn(dottydoc). settings( overrideScalaVersionSetting, @@ -265,55 +267,6 @@ object DottyInjectedPlugin extends AutoPlugin { ). settings(publishing) - lazy val dottydoc = project.in(file("dottydoc")).dependsOn(dotty).settings( - //resources in Compile += (fastOptJS in (dottydocJS, Compile)).value.data, - resourceDirectory in Compile := baseDirectory.value / "resources", - scalaSource in Compile := baseDirectory.value / "src", - javaSource in Compile := baseDirectory.value / "src", - scalaSource in Test := baseDirectory.value / "test", - javaSource in Test := baseDirectory.value / "test", - - libraryDependencies ++= Seq( - "com.novocode" % "junit-interface" % "0.11" % "test", - "com.github.spullara.mustache.java" % "compiler" % "0.9.3" - ), - - // enable improved incremental compilation algorithm - incOptions := incOptions.value.withNameHashing(true), - - mainClass in (Compile, run) := Some("dotty.tools.dottydoc.Main"), - fork in run := true, - fork in Test := true, - parallelExecution in Test := false, - - // http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala - javaOptions <++= (dependencyClasspath in Runtime, packageBin in Compile) map { (attList, bin) => - // put the Scala {library, reflect} in the classpath - val path = for { - file <- attList.map(_.data) - path = file.getAbsolutePath - } yield "-Xbootclasspath/p:" + path - // dotty itself needs to be in the bootclasspath - val fullpath = ("-Xbootclasspath/a:" + bin) :: path.toList - // System.err.println("BOOTPATH: " + fullpath) - - val travis_build = // propagate if this is a travis build - if (sys.props.isDefinedAt(JENKINS_BUILD)) - List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit - else - List() - - val tuning = - if (sys.props.isDefinedAt("Oshort")) - // Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 - List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1") - else - List() - - ("-DpartestParentID=" + pid) :: tuning ::: agentOptions ::: travis_build ::: fullpath - } - ).settings(publishing) - /** A sandbox to play with the Scala.js back-end of dotty. * * This sandbox is compiled with dotty with support for Scala.js. It can be |