Skip to content

Commit 6fc39bf

Browse files
committed
Scala3doc merge cleanups
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.
1 parent 9603491 commit 6fc39bf

File tree

7 files changed

+58
-87
lines changed

7 files changed

+58
-87
lines changed

.github/workflows/scala3doc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI for scala3doc
1+
name: CI for Scala3doc
22

33
on:
44
push:

build.sbt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ val `tasty-core` = Build.`tasty-core`
2121
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
2222
val `tasty-core-scala2` = Build.`tasty-core-scala2`
2323
val scala3doc = Build.scala3doc
24-
val scala3docTest = Build.`scala3doc-test`
25-
// val `scala3doc-example-project` = Build.`scala3doc-example-project`
24+
val `scala3doc-test` = Build.`scala3doc-test`
2625
val `scala3-bench-run` = Build.`scala3-bench-run`
2726
val dist = Build.dist
2827
val `community-build` = Build.`community-build`

project/Build.scala

Lines changed: 45 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ object Build {
136136

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

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

141141
lazy val SourceDeps = config("sourcedeps")
142142

@@ -1168,7 +1168,6 @@ object Build {
11681168

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

11731172
// sbt plugin to use Dotty in your own build, see
11741173
// https://github.com/lampepfl/scala3-example-project for usage.
@@ -1457,78 +1456,59 @@ object Build {
14571456
settings(commonBenchmarkSettings).
14581457
enablePlugins(JmhPlugin)
14591458

1460-
def commonScala3DocSettings = commonBootstrappedSettings ++ Seq(
1461-
scalaVersion := dottyVersion,
1459+
def commonScala3docSettings = Seq(
14621460
resolvers += Resolver.jcenterRepo,
14631461
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev"),
14641462
resolvers += Resolver.bintrayRepo("virtuslab", "dokka"),
14651463
)
14661464

1467-
def asScala3doc: Project =
1468-
project.
1469-
settings(commonScala3DocSettings).
1465+
def asScala3doc: Project =
1466+
project.settings(commonBootstrappedSettings).
1467+
settings(commonScala3docSettings).
14701468
dependsOn(`scala3-compiler-bootstrapped`).
14711469
dependsOn(`scala3-tasty-inspector`).
1472-
settings(aritfactsForScala3Documentation := Seq(
1473-
// All projects below will be put co generated documentaiton for Scala 3
1474-
classDirectory.in(`scala3-interfaces`).in(Compile).value,
1475-
classDirectory.in(`tasty-core`).in(Compile).value,
1476-
classDirectory.in(`scala3-library`).in(Compile).value,
1477-
// TODO this one fails to load using TASTY
1478-
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1470+
settings(artifactsForScala3Documentation := Seq(
1471+
// All projects below will be used to generated documentation for Scala 3
1472+
classDirectory.in(`scala3-interfaces`).in(Compile).value,
1473+
classDirectory.in(`tasty-core`).in(Compile).value,
1474+
classDirectory.in(`scala3-library`).in(Compile).value,
1475+
// TODO this one fails to load using TASTY
1476+
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
14791477
))
14801478

1481-
def asScala3docTest: Project =
1482-
project.
1483-
settings(commonScala3DocSettings).
1484-
dependsOn(`scala3doc`)
1485-
1486-
def asDocExampleProject: Project = project.
1487-
settings(commonBootstrappedSettings0).
1488-
dependsOn(`scala3-compiler-bootstrapped`).
1489-
settings(
1490-
Compile/scalaSource := baseDirectory.value / "src/main/scala",
1491-
Test/scalaSource := baseDirectory.value / "src/test/scala",
1492-
Compile/resourceDirectory := baseDirectory.value / "src/main/resources",
1493-
Test/resourceDirectory := baseDirectory.value / "src/test/resources",
1494-
1495-
name := "scala3doc-example-project",
1496-
description := "Example SBT project that is documented using Scala3doc",
1497-
version := "0.1.0-SNAPSHOT",
1498-
scalaVersion := dottyVersion,
1499-
1500-
useScala3doc := true,
1501-
scala3docOptions ++= Seq("--name", "example-project"),
1502-
Compile / doc / target := file("out/doc/example-project"),
1503-
1504-
// we cannot set
1505-
doc/scalaInstance := {
1506-
val externalNonBootstrappedDeps = externalDependencyClasspath.in(`scala3doc`, Compile).value
1507-
val scalaLibrary = findArtifact(externalNonBootstrappedDeps, "scala-library")
1508-
1509-
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1510-
// just directories containing classfiles because sbt maintains a cache of
1511-
// compiler instances. This cache is invalidated based on timestamps
1512-
// however this is only implemented on jars, directories are never
1513-
// invalidated.
1514-
val tastyCore = packageBin.in(`tasty-core`, Compile).value
1515-
val dottyLibrary = packageBin.in(`scala3-library-bootstrapped`, Compile).value
1516-
val dottyInterfaces = packageBin.in(`scala3-interfaces`, Compile).value
1517-
val dottyCompiler = packageBin.in(`scala3-compiler-bootstrapped`, Compile).value
1518-
val doctool = packageBin.in(`scala3doc`, Compile).value
1519-
1520-
val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, doctool) ++ externalNonBootstrappedDeps.map(_.data)
1521-
1522-
makeScalaInstance(
1523-
state.value,
1524-
scalaVersion.value,
1525-
scalaLibrary,
1526-
dottyLibrary,
1527-
dottyCompiler,
1528-
allJars
1529-
)
1530-
},
1531-
)
1479+
def asScala3docTest: Project =
1480+
project.settings(commonBootstrappedSettings0).
1481+
settings(commonScala3docSettings).
1482+
dependsOn(`scala3doc`).
1483+
settings(
1484+
Compile/doc/target := baseDirectory.value / "../out/doc" / name.value,
1485+
doc/scalaInstance := {
1486+
val externalNonBootstrappedDeps = externalDependencyClasspath.in(`scala3doc`, Compile).value
1487+
val scalaLibrary = findArtifact(externalNonBootstrappedDeps, "scala-library")
1488+
1489+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1490+
// just directories containing classfiles because sbt maintains a cache of
1491+
// compiler instances. This cache is invalidated based on timestamps
1492+
// however this is only implemented on jars, directories are never
1493+
// invalidated.
1494+
val tastyCore = packageBin.in(`tasty-core`, Compile).value
1495+
val dottyLibrary = packageBin.in(`scala3-library-bootstrapped`, Compile).value
1496+
val dottyInterfaces = packageBin.in(`scala3-interfaces`, Compile).value
1497+
val dottyCompiler = packageBin.in(`scala3-compiler-bootstrapped`, Compile).value
1498+
val doctool = packageBin.in(`scala3doc`, Compile).value
1499+
1500+
val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, doctool) ++ externalNonBootstrappedDeps.map(_.data)
1501+
1502+
makeScalaInstance(
1503+
state.value,
1504+
scalaVersion.value,
1505+
scalaLibrary,
1506+
dottyLibrary,
1507+
dottyCompiler,
1508+
allJars
1509+
)
1510+
},
1511+
)
15321512

15331513
def asDist(implicit mode: Mode): Project = project.
15341514
enablePlugins(PackPlugin).

scala3doc-test/build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ libraryDependencies ++= Seq(
55
"com.novocode" % "junit-interface" % "0.11" % "test",
66
)
77

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

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

1414

1515
buildInfoKeys in Test := Seq[BuildInfoKey](
16-
testOuputDir,
16+
testOutputDir,
1717
testSourceRoot,
1818
)
1919
buildInfoPackage in Test := "dotty.dokka"
@@ -27,4 +27,4 @@ fork.in(run) := true
2727

2828
// There is a bug in dokka that prevents parallel tests withing the same jvm
2929
fork.in(test) := true
30-
Test / parallelExecution := false
30+
Test / parallelExecution := false

scala3doc-test/test/dotty/dokka/MultipleFileTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ abstract class MultipleFileTest(val sourceFiles: List[String], val tastyFolders:
5959
val unexpectedFromSource = allFromSource.map(_._2).flatten.filter(extractSymbolName(_) != "NULL").map(cleanup)
6060
val unexpectedSignatureSymbolNames = unexpectedFromSource.map(extractSymbolName)
6161

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

6565
val documentedSignatures = fromDocumentation.flatMap(matchSignature(_, expectedFromSource)).toSet

scala3doc-test/test/dotty/dokka/tasty/comments/MemberLookupTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class MemberLookupTests {
123123
import java.io.File
124124
import scala.collection.mutable.ListBuffer
125125

126-
val classRoot = new File(BuildInfo.testOuputDir)
126+
val classRoot = new File(BuildInfo.testOutputDir)
127127

128128
def go(bld: ListBuffer[String])(file: File): Unit =
129129
file.listFiles.foreach { f =>

scala3doc/build.sbt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,21 @@ fork.in(run) := true
3030
Compile / mainClass := Some("dotty.dokka.Main")
3131

3232

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

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

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

50-
generateDottyDocsFromClasspath(dotttyJars)
49+
generateDottyDocsFromClasspath(dottyJars)
5150
}.value
52-
53-
val prepareExampleProject = taskKey[Unit]("Prepare example projet for interaction test")
54-
prepareExampleProject := {
55-
56-
57-
58-
}

0 commit comments

Comments
 (0)