Skip to content

Commit 4314d63

Browse files
author
michelou
committed
scaladoc fixes and improvements
Changes to scaladoc include: - fixed transformation of Code(text) into HTML tag <code> - added tool tips for deprecated entities (classes, methods) using the 'title' attribute - added syntax highlighting of Scala source code in generated <pre> blocks (CSS colors are defined in lib/template.css) Here are several examples of highlighted Scala code: scala.App scala.Application scala.Enumeration scala.Function1 scala.Function2 scala.native scala.Option scala.Proxy scala.specialized scala.throws scala.unchecked scala.actors.Actor scala.annotation.deprecatedName scala.annotation.elidable scala.annotation.switch scala.collection.DefaultMap scala.collection.JavaConversions scala.collection.JavaConverters scala.collection.LinearSeqLike scala.collection.MapLike scala.collection.SetLike scala.collection.TraversableLike scala.collection.immutable.NumericRange scala.collection.immutable.Range scala.collection.immutable.Stream scala.collection.mutable.BufferLike scala.concurrent.pilib scala.io.Position scala.reflect.BeanProperty scala.reflect.Manifest scala.testing.Benchmark scala.util.DynamicVariable scala.util.control.Breaks scala.util.control.ControlThrowable scala.util.control.Exception scala.util.control.TailCalls scala.util.logging.Logged scala.util.parsing.combinator.testing.Tester scala.util.parsing.json.JSON scala.util.regexp.WordExp scala.xml.factory.LoggedNodeFactory scala.xml.parsing.ConstructingParser git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25294 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
1 parent 22c1514 commit 4314d63

File tree

25 files changed

+647
-259
lines changed

25 files changed

+647
-259
lines changed

src/compiler/scala/reflect/api/Trees.scala

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,20 +356,16 @@ trait Trees /*extends reflect.generic.Trees*/ { self: Universe =>
356356
case class If(cond: Tree, thenp: Tree, elsep: Tree)
357357
extends TermTree
358358

359-
/** <p>
360-
* Pattern matching expression (before explicitouter)
361-
* Switch statements (after explicitouter)
362-
* </p>
363-
* <p>
364-
* After explicitouter, cases will satisfy the following constraints:
365-
* </p>
366-
* <ul>
367-
* <li>all guards are EmptyTree,</li>
368-
* <li>all patterns will be either <code>Literal(Constant(x:Int))</code>
369-
* or <code>Alternative(lit|...|lit)</code></li>
370-
* <li>except for an "otherwise" branch, which has pattern
371-
* <code>Ident(nme.WILDCARD)</code></li>
372-
* </ul>
359+
/** - Pattern matching expression (before explicitouter)
360+
* - Switch statements (after explicitouter)
361+
*
362+
* After explicitouter, cases will satisfy the following constraints:
363+
*
364+
* - all guards are `EmptyTree`,
365+
* - all patterns will be either `Literal(Constant(x:Int))`
366+
* or `Alternative(lit|...|lit)`
367+
* - except for an "otherwise" branch, which has pattern
368+
* `Ident(nme.WILDCARD)`
373369
*/
374370
case class Match(selector: Tree, cases: List[CaseDef])
375371
extends TermTree

src/compiler/scala/reflect/internal/AnnotationInfos.scala

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,38 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
1313

1414
/** Arguments to classfile annotations (which are written to
1515
* bytecode as java annotations) are either:
16-
* <ul>
17-
* <li>constants</li>
18-
* <li>arrays of constants</li>
19-
* <li>or nested classfile annotations</li>
20-
* </ul>
16+
*
17+
* - constants
18+
* - arrays of constants
19+
* - or nested classfile annotations
2120
*/
2221
abstract class ClassfileAnnotArg
2322

24-
/** Represents a compile-time Constant (Boolean, Byte, Short,
25-
* Char, Int, Long, Float, Double, String, java.lang.Class or
23+
/** Represents a compile-time Constant (`Boolean`, `Byte`, `Short`,
24+
* `Char`, `Int`, `Long`, `Float`, `Double`, `String`, `java.lang.Class` or
2625
* an instance of a Java enumeration value).
2726
*/
2827
case class LiteralAnnotArg(const: Constant)
2928
extends ClassfileAnnotArg {
3029
override def toString = const.escapedStringValue
3130
}
32-
31+
3332
object LiteralAnnotArg extends LiteralAnnotArgExtractor
34-
33+
3534
/** Represents an array of classfile annotation arguments */
3635
case class ArrayAnnotArg(args: Array[ClassfileAnnotArg])
3736
extends ClassfileAnnotArg {
3837
override def toString = args.mkString("[", ", ", "]")
3938
}
40-
39+
4140
object ArrayAnnotArg extends ArrayAnnotArgExtractor
4241

43-
/** A specific annotation argument that encodes an array of bytes as an array of `Long`. The type of the argument
44-
* declared in the annotation must be `String`. This specialised class is used to encode scala signatures for
45-
* reasons of efficiency, both in term of class-file size and in term of compiler performance. */
42+
/** A specific annotation argument that encodes an array of bytes as an
43+
* array of `Long`. The type of the argument declared in the annotation
44+
* must be `String`. This specialised class is used to encode Scala
45+
* signatures for reasons of efficiency, both in term of class-file size
46+
* and in term of compiler performance.
47+
*/
4648
case class ScalaSigBytes(bytes: Array[Byte]) extends ClassfileAnnotArg {
4749
override def toString = (bytes map { byte => (byte & 0xff).toHexString }).mkString("[ ", " ", " ]")
4850
lazy val encodedBytes = ByteCodecs.encode(bytes)
@@ -61,35 +63,26 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
6163
assert(annInfo.args.isEmpty, annInfo.args)
6264
override def toString = annInfo.toString
6365
}
64-
66+
6567
object NestedAnnotArg extends NestedAnnotArgExtractor
6668

6769
class AnnotationInfoBase
6870

69-
/** <p>
70-
* Typed information about an annotation. It can be attached to
71-
* either a symbol or an annotated type.
72-
* </p>
73-
* <p>
74-
* Annotations are written to the classfile as java annotations
75-
* if <code>atp</code> conforms to <code>ClassfileAnnotation</code>
76-
* (the classfile parser adds this interface to any Java annotation
77-
* class).
78-
* </p>
79-
* <p>
80-
* Annotations are pickled (written to scala symtab attribute
81-
* in the classfile) if <code>atp</code> inherits form
82-
* <code>StaticAnnotation</code>.
83-
* </p>
84-
* <p>
85-
* <code>args</code> stores arguments to Scala annotations,
86-
* represented as typed trees. Note that these trees are not
87-
* transformed by any phases following the type-checker.
88-
* </p>
89-
* <p>
90-
* <code>assocs</code> stores arguments to classfile annotations
91-
* as name-value pairs.
92-
* </p>
71+
/** Typed information about an annotation. It can be attached to either
72+
* a symbol or an annotated type.
73+
*
74+
* Annotations are written to the classfile as Java annotations
75+
* if `atp` conforms to `ClassfileAnnotation` (the classfile parser adds
76+
* this interface to any Java annotation class).
77+
*
78+
* Annotations are pickled (written to scala symtab attribute in the
79+
* classfile) if `atp` inherits form `StaticAnnotation`.
80+
*
81+
* `args` stores arguments to Scala annotations, represented as typed
82+
* trees. Note that these trees are not transformed by any phases
83+
* following the type-checker.
84+
*
85+
* `assocs` stores arguments to classfile annotations as name-value pairs.
9386
*/
9487
case class AnnotationInfo(atp: Type, args: List[Tree],
9588
assocs: List[(Name, ClassfileAnnotArg)])
@@ -136,13 +129,13 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
136129
case Literal(Constant(x: Int)) => x
137130
} else None
138131
}
139-
132+
140133
object AnnotationInfo extends AnnotationInfoExtractor
141134

142135
lazy val classfileAnnotArgManifest: ClassManifest[ClassfileAnnotArg] =
143136
reflect.ClassManifest.classType(classOf[ClassfileAnnotArg])
144137

145-
/** Symbol annotations parsed in Namer (typeCompleter of
138+
/** Symbol annotations parsed in `Namer` (typeCompleter of
146139
* definitions) have to be lazy (#1782)
147140
*/
148141
case class LazyAnnotationInfo(annot: () => AnnotationInfo)

src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @author Martin Odersky
44
*/
55

6-
76
package scala.tools.nsc
87
package backend
98

@@ -15,14 +14,13 @@ import scala.collection.{ mutable, immutable }
1514
* function is applied repeatedly to the first element in the
1615
* worklist, as long as the stack is not empty.
1716
*
18-
* The client class should mix-in this class and initialize the
19-
* worklist field and define the <code>processElement</code> method.
20-
* Then call the <code>run</code> method providing a function that
21-
* initializes the worklist.
17+
* The client class should mix-in this class and initialize the worklist
18+
* field and define the `processElement` method. Then call the `run` method
19+
* providing a function that initializes the worklist.
2220
*
2321
* @author Martin Odersky
2422
* @version 1.0
25-
* @see <a href="icode/Linearizers.html" target="contentFrame">scala.tools.nsc.backend.icode.Linearizers</a>
23+
* @see [[scala.tools.nsc.backend.icode.Linearizers]]
2624
*/
2725
trait WorklistAlgorithm {
2826
type Elem
@@ -31,9 +29,9 @@ trait WorklistAlgorithm {
3129
val worklist: WList
3230

3331
/**
34-
* Run the iterative algorithm until the worklist
35-
* remains empty. The initializer is run once before
36-
* the loop starts and should initialize the worklist.
32+
* Run the iterative algorithm until the worklist remains empty.
33+
* The initializer is run once before the loop starts and should
34+
* initialize the worklist.
3735
*
3836
* @param initWorklist ...
3937
*/

src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
* @author Martin Odersky
44
*/
55

6-
76
package scala.tools.nsc
87
package backend.icode.analysis
98

109
import scala.collection.{mutable, immutable}
1110

12-
/** A data-flow analysis on types, that works on <code>ICode</code>.
11+
/** A data-flow analysis on types, that works on `ICode`.
1312
*
1413
* @author Iulian Dragos
1514
*/
@@ -95,7 +94,7 @@ abstract class TypeFlowAnalysis {
9594
}
9695

9796
val timer = new Timer
98-
97+
9998
class MethodTFA extends DataFlowAnalysis[typeFlowLattice.type] {
10099
import icodes._
101100
import icodes.opcodes._

src/compiler/scala/tools/nsc/doc/DocFactory.scala

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
/* NSC -- new Scala compiler -- Copyright 2007-2011 LAMP/EPFL */
1+
/* NSC -- new Scala compiler
2+
* Copyright 2007-2011 LAMP/EPFL
3+
* @author David Bernard, Manohar Jonnalagedda
4+
*/
25

36
package scala.tools.nsc
47
package doc
@@ -9,18 +12,20 @@ import util.NoPosition
912
import io.{ File, Directory }
1013
import DocParser.Parsed
1114

12-
/** A documentation processor controls the process of generating Scala documentation, which is as follows.
15+
/** A documentation processor controls the process of generating Scala
16+
* documentation, which is as follows.
1317
*
14-
* * A simplified compiler instance (with only the front-end phases enabled) is created, and additional
15-
* ''sourceless'' comments are registered.
18+
* * A simplified compiler instance (with only the front-end phases enabled)
19+
* * is created, and additional ''sourceless'' comments are registered.
1620
* * Documentable files are compiled, thereby filling the compiler's symbol table.
1721
* * A documentation model is extracted from the post-compilation symbol table.
1822
* * A generator is used to transform the model into the correct final format (HTML).
1923
*
20-
* A processor contains a single compiler instantiated from the processor's `settings`. Each call to `document`
21-
* uses the same compiler instance with the same symbol table. In particular, this implies that the scaladoc site
22-
* obtained from a call to `run` will contain documentation about files compiled during previous calls to the same
23-
* processor's `run` method.
24+
* A processor contains a single compiler instantiated from the processor's
25+
* `settings`. Each call to `document` uses the same compiler instance with
26+
* the same symbol table. In particular, this implies that the scaladoc site
27+
* obtained from a call to `run` will contain documentation about files compiled
28+
* during previous calls to the same processor's `run` method.
2429
*
2530
* @param reporter The reporter to which both documentation and compilation errors will be reported.
2631
* @param settings The settings to be used by the documenter and compiler for generating documentation.
@@ -41,9 +46,10 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
4146
override def forScaladoc = true
4247
}
4348

44-
/** Creates a scaladoc site for all symbols defined in this call's `files`, as well as those defined in `files` of
45-
* previous calls to the same processor.
46-
* @param files The list of paths (relative to the compiler's source path, or absolute) of files to document. */
49+
/** Creates a scaladoc site for all symbols defined in this call's `files`,
50+
* as well as those defined in `files` of previous calls to the same processor.
51+
* @param files The list of paths (relative to the compiler's source path,
52+
* or absolute) of files to document. */
4753
def makeUniverse(files: List[String]): Option[Universe] = {
4854
assert(settings.docformat.value == "html")
4955
new compiler.Run() compile files
@@ -83,9 +89,9 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
8389
println("no documentable class found in compilation units")
8490
None
8591
}
86-
92+
8793
}
88-
94+
8995
object NoCompilerRunException extends ControlThrowable { }
9096

9197
val documentError: PartialFunction[Throwable, Unit] = {
@@ -97,7 +103,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
97103

98104
/** Generate document(s) for all `files` containing scaladoc documenataion.
99105
* @param files The list of paths (relative to the compiler's source path, or absolute) of files to document. */
100-
def document(files: List[String]): Unit = {
106+
def document(files: List[String]) {
101107
def generate() = {
102108
import doclet._
103109
val docletClass = Class.forName(settings.docgenerator.value) // default is html.Doclet
@@ -107,7 +113,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
107113
case universer: Universer =>
108114
val universe = makeUniverse(files) getOrElse { throw NoCompilerRunException }
109115
universer setUniverse universe
110-
116+
111117
docletInstance match {
112118
case indexer: Indexer => indexer setIndex model.IndexModelFactory.makeIndex(universe)
113119
case _ => ()
@@ -116,10 +122,11 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
116122
}
117123
docletInstance.generate
118124
}
119-
125+
120126
try generate()
121127
catch documentError
122128
}
129+
123130
private[doc] def docdbg(msg: String) {
124131
if (settings.Ydocdebug.value)
125132
println(msg)

src/compiler/scala/tools/nsc/doc/DocParser.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import util._
1212
import interactive.RangePositions
1313
import DocParser.Parsed
1414

15-
/** A very minimal global customized for extracting DocDefs. It stops
16-
* right after parsing so it can read DocDefs from source code which would
15+
/** A very minimal global customized for extracting `DocDefs`. It stops
16+
* right after parsing so it can read `DocDefs` from source code which would
1717
* otherwise cause the compiler to go haywire.
1818
*/
1919
class DocParser(settings: nsc.Settings, reporter: Reporter)
@@ -31,8 +31,8 @@ class DocParser(settings: nsc.Settings, reporter: Reporter)
3131
phasesSet += syntaxAnalyzer
3232
}
3333

34-
/** Returns a list of DocParser.Parseds, which hold the DocDefs found in the
35-
* given code along with the surrounding trees.
34+
/** Returns a list of `DocParser.Parseds`, which hold the DocDefs found
35+
* in the given code along with the surrounding trees.
3636
*/
3737
def docDefs(code: String) = {
3838
def loop(enclosing: List[Tree], tree: Tree): List[Parsed] = tree match {
@@ -54,7 +54,7 @@ class DocParser(settings: nsc.Settings, reporter: Reporter)
5454
}
5555

5656
/** Since the DocParser's whole reason for existing involves trashing a
57-
* global, it is designed to bottle up general Global#Tree types rather
57+
* global, it is designed to bottle up general `Global#Tree` types rather
5858
* than path dependent ones. The recipient will have to deal.
5959
*/
6060
object DocParser {

src/compiler/scala/tools/nsc/doc/Index.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* NSC -- new Scala compiler
2+
* Copyright 2005-2011 LAMP/EPFL
3+
* @author Martin Odersky
4+
*/
5+
16
package scala.tools.nsc.doc
27

38
import scala.collection._

src/compiler/scala/tools/nsc/doc/Settings.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import java.lang.System
1212
/** An extended version of compiler settings, with additional Scaladoc-specific options.
1313
* @param error A function that prints a string to the appropriate error stream. */
1414
class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) {
15-
15+
1616
/** A setting that defines in which format the documentation is output. ''Note:'' this setting is currently always
1717
* `html`. */
1818
val docformat = ChoiceSetting (
@@ -40,13 +40,14 @@ class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) {
4040
"An optional version number, to be appended to the title",
4141
""
4242
)
43-
43+
4444
val docUncompilable = StringSetting (
4545
"-doc-no-compile",
4646
"path",
4747
"A directory containing sources which should be parsed, no more (e.g. AnyRef.scala)",
4848
""
4949
)
50+
5051
lazy val uncompilableFiles = docUncompilable.value match {
5152
case "" => Nil
5253
case path => io.Directory(path).deepFiles filter (_ hasExtension "scala") toList
@@ -57,7 +58,7 @@ class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) {
5758
val docsourceurl = StringSetting (
5859
"-doc-source-url",
5960
"url",
60-
"A URL pattern used to build links to template sources; use variables, for example: {TPL_NAME} ('Seq'), {TPL_OWNER} ('scala.collection'), {FILE_PATH} ('scala/collection/Seq')",
61+
"A URL pattern used to build links to template sources; use variables, for example: ?{TPL_NAME} ('Seq'), ?{TPL_OWNER} ('scala.collection'), ?{FILE_PATH} ('scala/collection/Seq')",
6162
""
6263
)
6364

src/compiler/scala/tools/nsc/doc/Universe.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* NSC -- new Scala compiler
2+
* Copyright 2005-2011 LAMP/EPFL
3+
* @author Martin Odersky
4+
*/
5+
16
package scala.tools.nsc.doc
27

38
/**

0 commit comments

Comments
 (0)