blob: 3bc6aa9652c5d4889ce073d9a0efba2ee7eb1cbb (
plain) (
blame)
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
44
45
46
|
package dotty.tools.dottydoc
package js
import scala.scalajs.js
import js.Dynamic.global
import js.JSApp
import js.annotation.{ JSExport, JSName }
import org.scalajs.dom
import model.Entities._
import html.IndexLayout
@JSExport object DottyDocJS {
@JSExport def main(target: dom.html.Div) = {
global.document.title = "Dotty " + Index.currentEntity.path.mkString(".")
target.appendChild(IndexLayout.layout(Index.currentEntity).render)
hljs.initHighlightingOnLoad()
}
}
/** The unpickled AST available as scala classes */
object Index {
import prickle._
import model.Entities._
val packages: Map[String, Package] = Unpickle[Map[String, Package]]
.fromString(js.JSON.stringify(UnparsedIndex.packages))
.toOption
.getOrElse(Map.empty)
val currentEntity: Entity = Unpickle[Entity]
.fromString(js.JSON.stringify(UnparsedIndex.currentEntity))
.toOption
.getOrElse(NonEntity)
}
/** Unparsed index stores the pickled AST generated by the dottydoc tool */
@js.native object UnparsedIndex extends js.Object {
def packages: js.Any = js.native
def currentEntity: js.Any = js.native
}
/** Library wrapper for highlighting */
@js.native object hljs extends js.Object {
def initHighlightingOnLoad(): js.Any = js.native
}
|