1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package dotty.tools.dottydoc
package util
object IndexWriters {
import prickle._
import model.Entities._
import model.Html._
def writeJs(packs: Map[String, Package], outPath: String): Unit = {
for ((_, pack) <- packs) {
println(s"""Writing '${pack.path.mkString(".")}'""")
writeFile(
entityHtml(pack),
outPath + pack.path.tail.mkString("/", "/", "/"),
"index.html")
for (child <- pack.children) {
println(s"""Writing '${child.path.mkString(".")}'""")
writeFile(
entityHtml(child),
outPath + child.path.dropRight(1).mkString("/", "/", "/"),
child.path.last + ".html")
}
}
val pickled = Pickle.intoString(packs)
val js = "Index = {}; Index.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))
}
}
|