diff options
author | michelou <michelou@epfl.ch> | 2006-06-22 15:06:31 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-06-22 15:06:31 +0000 |
commit | 9d39ff267ef9994bab3fde4a2f25ae5d509d09a4 (patch) | |
tree | e0811cec9ff107335f1a63600ee8df18db71c188 | |
parent | 6e372ca4770ff87d81ceb540b87a1f66fc1055aa (diff) | |
download | scala-9d39ff267ef9994bab3fde4a2f25ae5d509d09a4.tar.gz scala-9d39ff267ef9994bab3fde4a2f25ae5d509d09a4.tar.bz2 scala-9d39ff267ef9994bab3fde4a2f25ae5d509d09a4.zip |
fixed bug #638
-rw-r--r-- | src/compiler/scala/tools/ant/Scaladoc.scala | 9 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/DocUtil.scala | 9 | ||||
-rwxr-xr-x | test/clitest | 39 |
3 files changed, 48 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index 08ddbfb320..5940b900d0 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -384,7 +384,14 @@ package scala.tools.ant { if (!extdirs.isEmpty) settings.extdirs.value = asString(getExtdirs) if (!encoding.isEmpty) settings.encoding.value = encoding.get if (!windowtitle.isEmpty) settings.windowtitle.value = windowtitle.get - if (!documenttitle.isEmpty) settings.documenttitle.value = documenttitle.get + if (!documenttitle.isEmpty) settings.documenttitle.value = + // In Ant script characters '<' and '>' must be encoded when + // used in attribute values, e.g. for attribute "documenttitle" + // in task Scaladoc you may write: + // documenttitle="<div>Scala</div>" + // so we have to decode them here. + documenttitle.get.replaceAll("<", "<").replaceAll(">",">") + .replaceAll("&", "&").replaceAll(""", "\"") // Compiles the actual code object compiler extends Global(settings, reporter) diff --git a/src/compiler/scala/tools/nsc/doc/DocUtil.scala b/src/compiler/scala/tools/nsc/doc/DocUtil.scala index 1a72be08d6..1e5312bbf8 100644 --- a/src/compiler/scala/tools/nsc/doc/DocUtil.scala +++ b/src/compiler/scala/tools/nsc/doc/DocUtil.scala @@ -18,11 +18,10 @@ object DocUtil { DQUOTE :: Text(str) :: DQUOTE :: Nil def load(str: String): NodeSeq = { - val xmlStr = str.replaceAll("<", "<").replaceAll(">",">") - .replaceAll("&", "&").replaceAll(""", "\"") - val xmlSrc = new InputSource(new StringReader(xmlStr)) - //System.err.println("loading: " + xmlStr); // debug - XML.load(xmlSrc) + val xmlSrc = + if (str.matches("^(<!--.*-->)*<[^>]+>.*<[^>]+>(<!--.*-->)*$")) str + else "<span>" + str + "</span>" + XML.load(new StringReader(xmlSrc)) } object DQUOTE extends SpecialNode { diff --git a/test/clitest b/test/clitest index 0d132c1e2c..bf093089dd 100755 --- a/test/clitest +++ b/test/clitest @@ -151,7 +151,7 @@ test_compile() { check="$1"; shift 1; info="$1"; shift 1; [ -d "$OUTPUT_DIR" ] || mkdir -p $OUTPUT_DIR; - [ -f "$LOG_FILE" ] && rm $LOG_FILE; + [ -f "$LOG_FILE" ] && $RM $LOG_FILE; if [ "$COMPILER" = "javac" ] || [ "$COMPILER" = "jikes" ]; then suffix=".${COMPILER}"; [ "$LANG" = "java5" ] && suffix=".${COMPILER}5"; @@ -201,7 +201,7 @@ test_execute() { suffix=".$LANG"; [ "$LANG" = "java6" ] && suffix=".java5"; - [ -f "$LOG_FILE" ] && rm $LOG_FILE; + [ -f "$LOG_FILE" ] && $RM $LOG_FILE; printf "\\n"; printf "Execute $main with unknown option '-cpp'\\n" @@ -236,7 +236,7 @@ test_interpret() { main="$1"; shift 1; check="$1"; shift 1; [ "$LANG" = "scala" ] || return; - [ -f "$LOG_FILE" ] && rm $LOG_FILE; + [ -f "$LOG_FILE" ] && $RM $LOG_FILE; printf "\\n" printf "Interpret $main with unknown option '-cpp'\\n" @@ -266,6 +266,35 @@ test_interpret() { test_diff "$check.scalaint" "$LOG_FILE"; } +test_docgen() { + [ $# = 2 ] || abort "internal error"; + source="$1"; shift 1; + check="$1"; shift 1; + [ -d "$OUTPUT_DIR" ] || mkdir -p $OUTPUT_DIR; + [ -f "$LOG_FILE" ] && $RM $LOG_FILE; + [ -d "$API_DIR" ] && $RM -r "$API_DIR/*" || mkdir -p $API_DIR; + suffix=".${LANG}_api"; + file=`echo $source | sed -e "s#$PREFIX/##g"`; + if [ "$LEVEL" = "info" ] || [ "$LEVEL" = "verbose" ] ; then + printf_outline "\\nSource file: $file\\n" + cat $source; + fi + printf "\\n"; + + printf "Generate documentation for $file\\n" + test_run "env CLASSPATH= $DOCGEN_COMMAND \ + -d $API_DIR $source 2>> $LOG_FILE 1>> $LOG_FILE"; + + n=`$TREE $API_DIR | wc -l`; + $TREE $API_DIR | tail -n `echo "$n-1" | bc` > "$LOG_FILE"; + test_diff "$check$suffix" "$LOG_FILE"; + + if [ "$LEVEL" = "verbose" ] ; then + printf_outline "\\nAPI directory:\\n"; + $TREE $API_DIR; + fi +} + ############################################################################## # Initialization @@ -314,6 +343,7 @@ else fi; SOURCE_DIR=$TEST_DIR/files/cli OUTPUT_DIR=$TMP_DIR/classes +API_DIR=$TMP_DIR/api DIFF="diff"; RM="rm -f"; @@ -352,11 +382,13 @@ if [ "$LANG" = "scala" ]; then RUNTIME_COMMAND="${BIN_DIR}scala" COMPILER_COMMAND="${BIN_DIR}$COMPILER" INTERPRETER_COMMAND="${BIN_DIR}scalaint" + DOCGEN_COMMAND="${BIN_DIR}scaladoc"; elif [ "$LANG" = "java" ]; then RUNTIME_COMMAND=`which ${JAVACMD:=java}` BIN_DIR=`dirname $RUNTIME_COMMAND`; [ "$COMPILER" = "javac" ] && COMPILER_COMMAND=$BIN_DIR/$COMPILER; [ "$COMPILER" = "jikes" ] && COMPILER_COMMAND=`which $COMPILER`; + DOCGEN_COMMAND=`dirname "$COMPILER_COMMAND"`/javadoc; else abort "unknown language '$LANG'" fi @@ -413,6 +445,7 @@ for testfile in "" $FILES; do sed -e "s#${SOURCE_DIR}/\(.*\)\${SUFFIX}#\1#g" -e "s#\/#\.#g"`; test_execute "$scala_main" "$checkfile"; test_interpret "$scala_main" "$checkfile"; + test_docgen "$testfile" "$checkfile"; fi done; |