diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-05-05 12:03:48 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-08-19 15:37:22 +0200 |
commit | 00203025abbb16a0fc45ababa02550dcb4b20671 (patch) | |
tree | 6394cde2037dd336bac4fe3bc0dd59dff23293c3 /dottydoc | |
parent | 29cf43bca7e478f290e7c39a05ce7e8bcb218d3d (diff) | |
download | dotty-00203025abbb16a0fc45ababa02550dcb4b20671.tar.gz dotty-00203025abbb16a0fc45ababa02550dcb4b20671.tar.bz2 dotty-00203025abbb16a0fc45ababa02550dcb4b20671.zip |
Add test for checking if Array has documentation after compiling std lib
Diffstat (limited to 'dottydoc')
-rw-r--r-- | dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala | 3 | ||||
-rw-r--r-- | dottydoc/jvm/test/CompilerTest.scala | 11 | ||||
-rw-r--r-- | dottydoc/jvm/test/TestCommentParsing.scala | 11 | ||||
-rw-r--r-- | dottydoc/jvm/test/WhitelistedStdLib.scala | 6 |
4 files changed, 22 insertions, 9 deletions
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala index 4650b21d8..e3aff1d71 100644 --- a/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala +++ b/dottydoc/jvm/src/dotty/tools/dottydoc/core/Phases.scala @@ -119,10 +119,11 @@ object Phases { val compUnits = super.runOn(units) // (2) Create documentation template from docstrings, with internal links + println("Generating documentation, this might take a while...") commentParser.parse(packages) // (3) Write the finished model to JSON - util.IndexWriters.writeJs(packages, "../js/out") + if (!ctx.settings.YDocNoWrite.value) util.IndexWriters.writeJs(packages, "../js/out") // (4) Clear caches commentParser.clear() diff --git a/dottydoc/jvm/test/CompilerTest.scala b/dottydoc/jvm/test/CompilerTest.scala index 4cafc72e0..001e4d422 100644 --- a/dottydoc/jvm/test/CompilerTest.scala +++ b/dottydoc/jvm/test/CompilerTest.scala @@ -2,7 +2,7 @@ package dotty.tools package dottydoc import dotc.core.Contexts -import Contexts.{ Context, ContextBase } +import Contexts.{ Context, ContextBase, FreshContext } import dotc.core.Phases.Phase import dotc.typer.FrontEnd import dottydoc.core.Phases.DocPhase @@ -10,17 +10,20 @@ import dottydoc.core.Phases.DocPhase trait DottyTest { dotty.tools.dotc.parsing.Scanners // initialize keywords - implicit var ctx: Contexts.Context = { + implicit var ctx: FreshContext = { val base = new ContextBase import base.settings._ val ctx = base.initialCtx.fresh + ctx.setSetting(ctx.settings.language, List("Scala2")) ctx.setSetting(ctx.settings.YkeepComments, true) + ctx.setSetting(ctx.settings.YDocNoWrite, true) base.initialize()(ctx) ctx } private def compilerWithChecker(assertion: DocPhase => Unit) = new DottyDocCompiler { - val docPhase = new DocPhase + private[this] val docPhase = new DocPhase + override def phases = List(new FrontEnd) :: List(docPhase) :: @@ -38,7 +41,7 @@ trait DottyTest { run.compile(source) } - def checkCompile(sources:List[String])(assertion: DocPhase => Unit): Unit = { + def checkCompile(sources: List[String])(assertion: DocPhase => Unit): Unit = { val c = compilerWithChecker(assertion) c.rootContext(ctx) val run = c.newRun diff --git a/dottydoc/jvm/test/TestCommentParsing.scala b/dottydoc/jvm/test/TestCommentParsing.scala index 16e855957..12f60f6a6 100644 --- a/dottydoc/jvm/test/TestCommentParsing.scala +++ b/dottydoc/jvm/test/TestCommentParsing.scala @@ -5,5 +5,14 @@ import org.junit.Test import org.junit.Assert._ class TestWhitelistedCollections extends DottyTest { - @Test def test = assert(false) + @Test def arrayHasDocumentation = + checkCompile(WhitelistedStandardLib.files) { doc => + val array = doc + .packages("scala") + .children + .find(_.path.mkString(".") == "scala.Array") + .get + + assert(array.comment.get.body.length > 0) + } } diff --git a/dottydoc/jvm/test/WhitelistedStdLib.scala b/dottydoc/jvm/test/WhitelistedStdLib.scala index 2ab832870..f4a2f9dc6 100644 --- a/dottydoc/jvm/test/WhitelistedStdLib.scala +++ b/dottydoc/jvm/test/WhitelistedStdLib.scala @@ -4,7 +4,7 @@ package dottydoc import scala.io.Source object WhitelistedStandardLib extends DottyDoc { - val files: Array[String] = { + val files: List[String] = { val whitelist = "../../test/dotc/scala-collections.whitelist" Source.fromFile(whitelist, "UTF8") @@ -15,9 +15,9 @@ object WhitelistedStandardLib extends DottyDoc { .filter(_.nonEmpty) .filterNot(_.endsWith("package.scala")) .map("../." + _) - .toArray + .toList } override def main(args: Array[String]) = - super.main("-language:Scala2" +: files) + super.main("-language:Scala2" +: files.toArray) } |