Skip to content

Commit

Permalink
Scala3doc merge cleanups
Browse files Browse the repository at this point in the history
Fix misspellings and whitespace issues.

Remove definition of scala3doc-example-project subproject.

Configure scala3doc-test/doc to document using Scala3doc, as it contains
visually important classes.
  • Loading branch information
abgruszecki authored and romanowski committed Oct 29, 2020
1 parent 608b6e3 commit f0a8719
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scala3doc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI for scala3doc
name: CI for Scala3doc

on:
push:
Expand Down
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ val `tasty-core` = Build.`tasty-core`
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
val `tasty-core-scala2` = Build.`tasty-core-scala2`
val scala3doc = Build.scala3doc
val scala3docTest = Build.`scala3doc-test`
// val `scala3doc-example-project` = Build.`scala3doc-example-project`
val `scala3doc-test` = Build.`scala3doc-test`
val `scala3-bench-run` = Build.`scala3-bench-run`
val dist = Build.dist
val `community-build` = Build.`community-build`
Expand Down
110 changes: 45 additions & 65 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object Build {

val fetchScalaJSSource = taskKey[File]("Fetch the sources of Scala.js")

val aritfactsForScala3Documentation = taskKey[Seq[File]]("All artifacts to document")
val artifactsForScala3Documentation = taskKey[Seq[File]]("Artifacts to be documented by Scala3doc")

lazy val SourceDeps = config("sourcedeps")

Expand Down Expand Up @@ -1160,7 +1160,6 @@ object Build {

lazy val `scala3doc` = project.in(file("scala3doc")).asScala3doc
lazy val `scala3doc-test` = project.in(file("scala3doc-test")).asScala3docTest
lazy val `scala3doc-example-project` = project.in(file("scala3doc-example-project")).asDocExampleProject

// sbt plugin to use Dotty in your own build, see
// https://github.com/lampepfl/scala3-example-project for usage.
Expand Down Expand Up @@ -1449,78 +1448,59 @@ object Build {
settings(commonBenchmarkSettings).
enablePlugins(JmhPlugin)

def commonScala3DocSettings = commonBootstrappedSettings ++ Seq(
scalaVersion := dottyVersion,
def commonScala3docSettings = Seq(
resolvers += Resolver.jcenterRepo,
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev"),
resolvers += Resolver.bintrayRepo("virtuslab", "dokka"),
)

def asScala3doc: Project =
project.
settings(commonScala3DocSettings).
def asScala3doc: Project =
project.settings(commonBootstrappedSettings).
settings(commonScala3docSettings).
dependsOn(`scala3-compiler-bootstrapped`).
dependsOn(`scala3-tasty-inspector`).
settings(aritfactsForScala3Documentation := Seq(
// All projects below will be put co generated documentaiton for Scala 3
classDirectory.in(`scala3-interfaces`).in(Compile).value,
classDirectory.in(`tasty-core`).in(Compile).value,
classDirectory.in(`scala3-library`).in(Compile).value,
// TODO this one fails to load using TASTY
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
settings(artifactsForScala3Documentation := Seq(
// All projects below will be used to generated documentation for Scala 3
classDirectory.in(`scala3-interfaces`).in(Compile).value,
classDirectory.in(`tasty-core`).in(Compile).value,
classDirectory.in(`scala3-library`).in(Compile).value,
// TODO this one fails to load using TASTY
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
))

def asScala3docTest: Project =
project.
settings(commonScala3DocSettings).
dependsOn(`scala3doc`)

def asDocExampleProject: Project = project.
settings(commonBootstrappedSettings0).
dependsOn(`scala3-compiler-bootstrapped`).
settings(
Compile/scalaSource := baseDirectory.value / "src/main/scala",
Test/scalaSource := baseDirectory.value / "src/test/scala",
Compile/resourceDirectory := baseDirectory.value / "src/main/resources",
Test/resourceDirectory := baseDirectory.value / "src/test/resources",

name := "scala3doc-example-project",
description := "Example SBT project that is documented using Scala3doc",
version := "0.1.0-SNAPSHOT",
scalaVersion := dottyVersion,

useScala3doc := true,
scala3docOptions ++= Seq("--name", "example-project"),
Compile / doc / target := file("out/doc/example-project"),

// we cannot set
doc/scalaInstance := {
val externalNonBootstrappedDeps = externalDependencyClasspath.in(`scala3doc`, Compile).value
val scalaLibrary = findArtifact(externalNonBootstrappedDeps, "scala-library")

// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
// just directories containing classfiles because sbt maintains a cache of
// compiler instances. This cache is invalidated based on timestamps
// however this is only implemented on jars, directories are never
// invalidated.
val tastyCore = packageBin.in(`tasty-core`, Compile).value
val dottyLibrary = packageBin.in(`scala3-library-bootstrapped`, Compile).value
val dottyInterfaces = packageBin.in(`scala3-interfaces`, Compile).value
val dottyCompiler = packageBin.in(`scala3-compiler-bootstrapped`, Compile).value
val doctool = packageBin.in(`scala3doc`, Compile).value

val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, doctool) ++ externalNonBootstrappedDeps.map(_.data)

makeScalaInstance(
state.value,
scalaVersion.value,
scalaLibrary,
dottyLibrary,
dottyCompiler,
allJars
)
},
)
def asScala3docTest: Project =
project.settings(commonBootstrappedSettings0).
settings(commonScala3docSettings).
dependsOn(`scala3doc`).
settings(
Compile/doc/target := baseDirectory.value / "../out/doc" / name.value,
doc/scalaInstance := {
val externalNonBootstrappedDeps = externalDependencyClasspath.in(`scala3doc`, Compile).value
val scalaLibrary = findArtifact(externalNonBootstrappedDeps, "scala-library")

// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
// just directories containing classfiles because sbt maintains a cache of
// compiler instances. This cache is invalidated based on timestamps
// however this is only implemented on jars, directories are never
// invalidated.
val tastyCore = packageBin.in(`tasty-core`, Compile).value
val dottyLibrary = packageBin.in(`scala3-library-bootstrapped`, Compile).value
val dottyInterfaces = packageBin.in(`scala3-interfaces`, Compile).value
val dottyCompiler = packageBin.in(`scala3-compiler-bootstrapped`, Compile).value
val doctool = packageBin.in(`scala3doc`, Compile).value

val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, doctool) ++ externalNonBootstrappedDeps.map(_.data)

makeScalaInstance(
state.value,
scalaVersion.value,
scalaLibrary,
dottyLibrary,
dottyCompiler,
allJars
)
},
)

def asDist(implicit mode: Mode): Project = project.
enablePlugins(PackPlugin).
Expand Down
8 changes: 4 additions & 4 deletions scala3doc-test/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ libraryDependencies ++= Seq(
"com.novocode" % "junit-interface" % "0.11" % "test",
)

val testOuputDir = taskKey[String]("Root directory where tests classses are generated")
testOuputDir := (Compile/target/classDirectory).value.getAbsolutePath.toString
val testOutputDir = taskKey[String]("Root directory where tests classses are generated")
testOutputDir := (Compile/target/classDirectory).value.getAbsolutePath.toString

val testSourceRoot = taskKey[String]("Root directory where tests sources are generated")
testSourceRoot := (baseDirectory.value / "src").getAbsolutePath.toString


buildInfoKeys in Test := Seq[BuildInfoKey](
testOuputDir,
testOutputDir,
testSourceRoot,
)
buildInfoPackage in Test := "dotty.dokka"
Expand All @@ -27,4 +27,4 @@ fork.in(run) := true

// There is a bug in dokka that prevents parallel tests withing the same jvm
fork.in(test) := true
Test / parallelExecution := false
Test / parallelExecution := false
2 changes: 1 addition & 1 deletion scala3doc-test/test/dotty/dokka/MultipleFileTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class MultipleFileTest(val sourceFiles: List[String], val tastyFolders:
val unexpectedFromSource = allFromSource.map(_._2).flatten.filter(extractSymbolName(_) != "NULL").map(cleanup)
val unexpectedSignatureSymbolNames = unexpectedFromSource.map(extractSymbolName)

val allFromDocumentation = tastyFolders.flatMap(folder => signaturesFromDocumentation(s"${BuildInfo.testOuputDir}/tests/$folder"))
val allFromDocumentation = tastyFolders.flatMap(folder => signaturesFromDocumentation(s"${BuildInfo.testOutputDir}/tests/$folder"))
val fromDocumentation = allFromDocumentation.filter(extractSymbolName(_) != "NULL").map(cleanup)

val documentedSignatures = fromDocumentation.flatMap(matchSignature(_, expectedFromSource)).toSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MemberLookupTests {
import java.io.File
import scala.collection.mutable.ListBuffer

val classRoot = new File(BuildInfo.testOuputDir)
val classRoot = new File(BuildInfo.testOutputDir)

def go(bld: ListBuffer[String])(file: File): Unit =
file.listFiles.foreach { f =>
Expand Down
18 changes: 5 additions & 13 deletions scala3doc/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,21 @@ fork.in(run) := true
Compile / mainClass := Some("dotty.dokka.Main")



def generateDottyDocsFromClasspath(artifacts: Seq[String]) = Def.taskDyn {
val roots = artifacts.mkString(java.io.File.pathSeparator)
val mapping = "=https://github.com/lampepfl/dotty/tree/master#L"
if (artifacts.isEmpty) Def.task {
streams.value.log.error("Dotty lib wasn't found")
} else Def.task {
run.in(Compile).toTask(s" -o output/stdLib -t $roots -d dotty-docs/docs -n dotty-lib -s $mapping ").value
}
}
}

val generateScala3Documentation = taskKey[Unit]("Generate documentation for dotty lib")
generateScala3Documentation := Def.taskDyn {
val dotttyJars = Build.aritfactsForScala3Documentation.value.map(_.toString)
generateScala3Documentation := Def.taskDyn {
val dottyJars = Build.artifactsForScala3Documentation.value.map(_.toString)

streams.value.log.info(s"Documenting classes from:\n${dotttyJars.mkString("\n")}")
streams.value.log.info(s"Documenting classes from:\n${dottyJars.mkString("\n")}")

generateDottyDocsFromClasspath(dotttyJars)
generateDottyDocsFromClasspath(dottyJars)
}.value

val prepareExampleProject = taskKey[Unit]("Prepare example projet for interaction test")
prepareExampleProject := {



}

0 comments on commit f0a8719

Please sign in to comment.