summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-02-01 12:58:52 +0000
committermichelou <michelou@epfl.ch>2008-02-01 12:58:52 +0000
commit222998874fb15354823e255384bf6ee6d1898d27 (patch)
tree523924d95f286b1270bafee7cbaa877e327451aa /src
parent856ffa7572e1ce74b354bfc3b529643c5193f97c (diff)
downloadscala-222998874fb15354823e255384bf6ee6d1898d27.tar.gz
scala-222998874fb15354823e255384bf6ee6d1898d27.tar.bz2
scala-222998874fb15354823e255384bf6ee6d1898d27.zip
fixed #224
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/doc/ModelToXML.scala25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/ModelToXML.scala b/src/compiler/scala/tools/nsc/doc/ModelToXML.scala
index ce68fb9f1c..331ce62ad6 100644
--- a/src/compiler/scala/tools/nsc/doc/ModelToXML.scala
+++ b/src/compiler/scala/tools/nsc/doc/ModelToXML.scala
@@ -267,11 +267,34 @@ trait ModelToXML extends ModelExtractor {
{
val cmnt = entity.decodeComment
if (cmnt.isEmpty) NodeSeq.Empty
- else <div>{parse(cmnt.get.body)}</div>;
+ else shortComment(cmnt.get)
}
</td>
</tr>
+ import java.util.regex.Pattern
+ // pattern detecting first line of comment (see ticket #224)
+ private val pat = Pattern.compile("[ \t]*(/\\*)[ \t]*")
+
+ /** Ticket #224
+ * Write the first sentence as a short summary of the method, as scaladoc
+ * automatically places it in the method summary table (and index).
+ * (see http://java.sun.com/j2se/javadoc/writingdoccomments/)
+ */
+ def shortComment(cmnt: Comment): NodeSeq = {
+ val lines = cmnt.body split "<p>"
+ val first =
+ if (lines.length < 2)
+ lines(0)
+ else {
+ val line0 = lines(0)
+ val mat = pat matcher line0
+ if (mat.matches()) line0 + lines(1)
+ else line0
+ }
+ <div>{parse(first/*cmnt.body*/)}</div>
+ }
+
def attrsFor(entity: Entity)(implicit from: Frame): NodeSeq = {
def attrFor(attr: AnnotationInfo): Node = {
val buf = new StringBuilder