diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-07-18 15:59:14 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-07-18 15:59:14 +0000 |
commit | 289e6a43d40b5b47ecd4ae55b59389ad27e5508a (patch) | |
tree | 0706b98b1d9bed213711876808e15d3bd7e7b744 | |
parent | bdbaba4cf02f53492fef9c8e8c72b85ba18d323b (diff) | |
download | scala-289e6a43d40b5b47ecd4ae55b59389ad27e5508a.tar.gz scala-289e6a43d40b5b47ecd4ae55b59389ad27e5508a.tar.bz2 scala-289e6a43d40b5b47ecd4ae55b59389ad27e5508a.zip |
[scaladoc] Print "Inherited from" headings usin...
[scaladoc] Print "Inherited from" headings using type instances
("SeqLike[A, List[A]]") instead of template names ("SeqLike"). Review by
malayeri.
3 files changed, 19 insertions, 16 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 06a2aaee6b..2a11905d7f 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -70,7 +70,7 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { <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 :: tpl.linearization) map { wte => <li class="in" name={ wte.qualifiedName }>{ wte.name }</li> } }</ol> + <ol id="linearization">{ (tpl :: tpl.linearizationTemplates) map { wte => <li class="in" name={ wte.qualifiedName }>{ wte.name }</li> } }</ol> </div> } { @@ -109,9 +109,9 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { } { - NodeSeq fromSeq (for (parent <- tpl.linearization) yield - <div class="parent" name={ parent.qualifiedName }> - <h3>Inherited from { templateToHtml(parent) }</h3> + NodeSeq fromSeq (for ((superTpl, superType) <- tpl.linearization) yield + <div class="parent" name={ superTpl.qualifiedName }> + <h3>Inherited from { typeToHtml(superType, true) }</h3> </div> ) } @@ -259,7 +259,7 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { } } ++ { mbr match { - case dtpl: DocTemplateEntity if (isSelf && !dtpl.linearizationTypes.isEmpty) => + case dtpl: DocTemplateEntity if (isSelf && !dtpl.linearization.isEmpty) => <div class="block"> linear super types: { typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) } </div> diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala index 8c47fd7fbb..7d4fbbfbfb 100644 --- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala +++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala @@ -71,8 +71,8 @@ trait DocTemplateEntity extends TemplateEntity with MemberEntity { def inSource: Option[(io.AbstractFile, Int)] def sourceUrl: Option[java.net.URL] def parentType: Option[TypeEntity] - def parentTemplates: List[TemplateEntity] - def linearization: List[TemplateEntity] + def linearization: List[(TemplateEntity, TypeEntity)] + def linearizationTemplates: List[TemplateEntity] def linearizationTypes: List[TypeEntity] def subClasses: List[DocTemplateEntity] def members: List[MemberEntity] diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index 218d3158f9..a45a227142 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -160,22 +160,25 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory } else None } - def parentTemplates = sym.info.parents map { x: Type => makeTemplate(x.typeSymbol) } def parentType = { - if (sym.isPackage) None else - Some(makeType(RefinedType((sym.tpe.parents filter (_ != ScalaObjectClass.tpe)) map { _.asSeenFrom(sym.thisType, sym) }, EmptyScope), inTpl)) + if (sym.isPackage) None else { + val tps = + (sym.tpe.parents filter (_ != ScalaObjectClass.tpe)) map { _.asSeenFrom(sym.thisType, sym) } + Some(makeType(RefinedType(tps, EmptyScope), inTpl)) + } } - val linearization = { - val tpls = sym.ancestors filter { _ != ScalaObjectClass } map { makeTemplate(_) } + val linearization: List[(TemplateEntity, TypeEntity)] = { + val acs = sym.ancestors filter { _ != ScalaObjectClass } + val tps = acs map { cls => makeType(sym.info.baseType(cls), this) } + val tpls = acs map { makeTemplate(_) } tpls map { case dtpl: DocTemplateImpl => dtpl.registerSubClass(this) case _ => } - tpls - } - def linearizationTypes = { - ((sym.info.baseClasses filter (_ != ScalaObjectClass)) map { cls => makeType(sym.info.baseType(cls), this) }).tail + tpls zip tps } + def linearizationTemplates = linearization map { _._1 } + def linearizationTypes = linearization map { _._2 } private lazy val subClassesCache = mutable.Buffer.empty[DocTemplateEntity] def registerSubClass(sc: DocTemplateEntity): Unit = { assert(subClassesCache != null) |