diff options
author | michelou <michelou@epfl.ch> | 2008-02-01 12:58:52 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2008-02-01 12:58:52 +0000 |
commit | 222998874fb15354823e255384bf6ee6d1898d27 (patch) | |
tree | 523924d95f286b1270bafee7cbaa877e327451aa | |
parent | 856ffa7572e1ce74b354bfc3b529643c5193f97c (diff) | |
download | scala-222998874fb15354823e255384bf6ee6d1898d27.tar.gz scala-222998874fb15354823e255384bf6ee6d1898d27.tar.bz2 scala-222998874fb15354823e255384bf6ee6d1898d27.zip |
fixed #224
-rw-r--r-- | build.xml | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/ModelToXML.scala | 25 |
2 files changed, 26 insertions, 1 deletions
@@ -876,6 +876,7 @@ ANDROID srcdir="${android.dir}/src" destdir="${android.dir}/lib/library" usepredefs="no" + deprecation="yes" unchecked="yes" addparams="${nsc.params}" extdirs="" scalacdebugging="${nsc.log-files}" @@ -889,6 +890,7 @@ ANDROID <quick srcdir="${android.dir}/src" destdir="${android.dir}/lib/library" + deprecation="yes" unchecked="yes" extdirs="" addparams="${nsc.params}" scalacdebugging="${nsc.log-files}" 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 |