aboutsummaryrefslogtreecommitdiff
path: root/doc-tool/test/GenDocs.scala
blob: c60e8f1e06279ba172a56ea04be86077e76fb101 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package dotty.tools
package dottydoc

object Files {
  type JFile = java.io.File

  implicit class ToUrl(val f: JFile) extends AnyVal {
    def getUrl = f.toURI.toURL
  }
}

trait LocalResources extends api.scala.Dottydoc {
  import Files._

  def getFiles(file: JFile): Array[JFile] =
    if (file.isDirectory) file.listFiles.flatMap(getFiles)
    else if (file.getAbsolutePath.endsWith(".scala")) Array(file)
    else Array()

  def withClasspath(files: Array[String]) =
    "-language:Scala2" +:
    "-classpath" +: "../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar:../interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" +:
    files
}

object GenCollections extends LocalResources {
  import Files._

  val collections = TestWhitelistedCollections.files

  override def main(args: Array[String]): Unit =
    super.main(Array("-siteroot", "../docs") ++ withClasspath(collections.toArray))
}

object GenDottyDocs extends LocalResources {
  import Files._

  val dottyFiles = new JFile("../compiler/src/dotty").listFiles.flatMap(getFiles).map(_.getAbsolutePath)

  override def main(args: Array[String]): Unit =
    super.main(Array("-siteroot", "../docs") ++ withClasspath(dottyFiles))
}