summaryrefslogtreecommitdiff
path: root/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-03-06 07:39:19 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-03-09 11:59:07 -0800
commitc6ca941ccc017a8869f4def717cfeb640f965077 (patch)
treee21038cc55d3a4231544d148913504a754eafdf8 /src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala
parent9094822181c398b945b7f30ac1e2b05da9796f53 (diff)
downloadscala-c6ca941ccc017a8869f4def717cfeb640f965077.tar.gz
scala-c6ca941ccc017a8869f4def717cfeb640f965077.tar.bz2
scala-c6ca941ccc017a8869f4def717cfeb640f965077.zip
Moved scaladoc sources into separate directory.
This change is not externally visible. It moves the scaladoc sources into src/scaladoc and adds an ant target for building them. The compilation products are still packaged into scala-compiler.jar as before, but with a small change to build.xml a separate jar can be created instead.
Diffstat (limited to 'src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala133
1 files changed, 133 insertions, 0 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala
new file mode 100644
index 0000000000..c034647320
--- /dev/null
+++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala
@@ -0,0 +1,133 @@
+/* NSC -- new Scala compiler
+ * Copyright 2007-2013 LAMP/EPFL
+ * @author David Bernard, Manohar Jonnalagedda
+ */
+
+package scala.tools.nsc
+package doc
+package html
+package page
+
+import model._
+import scala.collection._
+import scala.xml._
+
+class Index(universe: doc.Universe, val index: doc.Index) extends HtmlPage {
+
+ def path = List("index.html")
+
+ def title = {
+ val s = universe.settings
+ ( if (!s.doctitle.isDefault) s.doctitle.value else "" ) +
+ ( if (!s.docversion.isDefault) (" " + s.docversion.value) else "" )
+ }
+
+ val headers =
+ <xml:group>
+ <link href={ relativeLinkTo{List("index.css", "lib")} } media="screen" type="text/css" rel="stylesheet"/>
+ <script type="text/javascript" src={ relativeLinkTo{List("jquery.js", "lib")} }></script>
+ <script type="text/javascript" src={ relativeLinkTo{List("jquery-ui.js", "lib")} }></script>
+ <script type="text/javascript" src={ relativeLinkTo{List("jquery.layout.js", "lib")} }></script>
+ <script type="text/javascript" src={ relativeLinkTo{List("index.js", "lib")} }></script>
+ <script type="text/javascript" src={ relativeLinkTo{List("scheduler.js", "lib")} }></script>
+ </xml:group>
+
+ val body =
+ <body>
+ <div id="library">
+ <img class='class icon' src={ relativeLinkTo{List("class.png", "lib")} }/>
+ <img class='trait icon' src={ relativeLinkTo{List("trait.png", "lib")} }/>
+ <img class='object icon' src={ relativeLinkTo{List("object.png", "lib")} }/>
+ <img class='package icon' src={ relativeLinkTo{List("package.png", "lib")} }/>
+ </div>
+ { browser }
+ <div id="content" class="ui-layout-center">
+ <iframe id="template" name="template" src={ relativeLinkTo{List("package.html")} }/>
+ </div>
+ </body>
+
+ def letters: NodeSeq =
+ '_' +: ('a' to 'z') map {
+ char => {
+ val label = if (char == '_') '#' else char.toUpper
+
+ index.firstLetterIndex.get(char) match {
+ case Some(_) =>
+ <a target="template" href={ "index/index-" + char + ".html" }>{
+ label
+ }</a>
+ case None => <span>{ label }</span>
+ }
+ }
+ }
+
+ def browser =
+ <div id="browser" class="ui-layout-west">
+ <div class="ui-west-center">
+ <div id="filter">
+ <div id="textfilter"></div>
+ <div id="letters">{ letters }</div>
+ </div>
+ <div class="pack" id="tpl">{
+ def packageElem(pack: model.Package): NodeSeq = {
+ <xml:group>
+ { if (!pack.isRootPackage)
+ <a class="tplshow" href={ relativeLinkTo(pack) } target="template">{ pack.qualifiedName }</a>
+ else NodeSeq.Empty
+ }
+ <ol class="templates">{
+ val tpls: Map[String, Seq[DocTemplateEntity]] =
+ (pack.templates collect {
+ case t: DocTemplateEntity if !t.isPackage && !universe.settings.hardcoded.isExcluded(t.qualifiedName) => t
+ }) groupBy (_.name)
+
+ val placeholderSeq: NodeSeq = <div class="placeholder"></div>
+
+ def createLink(entity: DocTemplateEntity, includePlaceholder: Boolean, includeText: Boolean) = {
+ val entityType = kindToString(entity)
+ val linkContent = (
+ { if (includePlaceholder) placeholderSeq else NodeSeq.Empty }
+ ++
+ { if (includeText) <span class="tplLink">{ Text(packageQualifiedName(entity)) }</span> else NodeSeq.Empty }
+ )
+ <a class="tplshow" href={ relativeLinkTo(entity) } target="template"><span class={ entityType }>({ Text(entityType) })</span>{ linkContent }</a>
+ }
+
+ for (tn <- tpls.keySet.toSeq sortBy (_.toLowerCase)) yield {
+ val entities = tpls(tn)
+ val row = (entities find (e => e.isPackage || e.isObject), entities find (e => e.isTrait || e.isClass))
+
+ val itemContents = row match {
+ case (Some(obj), None) => createLink(obj, includePlaceholder = true, includeText = true)
+
+ case (maybeObj, Some(template)) =>
+ val firstLink = maybeObj match {
+ case Some(obj) => createLink(obj, includePlaceholder = false, includeText = false)
+ case None => placeholderSeq
+ }
+
+ firstLink ++ createLink(template, includePlaceholder = false, includeText = true)
+
+ case _ => // FIXME: this default case should not be necessary. For some reason AnyRef is not a package, object, trait, or class
+ val entry = entities.head
+ placeholderSeq ++ createLink(entry, includePlaceholder = false, includeText = true)
+ }
+
+ <li title={ entities.head.qualifiedName }>{ itemContents }</li>
+ }
+ }</ol>
+ <ol class="packages"> {
+ for (sp <- pack.packages sortBy (_.name.toLowerCase)) yield
+ <li class="pack" title={ sp.qualifiedName }>{ packageElem(sp) }</li>
+ }</ol>
+ </xml:group>
+ }
+ packageElem(universe.rootPackage)
+ }</div></div><script src="index.js"></script>
+ </div>
+
+ def packageQualifiedName(ety: DocTemplateEntity): String =
+ if (ety.inTemplate.isPackage) ety.name
+ else (packageQualifiedName(ety.inTemplate) + "." + ety.name)
+
+}