aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-05-11 15:57:56 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-08-19 15:37:24 +0200
commit926a81c358b58ea09de86f8d55519cc38bc97034 (patch)
tree1b8a522e3c4edbef1bcc9443f20d22089d9dbf6c
parentbcc75851c42b1e412767dc77465a145e3fb4b5d5 (diff)
downloaddotty-926a81c358b58ea09de86f8d55519cc38bc97034.tar.gz
dotty-926a81c358b58ea09de86f8d55519cc38bc97034.tar.bz2
dotty-926a81c358b58ea09de86f8d55519cc38bc97034.zip
Add option `-Ydoc-output` for specifying output dir
-rw-r--r--.gitignore1
-rwxr-xr-xdottydoc/jvm/resources/MaterialIcons-Regular.eot (renamed from dottydoc/js/static/MaterialIcons-Regular.eot)bin143258 -> 143258 bytes
-rwxr-xr-xdottydoc/jvm/resources/MaterialIcons-Regular.ijmap (renamed from dottydoc/js/static/MaterialIcons-Regular.ijmap)0
-rwxr-xr-xdottydoc/jvm/resources/MaterialIcons-Regular.svg (renamed from dottydoc/js/static/MaterialIcons-Regular.svg)0
-rwxr-xr-xdottydoc/jvm/resources/MaterialIcons-Regular.ttf (renamed from dottydoc/js/static/MaterialIcons-Regular.ttf)bin128180 -> 128180 bytes
-rwxr-xr-xdottydoc/jvm/resources/MaterialIcons-Regular.woff (renamed from dottydoc/js/static/MaterialIcons-Regular.woff)bin78776 -> 78776 bytes
-rwxr-xr-xdottydoc/jvm/resources/MaterialIcons-Regular.woff2 (renamed from dottydoc/js/static/MaterialIcons-Regular.woff2)bin42304 -> 42304 bytes
-rwxr-xr-xdottydoc/jvm/resources/codepoints (renamed from dottydoc/js/static/codepoints)0
-rw-r--r--dottydoc/jvm/resources/github.css (renamed from dottydoc/js/static/github.css)0
-rw-r--r--dottydoc/jvm/resources/highlight.pack.js (renamed from dottydoc/js/static/highlight.pack.js)0
-rw-r--r--dottydoc/jvm/resources/index.css (renamed from dottydoc/js/static/index.css)0
-rwxr-xr-xdottydoc/jvm/resources/material-icons.css (renamed from dottydoc/js/static/material-icons.css)0
-rw-r--r--dottydoc/jvm/resources/material.min.css (renamed from dottydoc/js/static/material.min.css)0
-rw-r--r--dottydoc/jvm/resources/material.min.js (renamed from dottydoc/js/static/material.min.js)0
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala3
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala4
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/util/IndexWriters.scala47
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/util/OutputWriter.scala90
-rw-r--r--dottydoc/jvm/test/WhitelistedStdLibMain.scala2
-rw-r--r--project/Build.scala9
20 files changed, 100 insertions, 56 deletions
diff --git a/.gitignore b/.gitignore
index 05f801961..17eba0468 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,7 @@ scala-scala
# Ignore output files but keep the directory
out/
+build/
!out/.keep
# Ignore build-file
diff --git a/dottydoc/js/static/MaterialIcons-Regular.eot b/dottydoc/jvm/resources/MaterialIcons-Regular.eot
index 70508ebab..70508ebab 100755
--- a/dottydoc/js/static/MaterialIcons-Regular.eot
+++ b/dottydoc/jvm/resources/MaterialIcons-Regular.eot
Binary files differ
diff --git a/dottydoc/js/static/MaterialIcons-Regular.ijmap b/dottydoc/jvm/resources/MaterialIcons-Regular.ijmap
index d9f1d259f..d9f1d259f 100755
--- a/dottydoc/js/static/MaterialIcons-Regular.ijmap
+++ b/dottydoc/jvm/resources/MaterialIcons-Regular.ijmap
diff --git a/dottydoc/js/static/MaterialIcons-Regular.svg b/dottydoc/jvm/resources/MaterialIcons-Regular.svg
index a449327e2..a449327e2 100755
--- a/dottydoc/js/static/MaterialIcons-Regular.svg
+++ b/dottydoc/jvm/resources/MaterialIcons-Regular.svg
diff --git a/dottydoc/js/static/MaterialIcons-Regular.ttf b/dottydoc/jvm/resources/MaterialIcons-Regular.ttf
index 7015564ad..7015564ad 100755
--- a/dottydoc/js/static/MaterialIcons-Regular.ttf
+++ b/dottydoc/jvm/resources/MaterialIcons-Regular.ttf
Binary files differ
diff --git a/dottydoc/js/static/MaterialIcons-Regular.woff b/dottydoc/jvm/resources/MaterialIcons-Regular.woff
index a0bfd17e7..a0bfd17e7 100755
--- a/dottydoc/js/static/MaterialIcons-Regular.woff
+++ b/dottydoc/jvm/resources/MaterialIcons-Regular.woff
Binary files differ
diff --git a/dottydoc/js/static/MaterialIcons-Regular.woff2 b/dottydoc/jvm/resources/MaterialIcons-Regular.woff2
index 20f1f6746..20f1f6746 100755
--- a/dottydoc/js/static/MaterialIcons-Regular.woff2
+++ b/dottydoc/jvm/resources/MaterialIcons-Regular.woff2
Binary files differ
diff --git a/dottydoc/js/static/codepoints b/dottydoc/jvm/resources/codepoints
index 3c8b07507..3c8b07507 100755
--- a/dottydoc/js/static/codepoints
+++ b/dottydoc/jvm/resources/codepoints
diff --git a/dottydoc/js/static/github.css b/dottydoc/jvm/resources/github.css
index 0ea7d8657..0ea7d8657 100644
--- a/dottydoc/js/static/github.css
+++ b/dottydoc/jvm/resources/github.css
diff --git a/dottydoc/js/static/highlight.pack.js b/dottydoc/jvm/resources/highlight.pack.js
index 60dbdab66..60dbdab66 100644
--- a/dottydoc/js/static/highlight.pack.js
+++ b/dottydoc/jvm/resources/highlight.pack.js
diff --git a/dottydoc/js/static/index.css b/dottydoc/jvm/resources/index.css
index 2be323ae7..2be323ae7 100644
--- a/dottydoc/js/static/index.css
+++ b/dottydoc/jvm/resources/index.css
diff --git a/dottydoc/js/static/material-icons.css b/dottydoc/jvm/resources/material-icons.css
index 43c889d6f..43c889d6f 100755
--- a/dottydoc/js/static/material-icons.css
+++ b/dottydoc/jvm/resources/material-icons.css
diff --git a/dottydoc/js/static/material.min.css b/dottydoc/jvm/resources/material.min.css
index e750f8137..e750f8137 100644
--- a/dottydoc/js/static/material.min.css
+++ b/dottydoc/jvm/resources/material.min.css
diff --git a/dottydoc/js/static/material.min.js b/dottydoc/jvm/resources/material.min.js
index c9efeaf98..c9efeaf98 100644
--- a/dottydoc/js/static/material.min.js
+++ b/dottydoc/jvm/resources/material.min.js
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala
index e569a706a..81dc21bbc 100644
--- a/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala
+++ b/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala
@@ -147,8 +147,7 @@ object Phases {
if (out.last == '/') out.dropRight(1)
else out
}
- assert(outputDir == "../js/out")
- if (!ctx.settings.YDocNoWrite.value) util.IndexWriters.writeJs(packages, outputDir)
+ if (!ctx.settings.YDocNoWrite.value) (new util.OutputWriter).write(packages, outputDir)
// (5) Clear caches
commentParser.clear()
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala
index cfac8333d..84630f214 100644
--- a/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala
+++ b/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala
@@ -12,7 +12,7 @@ case class EntityPage(entity: Entity, packages: Map[String, Package]) {
import util.internal.setters._
private def relPath(to: String, from: Entity) = {
- val len = from.path.length + (from match {
+ val len = (from.path.length - 1) + (from match {
case _: Package => 1
case _ => 0
})
@@ -30,7 +30,7 @@ case class EntityPage(entity: Entity, packages: Map[String, Package]) {
script(`type` := "text/javascript", src := relPath("static/material.min.js", entity)),
script(`type` := "text/javascript", src := relPath("static/highlight.pack.js", entity)),
script(`type` := "text/javascript", src := relPath("index.js", entity)),
- script(`type` := "text/javascript", src := relPath("target/scala-2.11/dottydoc-fastopt.js", entity)),
+ script(`type` := "text/javascript", src := relPath("static/dottydoc-fastopt.js", entity)),
link(rel := "stylesheet", href := relPath("static/material-icons.css", entity)),
link(rel := "stylesheet", href := relPath("static/material.min.css", entity)),
link(rel := "stylesheet", href := relPath("static/github.css", entity)),
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/util/IndexWriters.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/util/IndexWriters.scala
deleted file mode 100644
index 65ed70773..000000000
--- a/dottydoc/jvm/src/dotty/tools/dottydoc/util/IndexWriters.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package dotty.tools.dottydoc
-package util
-
-object IndexWriters {
- import html.EntityPage
- import model.Package
- import model.pickling._
- import prickle._
-
- def writeJs(packs: Map[String, Package], outPath: String): Unit = {
- for (pack <- packs.values) {
- println(s"""Writing '${pack.path.mkString(".")}'""")
- writeFile(
- EntityPage(pack, packs).render,
- outPath + pack.path.mkString("/", "/", "/"),
- "index.html")
-
- for {
- child <- pack.children
- if child.kind != "package"
- } {
- println(s"""Writing '${child.path.mkString(".")}'""")
- writeFile(
- EntityPage(child, packs).render,
- outPath + child.path.dropRight(1).mkString("/", "/", "/"),
- child.path.last + ".html")
- }
- }
-
- val pickled = Pickle.intoString(packs)
- val js = "UnparsedIndex = {}; UnparsedIndex.packages = " + pickled + ";"
- println("Writing index.js...")
- writeFile(js, outPath + "/../", "index.js")
- println("Done writing static material, building js-app")
-
- }
-
- def writeFile(str: String, path: String, file: String): Unit = {
- def printToFile(f: java.io.File)(op: java.io.PrintWriter => Unit) {
- val p = new java.io.PrintWriter(f)
- try { op(p) } finally { p.close() }
- }
-
- new java.io.File(path).mkdirs()
- printToFile(new java.io.File(path + file))(_.println(str))
- }
-}
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/util/OutputWriter.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/util/OutputWriter.scala
new file mode 100644
index 000000000..f2a6c7e95
--- /dev/null
+++ b/dottydoc/jvm/src/dotty/tools/dottydoc/util/OutputWriter.scala
@@ -0,0 +1,90 @@
+package dotty.tools.dottydoc
+package util
+
+
+class OutputWriter {
+ import java.io.{File => JFile, BufferedInputStream, FileInputStream, FileOutputStream, BufferedOutputStream}
+ import html.EntityPage
+ import model.Package
+ import model.pickling._
+ import prickle._
+
+ def write(packs: Map[String, Package], outPath: String): Unit = {
+ // Write all packages to `outPath`
+ for (pack <- packs.values) {
+ println(s"""Writing '${pack.path.mkString(".")}'""")
+ writeFile(
+ EntityPage(pack, packs).render,
+ outPath + pack.path.mkString("/", "/", "/"),
+ "index.html")
+
+ // Write all package children to outPath
+ for {
+ child <- pack.children
+ if child.kind != "package"
+ } {
+ println(s"""Writing '${child.path.mkString(".")}'""")
+ writeFile(
+ EntityPage(child, packs).render,
+ outPath + child.path.dropRight(1).mkString("/", "/", "/"),
+ child.path.last + ".html")
+ }
+ }
+
+ // Write full index to outPath
+ val pickled = Pickle.intoString(packs)
+ val js = "UnparsedIndex = {}; UnparsedIndex.packages = " + pickled + ";"
+ println("Writing index.js...")
+ writeFile(js, outPath + "/", "index.js")
+
+ // Write resources to outPath
+ println("Copying CSS/JS resources to destination...")
+ assert(resources.nonEmpty)
+ resources.map(copy(_, outPath))
+
+ println("Done writing static material, building js-app")
+ }
+
+ def writeFile(str: String, path: String, file: String): Unit =
+ writeFile(str.map(_.toByte).toArray, path, file)
+
+ def writeFile(bytes: Array[Byte], path: String, file: String): Unit = {
+ def printToFile(f: java.io.File)(op: java.io.PrintWriter => Unit) = {
+ val bos = new BufferedOutputStream(new FileOutputStream(f))
+ try {
+ Stream.continually(bos.write(bytes))
+ } finally bos.close()
+ }
+
+ new java.io.File(path).mkdirs()
+ printToFile(new java.io.File(path + file))(printer => bytes.foreach(printer.print))
+ }
+
+ def copy(src: JFile, path: String): Unit = {
+ val reader = new BufferedInputStream(new FileInputStream(src))
+ try {
+ val bytes = Stream.continually(reader.read).takeWhile(-1 != _).map(_.toByte)
+ writeFile(bytes.toArray, path + "/static/", src.getName)
+ } finally reader.close()
+ }
+
+ /** All static resources */
+ private val resources: Iterable[JFile] = List(
+ "/MaterialIcons-Regular.eot",
+ "/MaterialIcons-Regular.ijmap",
+ "/MaterialIcons-Regular.svg",
+ "/MaterialIcons-Regular.ttf",
+ "/MaterialIcons-Regular.woff",
+ "/MaterialIcons-Regular.woff2",
+ "/codepoints",
+ "/github.css",
+ "/highlight.pack.js",
+ "/index.css",
+ "/material-icons.css",
+ "/material.min.css",
+ "/material.min.js",
+ "/dottydoc-fastopt.js"
+ ).map { f =>
+ new JFile(this.getClass.getResource(f).toURI)
+ }
+}
diff --git a/dottydoc/jvm/test/WhitelistedStdLibMain.scala b/dottydoc/jvm/test/WhitelistedStdLibMain.scala
index d4c8206a9..49e8f4fc5 100644
--- a/dottydoc/jvm/test/WhitelistedStdLibMain.scala
+++ b/dottydoc/jvm/test/WhitelistedStdLibMain.scala
@@ -19,5 +19,5 @@ object WhitelistedStandardLib extends DottyDoc {
}
override def main(args: Array[String]) =
- super.main("-language:Scala2" +: "-Ydoc-output" +: "../js/out" +: files.toArray)
+ super.main("-language:Scala2" +: "-Ydoc-output" +: "../../build/dottydoc" +: files.toArray)
}
diff --git a/project/Build.scala b/project/Build.scala
index add3ebecb..e0edd571e 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -278,10 +278,11 @@ object DottyInjectedPlugin extends AutoPlugin {
)
lazy val dottydocJVM = dottydoc.jvm.dependsOn(dotty).settings(
- resources in Compile += (fastOptJS in (dottydocJS, Compile)).value.data,
- scalaSource in Compile := baseDirectory.value / "src",
- scalaSource in Test := baseDirectory.value / "test",
- javaSource in Test := baseDirectory.value / "test",
+ resources in Compile += (fastOptJS in (dottydocJS, Compile)).value.data,
+ resourceDirectory in Compile := baseDirectory.value / "resources",
+ scalaSource in Compile := baseDirectory.value / "src",
+ scalaSource in Test := baseDirectory.value / "test",
+ javaSource in Test := baseDirectory.value / "test",
libraryDependencies ++= Seq(
"org.scala-js" % "scalajs-dom_sjs0.6_2.11" % "0.9.0",