summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocGenerator.scala90
-rw-r--r--src/library/scala/All$.scala4
-rw-r--r--src/library/scala/AllRef$.scala4
-rw-r--r--src/library/scala/Application.scala6
-rw-r--r--src/library/scala/CaseClass.scala5
-rw-r--r--src/library/scala/Enumeration.scala6
-rw-r--r--src/library/scala/SerialVersionUID.scala4
-rw-r--r--src/library/scala/volatile.scala4
-rw-r--r--src/library/scala/xml/Group.scala38
9 files changed, 102 insertions, 59 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
index c81de38f62..17d1632392 100644
--- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
@@ -15,6 +15,10 @@ import scala.tools.nsc.models._
import scala.tools.nsc.symtab.Flags
import scala.xml._
+/**
+ * @author Sean McDirmid, Stephane Micheloud
+ * @version 1.0
+ */
abstract class DocGenerator extends Models {
import global._
import DocUtil._
@@ -33,27 +37,27 @@ abstract class DocGenerator extends Models {
def relative: String = {
assert(path != null)
var idx = 0
- var ct = ""
+ var ct = new StringBuffer
while (idx != -1) {
idx = path.indexOf('/', idx)
- //System.err.println(path + " idx=" + idx);
- ct = ct + (if (idx != -1) "../" else "")
+ //System.err.println(path + " idx=" + idx)
+ ct.append(if (idx != -1) "../" else "")
idx = idx + (if (idx == -1) 0 else 1)
}
- ct
+ ct.toString
}
def body: NodeSeq
def title: String
def save(nodes: NodeSeq) = {
- val path0 = outdir + "/" + path + FILE_EXTENSION_HTML
- //System.err.println("Writing to " + path0)
+ val path0 = outdir + File.separator + path + FILE_EXTENSION_HTML
+ if (settings.debug.value) inform("Writing XML nodes to " + path0)
val file = new File(path0)
val parent = file.getParentFile()
if (!parent.exists()) parent.mkdirs()
val writer = new FileWriter(file)
- val str = dtype + "\n" + nodes.toString()
+ val str = dtype + LINE_SEPARATOR + nodes.toString()
writer.write(str, 0, str.length())
writer.close()
}
@@ -64,7 +68,7 @@ abstract class DocGenerator extends Models {
* @return ...
*/
def urlFor(tree: Tree, target: String): NodeSeq = try {
- val sym = tree.symbol;
+ val sym = tree.symbol
if (sym == NoSymbol)
Text(tree.asInstanceOf[ValOrDefDef].name.toString());
else if (sym.sourceFile == null) Text(sym.fullNameString('.'))
@@ -224,18 +228,47 @@ abstract class DocGenerator extends Models {
NodeSeq.Empty
}
- private def nameFor(tree : Tree) = {
- if (tree.symbol == NoSymbol) tree.asInstanceOf[ValOrDefDef].name.toString();
- else tree.symbol.nameString;
- }
+ private def nameFor(tree: Tree) =
+ if (tree.symbol == NoSymbol) tree.asInstanceOf[ValOrDefDef].name.toString()
+ else tree.symbol.nameString
+
+ private def attrsFor(tree: Tree): NodeSeq =
+ if (tree.symbol.attributes.isEmpty || tree.symbol.hasFlag(Flags.CASE))
+ NodeSeq.Empty
+ else {
+ def attrFor(attr: AttrInfo): Node = {
+ val buf = new StringBuffer
+ val Triple(tpe, args, nvPairs) = attr
+ val name = aref(urlFor(tpe.symbol), contentFrame, tpe.toString)
+ if (!args.isEmpty)
+ buf.append(args.mkString("(", ",", ")"))
+ if (!nvPairs.isEmpty)
+ for (val Pair(Pair(name, value), index) <- nvPairs.zipWithIndex) {
+ if (index > 0)
+ buf.append(", ")
+ buf.append(name).append(" = ").append(value)
+ }
+ Group(name concat Text(buf.toString))
+ }
+ var res: NodeSeq = Text("[")
+ val attrs = tree.symbol.attributes
+ for (val i <- attrs.indices) {
+ if (i > 0) res = res.concat(Text(","))
+ res = res.concat(attrFor(attrs(i)))
+ }
+ br(res.concat(Text("]")))
+ }
def fullHeader(mmbr: HasTree): NodeSeq = <span>{ {
if (!mmbr.isInstanceOf[ImplMod]) {
<a name = {Utility.escape(mmbr.tree.symbol.nameString)}></a>;
} else NodeSeq.Empty;
} }<dl><dt>
- { { for (val str <- stringsFor(mmbr.mods)) yield (Text(str + " ")) } }
- <code>{ Text(codeFor(mmbr.kind)) }</code>
+ { attrsFor(mmbr.tree) }
+ <code>
+ { { for (val str <- stringsFor(mmbr.mods)) yield Text(str + " ") } }
+ { Text(codeFor(mmbr.kind)) }
+ </code>
<em>{ Text(nameFor(mmbr.tree)) }</em>
{ typesFor(mmbr) }{ argsFor(mmbr)}{resultFor(mmbr) }
</dt> { extendsFor(mmbr) }
@@ -316,13 +349,13 @@ abstract class DocGenerator extends Models {
}
def fullComment(mmbr: HasTree): NodeSeq =
- if (comments.contains(mmbr.tree.symbol))
+ if (comments contains mmbr.tree.symbol)
comment(comments(mmbr.tree.symbol), false)
else
NodeSeq.Empty
def shortComment(mmbr: HasTree): NodeSeq =
- if (comments.contains(mmbr.tree.symbol))
+ if (comments contains mmbr.tree.symbol)
comment(comments(mmbr.tree.symbol), true)
else
NodeSeq.Empty
@@ -337,7 +370,7 @@ abstract class DocGenerator extends Models {
if (before) nodes.concat(forTree(tree))
else {
val ret = forTree(tree).concat(nodes)
- //System.err.println("RET: " + ret);
+ //System.err.println("RET: " + ret)
ret
}
} else NodeSeq.Empty
@@ -403,7 +436,7 @@ abstract class DocGenerator extends Models {
def resultFor(ht: HasTree): NodeSeq = ht.tree match {
case vdef: ValOrDefDef =>
if (!vdef.symbol.nameString.equals("this"))
- Text(" : ").concat(forTree(vdef.tpt));
+ Text(" : ").concat(forTree(vdef.tpt))
else
NodeSeq.Empty
case _ =>
@@ -426,12 +459,12 @@ abstract class DocGenerator extends Models {
This document is the API specification for Scala 2.
<p/>
{ {
- for (val kind <- KINDS; classes.contains(kind)) yield {
+ for (val kind <- KINDS; classes contains kind) yield {
<span><hr/><table cellpadding="3" class="member" summary="">
<tr><td colspan="2" class="title">
{labelFor(kind)} Summary
</td></tr>{ {
- for (val mmbr <- classes(kind).toList) yield shortHeader(mmbr);
+ for (val mmbr <- classes(kind).toList) yield shortHeader(mmbr)
} }
</table></span>
}
@@ -486,7 +519,7 @@ abstract class DocGenerator extends Models {
assert(cdef.symbol.owner != NoSymbol)
val sym = cdef.symbol.owner.asInstanceOf[ModuleClassSymbol]
if (!sym.isEmptyPackageClass) {
- if (!topLevel.contains(sym)) topLevel = topLevel.update(sym, emptyMap);
+ if (!topLevel.contains(sym)) topLevel = topLevel.update(sym, emptyMap)
topLevel = topLevel.update(sym, organize0(mmbr, topLevel(sym)))
}
case _ =>
@@ -497,7 +530,7 @@ abstract class DocGenerator extends Models {
val modules0 = {
var modules0 = new TreeMap[String, ModuleClassSymbol]
for (val top <- topLevel.elements)
- modules0 = modules0.insert(top._1.fullNameString, top._1);
+ modules0 = modules0.insert(top._1.fullNameString, top._1)
modules0
}
@@ -512,7 +545,7 @@ abstract class DocGenerator extends Models {
def classes = {
var allClasses = emptyMap
for (val top <- topLevel.elements)
- allClasses = merge(allClasses, top._2);
+ allClasses = merge(allClasses, top._2)
allClasses
}
def title = "List of all classes and objects"
@@ -558,10 +591,11 @@ abstract class DocGenerator extends Models {
def path = "index"
override def hasBody = false
}
+ val rsrcdir = "scala/tools/nsc/doc/".replace('/', File.separatorChar)
for (val base <- "style.css" :: "script.js" :: Nil) {
- val input = loader.getResourceAsStream("scala/tools/nsc/doc/" + base)
+ val input = loader.getResourceAsStream(rsrcdir + base)
if (input != null) {
- val file = new File(outdir + "/" + base)
+ val file = new File(outdir + File.separator + base)
val output = new FileOutputStream(file)
var break = false
val bytes = new Array[byte](1024)
@@ -588,7 +622,7 @@ abstract class DocGenerator extends Models {
def organize0(mmbr: HasTree, map0: ListMap[Kind, TreeSet[HasTree]]) = {
var map = map0
- assert(mmbr.kind != null);
+ assert(mmbr.kind != null)
if (!map.contains(mmbr.kind))
map = map.update(mmbr.kind, new TreeSet[HasTree])
val sz = map(mmbr.kind).size
@@ -664,7 +698,7 @@ abstract class DocGenerator extends Models {
else <span><dl><dd>{parse(body)}</dd></dl><dl>
{ {
for (val attr <- attributes) yield
- <dt style="margin:10px 0 0 10px;">
+ <dt style="margin:10px 0 0 20px;">
{tag(attr._1)}
</dt>
<dd>{(parse(attr._2))}</dd>;
@@ -682,6 +716,8 @@ abstract class DocGenerator extends Models {
val root = <b></b>
+ private val LINE_SEPARATOR = System.getProperty("line.separator", "\n")
+
private val NAME_SUFFIX_OBJECT = "$object"
private val NAME_SUFFIX_PACKAGE = "$package"
private val FILE_EXTENSION_HTML = ".html"
diff --git a/src/library/scala/All$.scala b/src/library/scala/All$.scala
index 5859adf6c9..70b52d8ef1 100644
--- a/src/library/scala/All$.scala
+++ b/src/library/scala/All$.scala
@@ -9,12 +9,12 @@
// $Id: All$.java 5880 2006-03-02 23:05:17Z mihaylov $
-package scala;
+package scala
/**
* Dummy class which exist only to satisfy the JVM. It corresponds
- * to scala.All. If such type appears in method
+ * to <code>scala.All</code>. If such type appears in method
* signatures, it is erased to this one.
*/
diff --git a/src/library/scala/AllRef$.scala b/src/library/scala/AllRef$.scala
index 15dc79930e..919b4983a3 100644
--- a/src/library/scala/AllRef$.scala
+++ b/src/library/scala/AllRef$.scala
@@ -9,12 +9,12 @@
// $Id: AllRef$.java 5880 2006-03-02 23:05:17Z mihaylov $
-package scala;
+package scala
/**
* Dummy class which exist only to satisfy the JVM. It corresponds
- * to scala.AllRef. If such type appears in method
+ * to <code>scala.AllRef</code>. If such type appears in method
* signatures, it is erased to this one.
*/
diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala
index f5db3c40ac..a289884eca 100644
--- a/src/library/scala/Application.scala
+++ b/src/library/scala/Application.scala
@@ -15,8 +15,8 @@ package scala
/** The <code>Application</code> class can be used to quickly turn objects
* into executable programs. Here is an example:
* <pre>
- * object Main with Application {
- * Console.println("Hello World!");
+ * <b>object</b> Main <b>extends</b> Application {
+ * Console.println("Hello World!")
* }
* </pre>
* Here, object <code>Main</code> inherits the <code>main</code> method
@@ -43,6 +43,8 @@ trait Application {
val executionStart: Long = java.lang.System.currentTimeMillis()
/** The default main method.
+ *
+ * @param args the arguments passed to the main method
*/
def main(args: Array[String]) = {
if (java.lang.System.getProperty("scala.time") != null) {
diff --git a/src/library/scala/CaseClass.scala b/src/library/scala/CaseClass.scala
index 88d2fa8c48..dabdf2d930 100644
--- a/src/library/scala/CaseClass.scala
+++ b/src/library/scala/CaseClass.scala
@@ -12,7 +12,8 @@
package scala
-/** defines an access function for instances of case classes
+/** The trait <code>CaseClass</code> defines access functions for instances
+ * of case classes.
*
* @author Burak Emir
* @version 1.0
@@ -22,7 +23,7 @@ trait CaseClass extends AnyRef {
/** for a case class <code>A(x_0,...,x_(k-1))</code>, returns <code>x_i</code>
* for <code>0 &lt;= i &lt; k</code>, <code>null</code> otherwise.
*
- * @param n ...
+ * @param n the position of the n-th element
* @return ...
*/
def caseElement(n: Int): Any
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala
index 031609e577..146a05e2d7 100644
--- a/src/library/scala/Enumeration.scala
+++ b/src/library/scala/Enumeration.scala
@@ -19,16 +19,16 @@ import scala.collection.mutable._
* <code>enum</code> construct found in C-like languages like C++ or Java.
* Here is an example:</p>
* <pre>
- * <b>object</b> Main <b>with</b> Application {
+ * <b>object</b> Main <b>extends</b> Application {
*
* <b>object</b> WeekDays <b>extends</b> Enumeration {
* <b>val</b> Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
* }
*
* <b>def</b> isWorkingDay(d: WeekDays.Value) =
- * ! (d == WeekDays.Sat || d == WeekDays.Sun);
+ * ! (d == WeekDays.Sat || d == WeekDays.Sun)
*
- * WeekDays filter (isWorkingDay) foreach { d =&gt; System.out.println(d) }
+ * WeekDays filter (isWorkingDay) foreach { d =&gt; Console.println(d) }
* }
* </pre>
*
diff --git a/src/library/scala/SerialVersionUID.scala b/src/library/scala/SerialVersionUID.scala
index f74d60fc1e..4467303067 100644
--- a/src/library/scala/SerialVersionUID.scala
+++ b/src/library/scala/SerialVersionUID.scala
@@ -9,11 +9,11 @@
// $Id$
-package scala;
+package scala
/**
* Attribute for specifying the static SerialVersionUID field
* of a serializable class
*/
-class SerialVersionUID(uid: Long) extends Attribute {}
+class SerialVersionUID(uid: Long) extends Attribute
diff --git a/src/library/scala/volatile.scala b/src/library/scala/volatile.scala
index a776385cf5..3d40f25756 100644
--- a/src/library/scala/volatile.scala
+++ b/src/library/scala/volatile.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala;
+package scala
-class volatile extends Attribute {}
+class volatile extends Attribute
diff --git a/src/library/scala/xml/Group.scala b/src/library/scala/xml/Group.scala
index 7fae60725b..7a5a7a201c 100644
--- a/src/library/scala/xml/Group.scala
+++ b/src/library/scala/xml/Group.scala
@@ -9,49 +9,53 @@
// $Id$
-package scala.xml;
+package scala.xml
-import scala.runtime.compat.StringBuilder;
+import scala.runtime.compat.StringBuilder
-/** a hack to group XML nodes in one node for output
- * @author Burak Emir
+/** A hack to group XML nodes in one node for output.
+ *
+ * @author Burak Emir
+ * @version 1.0
*/
[serializable]
-case class Group(val nodes:Seq[Node]) extends Node {
+case class Group(val nodes: Seq[Node]) extends Node {
override def theSeq = nodes
/** structural equality */
override def equals(x: Any) = x match {
case z:Node => (length == 1) && z == apply(0)
- case z:Seq[Node] => sameElements( z )
+ case z:Seq[Node] => sameElements(z)
case z:String => text == z
case _ => false;
}
/** always null */
- final def label = error("class Group does not support method 'label'")
+ final def label =
+ error("class Group does not support method 'label'")
/** always empty */
- final override def attributes = error("class Group does not support method 'attributes'")
-
+ final override def attributes =
+ error("class Group does not support method 'attributes'")
/** always null */
- final override def namespace = error("class Group does not support method 'namespace'")
+ final override def namespace =
+ error("class Group does not support method 'namespace'")
/** always empty */
- final override def child = error("class Group does not support method 'child'")
+ final override def child =
+ error("class Group does not support method 'child'")
/** returns text, with some characters escaped according to XML spec */
def toString(sb: StringBuilder) =
error("class Group does not support method toString(StringBuilder)")
override def text = { // same impl as NodeSeq
- val sb = new StringBuilder();
- val it = elements;
- while(it.hasNext) {
- sb.append(it.next.text);
- }
- sb.toString();
+ val sb = new StringBuilder()
+ val it = elements
+ while (it.hasNext)
+ sb.append(it.next.text)
+ sb.toString()
}
}