diff options
author | Donna Malayeri <lindydonna@gmail.com> | 2011-04-08 14:26:22 +0000 |
---|---|---|
committer | Donna Malayeri <lindydonna@gmail.com> | 2011-04-08 14:26:22 +0000 |
commit | 8cd754f3589c0b0b19b3869dba5e2ddfc54579d7 (patch) | |
tree | 2bab15cba6b662f3dbf02c785fc8974dead33cc7 | |
parent | 4cf60d65bc8f71969d6012182738c6bb31a4c49b (diff) | |
download | scala-8cd754f3589c0b0b19b3869dba5e2ddfc54579d7.tar.gz scala-8cd754f3589c0b0b19b3869dba5e2ddfc54579d7.tar.bz2 scala-8cd754f3589c0b0b19b3869dba5e2ddfc54579d7.zip |
[scaladoc] Separate sections for "linear supert...
[scaladoc] Separate sections for "linear supertype" and "known
subclasses" using patch provided by Ruediger Keller. Closes #4456.
Closes #4304.
3 files changed, 46 insertions, 74 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 9277b17a56..f7d7b95844 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -375,9 +375,7 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { }</dd> } else NodeSeq.Empty - <xml:group> { - example ++ version ++ sinceVersion ++ seeAlso - } </xml:group> + example ++ version ++ sinceVersion ++ seeAlso case None => NodeSeq.Empty } @@ -390,39 +388,35 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { else <dl class="attributes block"> { attributesInfo }</dl> - val linearization = - mbr match { - case dtpl: DocTemplateEntity if isSelf && !isReduced && (dtpl.linearizationTemplates.nonEmpty || dtpl.subClasses.nonEmpty) => - val linearSupertypes: Seq[scala.xml.Node] = - if (dtpl.linearizationTemplates.isEmpty) NodeSeq.Empty - else { - <h1>Linear Supertypes</h1> - <p>{ typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) }</p> - } - - val knownSubclasses: Seq[scala.xml.Node] = - if (dtpl.subClasses.isEmpty) NodeSeq.Empty - else { - <h1>Known Subclasses</h1> - <p>{ templatesToHtml(dtpl.subClasses, xml.Text(", ")) }</p> - } - - <div id="superTypesDiv"> - <div class="attributes block"> - <span class="link showElement">Show linear super types and known subclasses</span> - <span class="link hideElement">Hide linear super types and known subclasses</span> - </div> - <div class="superTypes hiddenContent"> - <xml:group> { - linearSupertypes ++ knownSubclasses - } </xml:group> - </div> + val linearization = mbr match { + case dtpl: DocTemplateEntity if isSelf && !isReduced && dtpl.linearizationTemplates.nonEmpty => + <div class="toggleContainer"> + <div class="attributes block"> + <span class="link showElement">Linear Supertypes</span> + <span class="link hideElement">Linear Supertypes</span> </div> - case _ => NodeSeq.Empty - } + <div class="superTypes hiddenContent"> + <p>{ typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) }</p> + </div> + </div> + case _ => NodeSeq.Empty + } - NodeSeq.Empty ++ memberComment ++ paramComments ++ attributesBlock ++ linearization + val subclasses = mbr match { + case dtpl: DocTemplateEntity if isSelf && !isReduced && dtpl.subClasses.nonEmpty => + <div class="toggleContainer"> + <div class="attributes block"> + <span class="link showElement">Known Subclasses</span> + <span class="link hideElement">Known Subclasses</span> + </div> + <div class="subClasses hiddenContent"> + <p>{ templatesToHtml(dtpl.subClasses.sortBy(_.name), xml.Text(", ")) }</p> + </div> + </div> + case _ => NodeSeq.Empty + } + memberComment ++ paramComments ++ attributesBlock ++ linearization ++ subclasses } def kindToString(mbr: MemberEntity): String = { diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css index 038d835d43..192a56f9bb 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css @@ -122,9 +122,21 @@ div.superTypes > h1 { text-decoration: underline; cursor: pointer; color: #315479; - font-size: 11pt; } +.toggleContainer p { + margin-top: 5px; +} + +.toggleContainer .showElement { + padding-left: 15px; + background: url("arrow-right.png") no-repeat 0 5px transparent; +} + +.toggleContainer .hideElement { + padding-left: 15px; + background: url("arrow-down.png") no-repeat 0 5px transparent; +} .value #definition { background-color: #2C475C; /* blue */ diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js index 480425a305..14a5613015 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js @@ -101,63 +101,29 @@ $(document).ready(function(){ $(this.getTip()).html(this.getTrigger().attr("name")) } }); - var docAllSigs = $("#template .signature"); - // Is this used anywhere? - /* - function commentShowFct(signature){ - var fullComment = $("+ div.fullcomment", $(signature)); - var vis = $(":visible", fullComment); - if (vis.length > 0) { - fullComment.slideUp(100); - signature.addClass("closed"); - signature.removeClass("opened"); - } - else { - fullComment.slideDown(100); - signature.removeClass("closed"); - signature.addClass("opened"); - } - }; - var docShowSigs = docAllSigs.filter(function(){ - return $("+ div.fullcomment", $(this)).length > 0; - }); - docShowSigs.css("cursor", "pointer"); - docShowSigs.click(function(){ - commentShowFct($(this)); - }); - */ + /* Add toggle arrows */ + var docAllSigs = $("#template li").has(".fullcomment").find(".signature"); function commentToggleFct(signature){ var parent = signature.parent(); var shortComment = $(".shortcomment", parent); var fullComment = $(".fullcomment", parent); var vis = $(":visible", fullComment); + signature.toggleClass("closed").toggleClass("opened"); if (vis.length > 0) { shortComment.slideDown(100); fullComment.slideUp(100); - signature.addClass("closed"); - signature.removeClass("opened"); } else { shortComment.slideUp(100); fullComment.slideDown(100); - signature.removeClass("closed"); - signature.addClass("opened"); } }; - var docToggleSigs = docAllSigs.filter(function(){ - return $("+ .shortcomment", $(this)).length > 0; - }); - docToggleSigs.addClass("closed"); - docToggleSigs.click(function(){ - commentToggleFct($(this)); - }); - /* - $(".shortcomment").click(function(){ + docAllSigs.addClass("closed"); + docAllSigs.click(function() { commentToggleFct($(this)); }); - */ /* Linear super types and known subclasses */ function toggleShowContentFct(outerElement){ @@ -174,7 +140,7 @@ $(document).ready(function(){ $(".hideElement", outerElement).show(); } }; - $("#superTypesDiv").click(function() { + $(".toggleContainer").click(function() { toggleShowContentFct($(this)); }); }); |