Skip to content

Commit e06a381

Browse files
committed
Scala3doc: document stdlib together with Dotty extensions
1 parent d8ff7d8 commit e06a381

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

project/Build.scala

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,16 @@ object Build {
841841
settings(
842842
moduleName := "scala-library",
843843
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value,
844+
Compile/scalacOptions += "-Yerased-terms",
845+
Compile/scalacOptions ++= {
846+
Seq(
847+
"-sourcepath",
848+
Seq(
849+
(Compile/sourceManaged).value / "scala-library-src",
850+
(Compile/sourceManaged).value / "dotty-library-src",
851+
).mkString(File.pathSeparator),
852+
)
853+
},
844854
scalacOptions -= "-Xfatal-warnings",
845855
ivyConfigurations += SourceDeps.hide,
846856
transitiveClassifiers := Seq("sources"),
@@ -870,6 +880,30 @@ object Build {
870880
((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet
871881
} (Set(scalaLibrarySourcesJar)).toSeq
872882
}.taskValue,
883+
sourceGenerators in Compile += Def.task {
884+
val s = streams.value
885+
val cacheDir = s.cacheDirectory
886+
val trgDir = (sourceManaged in Compile).value / "dotty-library-src"
887+
888+
// NOTE `sourceDirectory` is used for actual copying,
889+
// but `sources` are used as cache keys
890+
val dottyLibSourceDir = (`scala3-library-bootstrapped`/sourceDirectory).value
891+
val dottyLibSources = (`scala3-library-bootstrapped`/Compile/sources).value
892+
893+
val cachedFun = FileFunction.cached(
894+
cacheDir / s"copyDottyLibrarySrc",
895+
FilesInfo.lastModified,
896+
FilesInfo.exists,
897+
) { _ =>
898+
s.log.info(s"Copying scala3-library sources from $dottyLibSourceDir to $trgDir...")
899+
if (trgDir.exists) IO.delete(trgDir)
900+
IO.copyDirectory(dottyLibSourceDir, trgDir)
901+
902+
((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet
903+
}
904+
905+
cachedFun(dottyLibSources.toSet).toSeq
906+
}.taskValue,
873907
sources in Compile ~= (_.filterNot(file =>
874908
// sources from https://github.com/scala/scala/tree/2.13.x/src/library-aux
875909
file.getPath.endsWith("scala-library-src/scala/Any.scala") ||
@@ -1489,7 +1523,7 @@ object Build {
14891523
}
14901524

14911525
def joinProducts(products: Seq[java.io.File]): String =
1492-
products.iterator.map(_.getAbsolutePath.toString).mkString(java.io.File.pathSeparator)
1526+
products.iterator.map(_.getAbsolutePath.toString).mkString(" ")
14931527

14941528
val dokkaVersion = "1.4.10.2"
14951529

@@ -1537,7 +1571,7 @@ object Build {
15371571
(`scala3-library-bootstrapped`/Compile/products).value,
15381572
).flatten
15391573

1540-
val roots = dottyJars.mkString(" ")
1574+
val roots = joinProducts(dottyJars)
15411575

15421576
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
15431577
else Def.task{
@@ -1554,6 +1588,8 @@ object Build {
15541588
generateScala3StdlibDocumentation:= Def.taskDyn {
15551589
val dottyJars: Seq[java.io.File] = Seq(
15561590
(`stdlib-bootstrapped`/Compile/products).value,
1591+
(`scala3-interfaces`/Compile/products).value,
1592+
(`tasty-core-bootstrapped`/Compile/products).value,
15571593
).flatten
15581594

15591595
val roots = joinProducts(dottyJars)

0 commit comments

Comments
 (0)