diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-06-15 16:09:36 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-06-15 16:09:36 +0000 |
commit | bf1b8d136d862e5e4d5a6bba3c05254327542281 (patch) | |
tree | 3c2e4dbe16161f093edf7832af76dcbf1268302d | |
parent | 1e0846707622d0301b821cec67d3d0aac6361273 (diff) | |
download | scala-bf1b8d136d862e5e4d5a6bba3c05254327542281.tar.gz scala-bf1b8d136d862e5e4d5a6bba3c05254327542281.tar.bz2 scala-bf1b8d136d862e5e4d5a6bba3c05254327542281.zip |
[scaladoc] New display mode for members: ordere...
[scaladoc] New display mode for members: ordered by inheritance class.
Review by malayeri.
5 files changed, 143 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala index 66e2ba2260..1efb56d716 100644 --- a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala @@ -47,7 +47,6 @@ abstract class HtmlPage { thisPage => <head> <title>{ title }</title> <meta http-equiv="content-type" content={ "text/html; charset=" + site.encoding }/> - <script type="text/javascript" src={ relativeLinkTo{List("jquery.js", "lib")} }></script> { headers } </head> { body } diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Index.scala b/src/compiler/scala/tools/nsc/doc/html/page/Index.scala index 784a92f1ff..8675058c24 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Index.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Index.scala @@ -26,17 +26,18 @@ class Index(universe: Universe) extends HtmlPage { def headers = <xml:group> <link href={ relativeLinkTo(List("index.css", "lib")) } media="screen" type="text/css" rel="stylesheet"/> - <script type="text/javascript" src={ relativeLinkTo{List("index.js", "lib")} }></script> + <script type="text/javascript" src={ relativeLinkTo{List("jquery.js", "lib")} }></script> <script type="text/javascript" src={ relativeLinkTo{List("scheduler.js", "lib")} }></script> + <script type="text/javascript" src={ relativeLinkTo{List("index.js", "lib")} }></script> </xml:group> def body = <body> <div id="library"> - <img class='class icon' src='lib/class.png'/> - <img class='trait icon' src='lib/trait.png'/> - <img class='object icon' src='lib/object.png'/> - <img class='package icon' src='lib/package.png'/> + <img class='class icon' width="13" height="13" src='lib/class.png'/> + <img class='trait icon' width="13" height="13" src='lib/trait.png'/> + <img class='object icon' width="13" height="13" src='lib/object.png'/> + <img class='package icon' width="13" height="13" src='lib/package.png'/> </div> <div id="browser"> <div id="filter"></div> 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 72cfd9c662..311bac0f86 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -23,8 +23,9 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { val headers = <xml:group> <link href={ relativeLinkTo(List("template.css", "lib")) } media="screen" type="text/css" rel="stylesheet"/> - <script type="text/javascript" src={ relativeLinkTo{List("template.js", "lib")} }></script> + <script type="text/javascript" src={ relativeLinkTo{List("jquery.js", "lib")} }></script> <script type="text/javascript" src={ relativeLinkTo{List("tools.tooltip.js", "lib")} }></script> + <script type="text/javascript" src={ relativeLinkTo{List("template.js", "lib")} }></script> </xml:group> val valueMembers = @@ -59,16 +60,24 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { <div id="mbrsel"> { if (tpl.linearization.isEmpty) NodeSeq.Empty else + <div id="order"> + <span class="filtertype">Ordering</span> + <ol><li class="alpha in">Alphabetic</li><li class="inherit out">By inheritance</li></ol> + </div> + } + { if (tpl.linearization.isEmpty) NodeSeq.Empty else <div id="ancestors"> <span class="filtertype">Inherited</span> <ol><li class="hideall">Hide All</li><li class="showall">Show all</li></ol> - <ol id="linearization">{ tpl.linearization map { wte => <li class="in" name={ wte.qualifiedName }>{ wte.name }</li> } }</ol> + <ol id="linearization">{ (tpl :: tpl.linearization) map { wte => <li class="in" name={ wte.qualifiedName }>{ wte.name }</li> } }</ol> </div> } - <div id="visbl"> - <span class="filtertype">Visibility</span> - <ol><li class="public in">Public</li><li class="all out">All</li></ol> - </div> + { + <div id="visbl"> + <span class="filtertype">Visibility</span> + <ol><li class="public in">Public</li><li class="all out">All</li></ol> + </div> + } </div> { if (constructors.isEmpty) NodeSeq.Empty else @@ -79,25 +88,34 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { } { if (typeMembers.isEmpty) NodeSeq.Empty else - <div id="types" class="members"> + <div id="types" class="types members"> <h3>Type Members</h3> <ol>{ typeMembers map (memberToHtml(_)) }</ol> </div> } { if (valueMembers.isEmpty) NodeSeq.Empty else - <div id="values" class="members"> + <div id="values" class="values members"> <h3>Value Members</h3> <ol>{ valueMembers map (memberToHtml(_)) }</ol> </div> } + { + NodeSeq fromSeq (for (parent <- tpl.linearization) yield + <div class="parent" name={ parent.qualifiedName }> + <h3>Inherited from { templateToHtml(parent) }</h3> + </div> + ) + } + </div> <div id="tooltip" ></div> </body> + def memberToHtml(mbr: MemberEntity): NodeSeq = { val attributes: List[comment.Body] = Nil <li name={ mbr.definitionName } visbl={ if (mbr.visibility.isProtected) "prt" else "pub" }> 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 0c17d9fa2a..ccbb14ba8f 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 @@ -85,7 +85,7 @@ a:hover { padding-left: 8px; } -#values > h3 { +#template .values > h3 { color: white; padding: 4px; background-color: #7996AC; @@ -93,7 +93,7 @@ a:hover { font-weight: bold; } -#types > h3 { +#template .types > h3 { padding: 4px; color: white; font-weight: bold; @@ -109,6 +109,18 @@ a:hover { background-color: #333; } +#template > div.parent > h3 { + color: white; + padding: 4px; + background-color: #385E1A; + font-size: 12pt; + font-weight: bold; +} + +#template > div.parent > h3 > a { + color: white; +} + /* Member cells */ div.members > ol { @@ -181,11 +193,11 @@ div.members > ol > li { font-style: italic; } -#values .signature .name { +#template .values .signature .name { color: blue; } -#types .signature .name { +#template .types .signature .name { color: green; } 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 a13c502ba5..5e24f3f5a8 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 @@ -47,6 +47,20 @@ $(document).ready(function(){ filter(); }; }); + $("#order > ol > li.alpha").click(function() { + if ($(this).hasClass("out")) { + $(this).removeClass("out").addClass("in"); + $("#order > ol > li.inherit").removeClass("in").addClass("out"); + orderAlpha(); + }; + }) + $("#order > ol > li.inherit").click(function() { + if ($(this).hasClass("out")) { + $(this).removeClass("out").addClass("in"); + $("#order > ol > li.alpha").removeClass("in").addClass("out"); + orderInherit(); + }; + }); //http://flowplayer.org/tools/tooltip.html $(".extype").tooltip({ tip: "#tooltip", @@ -95,11 +109,80 @@ $(document).ready(function(){ $("p.shortcomment").click(function(){ commentToggleFct($(this)); }); + initInherit(); }); +function orderAlpha() { + $("#template > div.parent").hide(); + $("#ancestors").show(); + filter(); +}; + +function orderInherit() { + $("#template > div.parent").show(); + $("#ancestors").hide(); + filter(); +}; + +/** Prepares the DOM for inheritance-based display. To do so it will: + * - hide all statically-generated parents headings; + * - copy all members from the value and type members lists (flat members) to corresponding lists nested below the + * parent headings (inheritance-grouped members); + * - initialises a control variable used by the filter method to control whether filtering happens on flat members + * or on inheritance-grouped members. */ +function initInherit() { + // parents is a map from fully-qualified names to the DOM node of parent headings. + var parents = new Object(); + $("#template > div.parent").each(function(){ + parents[$(this).attr("name")] = $(this); + }); + // + $("#types > ol > li").each(function(){ + var qualName = $(this).attr("name"); + var owner = qualName.slice(0, qualName.indexOf("#")); + var name = qualName.slice(qualName.indexOf("#") + 1); + var parent = parents[owner]; + if (parent != undefined) { + var types = $("> .types > ol", parent); + if (types.length == 0) { + parent.append("<div class='types members'><h3>Type Members</h3><ol></ol></div>"); + types = $("> .types > ol", parent); + } + types.append($(this).clone()); + } + }); + $("#values > ol > li").each(function(){ + var qualName = $(this).attr("name"); + var owner = qualName.slice(0, qualName.indexOf("#")); + var name = qualName.slice(qualName.indexOf("#") + 1); + var parent = parents[owner]; + if (parent != undefined) { + var values = $("> .values > ol", parent); + if (values.length == 0) { + parent.append("<div class='values members'><h3>Value Members</h3><ol></ol></div>"); + values = $("> .values > ol", parent); + } + values.append($(this).clone()); + } + }); + $("#template > div.parent").each(function(){ + if ($("> div.members", this).length == 0) { $(this).remove(); }; + }); + $("#template > div.parent").each(function(){ + $(this).hide(); + }); +}; + function filter() { + var inheritHides = null + if ($("#order > ol > li.inherit").hasClass("in")) { + inheritHides = $("#linearization > li:gt(0)"); + } + else { + inheritHides = $("#linearization > li.out"); + } var outOwners = - $("#mbrsel ol#linearization > li.out").map(function(){ + inheritHides.map(function(){ var r = $(this).attr("name"); return r }).get(); @@ -107,12 +190,15 @@ function filter() { $(".members > ol > li").each(function(){ var vis1 = $(this).attr("visbl"); var qualName1 = $(this).attr("name"); - var owner1 = qualName1.slice(0, qualName1.indexOf("#")); //var name1 = qualName1.slice(qualName1.indexOf("#") + 1); var showByOwned = true; - for (out in outOwners) { - if (outOwners[out] == owner1) { - showByOwned = false; + if ($(this).parents(".parent").length == 0) { + // owner filtering must not happen in "inherited from" member lists + var owner1 = qualName1.slice(0, qualName1.indexOf("#")); + for (out in outOwners) { + if (outOwners[out] == owner1) { + showByOwned = false; + }; }; }; var showByVis = true @@ -126,5 +212,9 @@ function filter() { $(this).hide(); }; }); + $(".members").each(function(){ + $(this).show(); + if ($(" > ol > li:visible", this).length == 0) { $(this).hide(); } + }); return false }; |