aboutsummaryrefslogtreecommitdiff
path: root/dottydoc/jvm/src
diff options
context:
space:
mode:
Diffstat (limited to 'dottydoc/jvm/src')
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/html/CustomTags.scala12
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala127
2 files changed, 2 insertions, 137 deletions
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/html/CustomTags.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/html/CustomTags.scala
deleted file mode 100644
index ed462f21b..000000000
--- a/dottydoc/jvm/src/dotty/tools/dottydoc/html/CustomTags.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-package dotty.tools.dottydoc
-package html
-
-import scalatags.Text.all._
-import scalatags.generic
-import scalatags.generic.Util
-import org.scalajs.dom
-
-object CustomTags {
- lazy val nav = "nav".tag
- lazy val main = "main".tag
-}
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala
index 3ace813f0..6eee9abf9 100644
--- a/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala
+++ b/dottydoc/jvm/src/dotty/tools/dottydoc/html/EntityPage.scala
@@ -5,7 +5,6 @@ import scalatags.Text.all._
import model._
case class EntityPage(entity: Entity, packages: Map[String, Package]) {
- import CustomTags._
import model.json._
import util.internal.setters._
@@ -34,134 +33,12 @@ case class EntityPage(entity: Entity, packages: Map[String, Package]) {
link(rel := "stylesheet", href := relPath("static/github.css", entity)),
link(rel := "stylesheet", href := relPath("static/index.css", entity))
),
- body(
- div(
- id := "main-container",
- div(
- cls := "mdl-layout mdl-js-layout mdl-layout--fixed-drawer",
- div(
- cls := "mdl-layout__drawer",
- span(
- cls := "mdl-layout-title subtitle",
- entity.path.dropRight(1).mkString(".")
- ),
- span(
- cls := "mdl-layout-title",
- entity match {
- case p: Package => p.name.split("\\.").last
- case e => e.name
- }
- ),
- nav(
- cls := "related mdl-navigation",
- companionAnchor,
- a(cls := "mdl-navigation__link", href := "#", "Source")
- ),
- span(
- cls := "mdl-layout-title",
- id := "docs-title",
- "Docs"
- ),
- searchView,
- packageView
- ),
- main(
- id := "entity-container",
- cls := "mdl-layout__content"
- ),
- main(
- id := "search-results",
- cls := "mdl-layout__content"
- )
- )
- )
- ),
+ body(div(id := "main-container")),
script(
raw(s"""|UnparsedIndex.currentEntity = ${entity.flat.json};
|dotty.tools.dottydoc.js.DottyDocJS()
- | .main(document.getElementById("entity-container"));
+ | .main(document.getElementById("main-container"));
""".stripMargin)
)
)
-
- private def relativePath(to: Entity) = {
- val prefix = entity match {
- case _: Package => "../"
- case _ => ""
- }
- prefix + util.traversing.relativePath(entity, to)
- }
-
- def packageView = ul(
- cls := "mdl-list packages",
- {
- val keys: Seq[String] = packages.keys.toSeq.sorted
- val productReg = """^Product[0-9]+$""".r
- keys.flatMap { k =>
- val pack = packages(k)
- val children =
- pack.children
- .sortBy(_.name)
- .filterNot { ent =>
- // Filter out ProductX where X > 3
- productReg.findFirstIn(ent.name).map(_.slice(7, 99).toInt > 3).getOrElse(false) ||
- // Filter out packages
- ent.kind == "package" ||
- // Filter out objects that have companions
- (ent.kind == "object" && companion(ent).isDefined) ||
- ent.name == "AnyValCompanion"
- }
- .map { entity =>
- val comp = companion(entity)
- val entityUrl = relativePath(entity)
- val compUrl = comp.map(relativePath).getOrElse("#")
- li(
- cls := s"""mdl-list__item entity ${ if (comp.isDefined) "two" else "one" }""",
- comp.map { _ => a(cls := "entity-button object", href := compUrl, "O") }.getOrElse(()),
- a(
- cls := s"""entity-button shadowed ${entity.kind.replaceAll(" ", "")}""",
- href := entityUrl,
- entity.kind(0).toUpper.toString
- ),
- a(
- cls := "entity-name",
- href := entityUrl,
- entity.name
- )
- )
- }
-
- if (children.length > 0)
- li(cls := "mdl-list__item package", href := relativePath(pack), k) :: children
- else Nil
- }
- }
- )
-
- def companion(entity: Entity) = {
- val pack = entity.path.dropRight(1).mkString(".")
- (for {
- p <- packages.get(pack)
- child <- p.children.find(e => e.name == entity.name && e.path.last != entity.path.last)
- } yield child)
- }
-
- def companionAnchor = {
- companion(entity).map { c =>
- a(
- cls := "mdl-navigation__link",
- href := c.path.last + ".html",
- "Companion " + c.kind
- )
- }.getOrElse(span())
- }
-
- def searchView = div(
- cls := "search-container",
- div(
- cls := "mdl-textfield mdl-js-textfield mdl-textfield--floating-label",
- input(cls := "mdl-textfield__input", `type` := "text", id := "search"),
- label(cls := "mdl-textfield__label", `for` := "search", "Search")
- )
- )
}