diff options
author | michelou <michelou@epfl.ch> | 2006-12-02 23:58:50 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-12-02 23:58:50 +0000 |
commit | 6cffd12cb90c8353ccd8581a712bffb52a7b4c59 (patch) | |
tree | c76124f7c484b87bda8397364c680381cbe7283f /src | |
parent | a3ffb394a417e6e85743058db6074f7fb913e436 (diff) | |
download | scala-6cffd12cb90c8353ccd8581a712bffb52a7b4c59.tar.gz scala-6cffd12cb90c8353ccd8581a712bffb52a7b4c59.tar.bz2 scala-6cffd12cb90c8353ccd8581a712bffb52a7b4c59.zip |
added alphabetic ordered links in navigation frame
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/DocGenerator.scala | 40 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/DocUtil.scala | 10 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/script.js | 23 |
3 files changed, 54 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index d4351839f4..b591b499bb 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -13,7 +13,7 @@ import java.util.regex.Pattern import compat.Platform.{EOL => LINE_SEPARATOR} import scala.collection.immutable.{ListMap, TreeMap, TreeSet} -import scala.collection.mutable.{HashMap, ListBuffer, Map} +import scala.collection.mutable.{HashMap, HashSet, ListBuffer, Map} import scala.tools.nsc.models.Models import scala.tools.nsc.symtab.Flags import scala.xml._ @@ -204,7 +204,7 @@ abstract class DocGenerator extends Models { def body: NodeSeq = <div> {doctitle} - <a href="all-classes.html" target={classesFrame} onclick="resetKinds();">{"All objects and classes"}</a> + <a href="all-classes.html" target={classesFrame} onclick="resetKind();">{"All objects and classes"}</a> </div> <div class="kinds"> Packages @@ -212,7 +212,7 @@ abstract class DocGenerator extends Models { <ul class="list"> { { for (val top <- modules.elements.toList) yield - <li><a href={urlFor(top._2)} target={classesFrame} onclick="resetKinds();">{top._2.fullNameString('.')}</a></li> + <li><a href={urlFor(top._2)} target={classesFrame} onclick="resetKind();">{top._2.fullNameString('.')}</a></li> } } </ul>; } @@ -255,7 +255,7 @@ abstract class DocGenerator extends Models { else p } - def body: NodeSeq = { + def body: NodeSeq = { val nav = <table class="navigation" summary=""> <tr><td valign="top" class="navigation-links"> @@ -263,6 +263,13 @@ abstract class DocGenerator extends Models { </td></tr> </table>; + val ids = new HashSet[String] + def idFor(kind: Kind, t: Tree): String = { + val ch = t.symbol.nameString.charAt(0) + val id = pluralFor(kind) + "_" + ch + if (ids contains id) null + else { ids += id; id } + } val body = <div>{ { for (val kind <- KINDS; classes contains kind) yield { <div id={pluralFor(kind)} class="kinds"> {Text(pluralFor(kind))} @@ -270,7 +277,7 @@ abstract class DocGenerator extends Models { <ul class="list"> { { for (val mmbr <- classes(kind).toList) yield - <li>{urlFor(mmbr.tree, contentFrame)}</li> + <li id={idFor(kind, mmbr.tree)}>{urlFor(mmbr.tree, contentFrame)}</li> } } </ul> } } }</div>; @@ -827,14 +834,31 @@ abstract class DocGenerator extends Models { def title="navigation" def path="nav-classes" override def body0(hasBody: Boolean, nodes: NodeSeq): NodeSeq = - if (!hasBody) nodes else <body onload="init()" style="margin:1px;">{nodes}</body>; + if (!hasBody) nodes + else <body onload="init()" style="margin:1px 0 0 1px; padding:1px 0 0 1px;">{nodes}</body>; def body = <form> - <select id="kinds" onchange="goto()"> + <select id="kinds" onchange="gotoKind()"> <option value="#Classes" selected="selected">Classes</option> <option value="#Objects">Objects</option> <option value="#Traits">Traits</option> </select> + <span style="word-spacing:-3px;"> + <a href={Unparsed("javascript:gotoName('A')")}>A</a> + <a href={Unparsed("javascript:gotoName('B')")}>B</a> + <a href={Unparsed("javascript:gotoName('C')")}>C</a> + <a href={Unparsed("javascript:gotoName('D')")}>D</a> + <a href={Unparsed("javascript:gotoName('E')")}>E</a> + <a href={Unparsed("javascript:gotoName('G')")}>G</a> + <a href={Unparsed("javascript:gotoName('I')")}>I</a> + <a href={Unparsed("javascript:gotoName('K')")}>K</a> + <a href={Unparsed("javascript:gotoName('M')")}>M</a> + <a href={Unparsed("javascript:gotoName('P')")}>P</a> + <a href={Unparsed("javascript:gotoName('R')")}>R</a> + <a href={Unparsed("javascript:gotoName('T')")}>T</a> + <a href={Unparsed("javascript:gotoName('V')")}>V</a> + <a href={Unparsed("javascript:gotoName('X')")}>X</a> + </span> </form> } @@ -1236,7 +1260,7 @@ abstract class DocGenerator extends Models { val index = <frameset cols="25%, 75%"> - <frameset rows="50%, 26, 50%"> + <frameset rows="50%, 28, 50%"> <frame src="modules.html" name={modulesFrame}></frame> <frame src="nav-classes.html" name="navigationFrame"></frame> <frame src="all-classes.html" name={classesFrame}></frame> diff --git a/src/compiler/scala/tools/nsc/doc/DocUtil.scala b/src/compiler/scala/tools/nsc/doc/DocUtil.scala index 406ea66777..745661ffc7 100644 --- a/src/compiler/scala/tools/nsc/doc/DocUtil.scala +++ b/src/compiler/scala/tools/nsc/doc/DocUtil.scala @@ -7,6 +7,7 @@ package scala.tools.nsc.doc import java.io.StringReader +import java.net.URLEncoder import org.xml.sax.InputSource import scala.collection.immutable._ @@ -38,14 +39,15 @@ object DocUtil { def relative: String def aref(href0: String, target: String, text: String): NodeSeq = { - val href = Utility.escape(href0) + //val href = Utility.escape(href0) + val href = relative + URLEncoder.encode(href0, encoding) if ((target ne null) && target.indexOf('<') != -1) throw new Error(target) val t0 = Text(text) - if ((target ne null)) - <a href={(relative + href)} target={(target)}>{t0}</a>; + if (target ne null) + <a href={href} target={target}>{t0}</a>; else - <a href={(relative + href)}>{t0}</a>; + <a href={href}>{t0}</a>; } val encoding = "iso-8859-1" diff --git a/src/compiler/scala/tools/nsc/doc/script.js b/src/compiler/scala/tools/nsc/doc/script.js index 524ea6834d..b62b36019b 100644 --- a/src/compiler/scala/tools/nsc/doc/script.js +++ b/src/compiler/scala/tools/nsc/doc/script.js @@ -270,19 +270,28 @@ function init() { } } -function goto() { - kinds = parent.navigationFrame.document.getElementById("kinds") - oldLocation = parent.classesFrame.window.location.href +function getLocation() { + kinds = parent.navigationFrame.document.getElementById("kinds"); + oldLocation = parent.classesFrame.window.location.href; //alert("oldLocation="+oldLocation); - pos = oldLocation.lastIndexOf("#") + pos = oldLocation.lastIndexOf("#"); classesURL = (pos > 0) ? oldLocation.substring(0, pos) : oldLocation; newLocation = classesURL + kinds.options[kinds.selectedIndex].value; //alert("newLocation="+newLocation); - parent.classesFrame.window.location = newLocation; + return newLocation; } -function resetKinds() { - kinds = parent.navigationFrame.document.getElementById("kinds") +function gotoKind() { + parent.classesFrame.window.location = getLocation(); +} + +function resetKind() { + kinds = parent.navigationFrame.document.getElementById("kinds"); kinds.selectedIndex = 0; } + +function gotoName(letter) { + parent.classesFrame.window.location = getLocation() + "_" + letter; +} --> + |