From 5632167f6cacec16d82b1961d233d7e761cf6036 Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Tue, 27 Mar 2012 10:35:40 +0200 Subject: Fixes SI-5373 And adds basic support for scaladoc model tests (class partest.ScaladocModelTest) --- src/compiler/scala/tools/nsc/doc/DocFactory.scala | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/compiler/scala/tools/nsc/doc/DocFactory.scala') diff --git a/src/compiler/scala/tools/nsc/doc/DocFactory.scala b/src/compiler/scala/tools/nsc/doc/DocFactory.scala index 9a025b0d14..f32564f097 100644 --- a/src/compiler/scala/tools/nsc/doc/DocFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/DocFactory.scala @@ -8,7 +8,7 @@ package doc import scala.util.control.ControlThrowable import reporters.Reporter -import util.NoPosition +import util.{ NoPosition, BatchSourceFile} import io.{ File, Directory } import DocParser.Parsed @@ -46,13 +46,19 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor override def forScaladoc = true } - /** Creates a scaladoc site for all symbols defined in this call's `files`, - * as well as those defined in `files` of previous calls to the same processor. + /** Creates a scaladoc site for all symbols defined in this call's `source`, + * as well as those defined in `sources` of previous calls to the same processor. * @param files The list of paths (relative to the compiler's source path, * or absolute) of files to document. */ - def makeUniverse(files: List[String]): Option[Universe] = { + def makeUniverse(source: Either[List[String], String]): Option[Universe] = { assert(settings.docformat.value == "html") - new compiler.Run() compile files + source match { + case Left(files) => + new compiler.Run() compile files + case Right(sourceCode) => + new compiler.Run() compileSources List(new BatchSourceFile("newSource", sourceCode)) + } + if (reporter.hasErrors) return None @@ -111,7 +117,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor docletInstance match { case universer: Universer => - val universe = makeUniverse(files) getOrElse { throw NoCompilerRunException } + val universe = makeUniverse(Left(files)) getOrElse { throw NoCompilerRunException } universer setUniverse universe docletInstance match { -- cgit v1.2.3