From 15a20c680cd904ca29e35ef7379055afbd815ef8 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 14 Nov 2006 13:20:28 +0000 Subject: improved generation of inherited members in Doc... improved generation of inherited members in DocGenerator --- src/actors/scala/actors/ActorProxy.scala | 38 ++++--- .../scala/tools/nsc/doc/DocGenerator.scala | 109 +++++++++++---------- src/compiler/scala/tools/nsc/doc/style.css | 2 + src/compiler/scala/tools/nsc/models/Models.scala | 42 ++++---- 4 files changed, 103 insertions(+), 88 deletions(-) diff --git a/src/actors/scala/actors/ActorProxy.scala b/src/actors/scala/actors/ActorProxy.scala index 8609ceab85..2cfd12cb0a 100644 --- a/src/actors/scala/actors/ActorProxy.scala +++ b/src/actors/scala/actors/ActorProxy.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -15,26 +15,36 @@ package scala.actors import java.lang.Thread /** - * This class provides a dynamic actor proxy for normal Java - * threads. + * The class ActorProxyprovides a dynamic actor proxy for normal + * Java threads. * * @version 0.9.0 * @author Philipp Haller */ private[actors] class ActorProxy(t: Thread) extends Actor { - def act(): Unit = {} - /** - Terminates execution of self with the following - effect on linked actors: - For each linked actor a with - trapExit set to true, send message - Exit(self, reason) to a. + /** + */ + def act(): Unit = {} - For each linked actor a with - trapExit set to false (default), - call a.exit(reason) if - !reason.equals("normal"). + /** + *

+ * Terminates execution of self with the following + * effect on linked actors: + *

+ *

+ * For each linked actor a with + * trapExit set to true, send message + * Exit(self, reason) to a. + *

+ *

+ * For each linked actor a with + * trapExit set to false (default), + * call a.exit(reason) if + * !reason.equals("normal"). + *

+ * + * @param reason the exit reason of the interrupted thread. */ override def exit(reason: String): Unit = { exitReason = reason diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index c4b6cedc22..b3238cd619 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -24,6 +24,7 @@ import scala.xml._ abstract class DocGenerator extends Models { import global._ import DocUtil._ + import Kinds._ import compat.StringBuilder @@ -384,7 +385,7 @@ abstract class DocGenerator extends Models { case cmod: ImplMod => { listMembersShort(mmbr) } - { listInheritedMembers(mmbr) } + { listMembersFull(mmbr) } case _ => @@ -398,63 +399,71 @@ abstract class DocGenerator extends Models { def listMembersShort(mmbr: HasTree): NodeSeq = if (mmbr.isInstanceOf[Composite]) { val map = organize(mmbr.asInstanceOf[Composite], emptyMap) - for (val kind <- KINDS; map contains kind) yield Group(br( - - - - - { { - for (val mmbr <- map(kind).toList) yield - shortHeader(mmbr) - } } -
{Text(labelFor(kind))} Summary
)) + for (val kind <- KINDS) yield Group( + (if (map contains kind) + + + + + { { + for (val mmbr <- map(kind).toList) yield + shortHeader(mmbr) + } } +
{Text(labelFor(kind))} Summary
+ else + NodeSeq.Empty + ).concat( + listInheritedMembers(mmbr.tree.symbol, kind))) } else NodeSeq.Empty /** - * @param mmbr ... + * @param sym the symbol + * @param kind the selected kind of members * @return a sequence of HTML tables containing inherited members */ - def listInheritedMembers(mmbr: HasTree): NodeSeq = - if (mmbr.isInstanceOf[Composite]) { - val sym = mmbr.tree.symbol - val ignored = List(definitions.ObjectClass, definitions.ScalaObjectClass) - val parents = sym.info.parents - for (val p <- parents; !ignored.contains(p.symbol)) yield Group(br( - - - - - - { { - val decls = p.decls.toList filter(d => - d.isMethod && !d.isConstructor) - if (decls.isEmpty) NodeSeq.Empty // scope empty - else { - def aref1(sym: Symbol): NodeSeq = { - val isJava = sym hasFlag Flags.JAVA - if (isJava || (sym.sourceFile eq null)) { - {sym.nameString} - } - else - aref(urlFor(sym), contentFrame, sym.nameString) + def listInheritedMembers(sym: Symbol, kind: Kind): NodeSeq = { + val ignored = List(definitions.ObjectClass, definitions.ScalaObjectClass) + def hasKind(sym: Symbol) = + (kind == DEF && sym.isMethod && !sym.isConstructor) + (kind == VAR && sym.isVariable) + (kind == VAL && sym.isValue && !sym.isVariable) + val parents = sym.info.parents + for (val p <- parents; !ignored.contains(p.symbol); + val decls = p.decls.toList filter(member => hasKind(member)); + !decls.isEmpty) yield Group( +
- {Text("Methods inherited from ").concat(urlFor(p, contentFrame))} -
+ + + + + { { + //val decls = p.decls.toList filter(member => hasKind(member)) + //if (decls.isEmpty) NodeSeq.Empty // scope empty + /*else*/ { + def aref1(sym: Symbol): NodeSeq = { + val isJava = sym hasFlag Flags.JAVA + if (isJava || (sym.sourceFile eq null)) { + {sym.nameString} } - val members = decls.sort( - (x, y) => (x.nameString compareTo y.nameString) < 0) - + else + aref(urlFor(sym), contentFrame, sym.nameString) } - } } - -
+ {Text(kind.toString + " inherited from ").concat(urlFor(p, contentFrame))} +
- {aref1(members.head)} - {for (val m <- members.tail) yield Text(", ").concat(aref1(m))} -
)) - } else - NodeSeq.Empty + val members = decls.sort( + (x, y) => (x.nameString compareTo y.nameString) < 0) + + {aref1(members.head)} + {for (val m <- members.tail) yield Text(", ").concat(aref1(m))} + + } + } } + + ) + } /** * @param mmbr ... diff --git a/src/compiler/scala/tools/nsc/doc/style.css b/src/compiler/scala/tools/nsc/doc/style.css index 890a4369ea..92c94ffedb 100644 --- a/src/compiler/scala/tools/nsc/doc/style.css +++ b/src/compiler/scala/tools/nsc/doc/style.css @@ -45,6 +45,7 @@ span.entity { } table.member { + margin: 0 0 1.2em 0; /* top rigth bottom left */ border-collapse: collapse; border: 2px inset #888888; width: 100%; @@ -58,6 +59,7 @@ table.member td.title { } table.inherited { + margin: 0 0 1.2em 0; /* top rigth bottom left */ border-collapse: collapse; border: 2px inset #888888; width: 100%; diff --git a/src/compiler/scala/tools/nsc/models/Models.scala b/src/compiler/scala/tools/nsc/models/Models.scala index db000efd1e..9a9284d321 100644 --- a/src/compiler/scala/tools/nsc/models/Models.scala +++ b/src/compiler/scala/tools/nsc/models/Models.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -20,30 +20,24 @@ abstract class Models { def acceptPrivate = true - abstract class Kind {} - object CONSTRUCTOR extends Kind - object OBJECT extends Kind - object CLASS extends Kind - object TRAIT extends Kind - object DEF extends Kind - object VAL extends Kind - object VAR extends Kind - object ARG extends Kind - object TPARAM extends Kind - - def KINDS = CLASS :: TRAIT :: OBJECT :: CONSTRUCTOR :: TPARAM :: VAL :: VAR :: DEF :: Nil - - def labelFor(kind: Kind): String = kind match { - case OBJECT => "Object" - case CLASS => "Class" - case TRAIT => "Trait" - case DEF => "Def" - case VAL => "Val" - case VAR => "Var" - case ARG => "Arg" - case TPARAM => "Type" - case CONSTRUCTOR => "Constructor" + object Kinds extends Enumeration { + type Kind = Value + val CONSTRUCTOR = Value("Constructor") + val OBJECT = Value("Object") + val CLASS = Value("Class") + val TRAIT = Value("Trait") + val DEF = Value("Def") + val VAL = Value("Val") + val VAR = Value("Var") + val ARG = Value("Arg") + val TPARAM = Value("Type") } + import Kinds._ + + def KINDS = List(CLASS, TRAIT, OBJECT, CONSTRUCTOR, TPARAM, VAL, VAR, DEF) + + def labelFor(kind: Kind): String = kind.toString + def stringsFor(mods: Modifiers) = { var modString: List[String] = Nil if (mods.isPrivate ) modString = "private" :: modString -- cgit v1.2.3