Skip to content

Commit f0a8719

Browse files
abgruszeckiromanowski
authored andcommitted
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 608b6e3 commit f0a8719

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

@@ -1160,7 +1160,6 @@ object Build {
11601160

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

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

1452-
def commonScala3DocSettings = commonBootstrappedSettings ++ Seq(
1453-
scalaVersion := dottyVersion,
1451+
def commonScala3docSettings = Seq(
14541452
resolvers += Resolver.jcenterRepo,
14551453
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev"),
14561454
resolvers += Resolver.bintrayRepo("virtuslab", "dokka"),
14571455
)
14581456

1459-
def asScala3doc: Project =
1460-
project.
1461-
settings(commonScala3DocSettings).
1457+
def asScala3doc: Project =
1458+
project.settings(commonBootstrappedSettings).
1459+
settings(commonScala3docSettings).
14621460
dependsOn(`scala3-compiler-bootstrapped`).
14631461
dependsOn(`scala3-tasty-inspector`).
1464-
settings(aritfactsForScala3Documentation := Seq(
1465-
// All projects below will be put co generated documentaiton for Scala 3
1466-
classDirectory.in(`scala3-interfaces`).in(Compile).value,
1467-
classDirectory.in(`tasty-core`).in(Compile).value,
1468-
classDirectory.in(`scala3-library`).in(Compile).value,
1469-
// TODO this one fails to load using TASTY
1470-
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1462+
settings(artifactsForScala3Documentation := Seq(
1463+
// All projects below will be used to generated documentation for Scala 3
1464+
classDirectory.in(`scala3-interfaces`).in(Compile).value,
1465+
classDirectory.in(`tasty-core`).in(Compile).value,
1466+
classDirectory.in(`scala3-library`).in(Compile).value,
1467+
// TODO this one fails to load using TASTY
1468+
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
14711469
))
14721470

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

15251505
def asDist(implicit mode: Mode): Project = project.
15261506
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)