@@ -213,6 +213,12 @@ object Build {
213
213
}
214
214
)
215
215
216
+ lazy val disableDocSetting =
217
+ // Disable scaladoc generation, it's way too slow and we'll replace it
218
+ // by dottydoc anyway. We still publish an empty -javadoc.jar to make
219
+ // sonatype happy.
220
+ sources in (Compile , doc) := Seq ()
221
+
216
222
lazy val commonSettings = publishSettings ++ Seq (
217
223
scalaSource in Compile := baseDirectory.value / " src" ,
218
224
scalaSource in Test := baseDirectory.value / " test" ,
@@ -221,11 +227,6 @@ object Build {
221
227
resourceDirectory in Compile := baseDirectory.value / " resources" ,
222
228
resourceDirectory in Test := baseDirectory.value / " test-resources" ,
223
229
224
- // Disable scaladoc generation, it's way too slow and we'll replace it
225
- // by dottydoc anyway. We still publish an empty -javadoc.jar to make
226
- // sonatype happy.
227
- sources in (Compile , doc) := Seq (),
228
-
229
230
// Prevent sbt from rewriting our dependencies
230
231
scalaModuleInfo ~= (_.map(_.withOverrideScalaVersion(false ))),
231
232
@@ -244,7 +245,8 @@ object Build {
244
245
crossPaths := false ,
245
246
// Do not depend on the Scala library
246
247
autoScalaLibrary := false ,
247
- excludeFromIDE := true
248
+ excludeFromIDE := true ,
249
+ disableDocSetting
248
250
)
249
251
250
252
// Settings used when compiling dotty (both non-bootstrapped and bootstrapped)
@@ -258,6 +260,8 @@ object Build {
258
260
moduleName ~= { _.stripSuffix(" -scala2" ) },
259
261
version := dottyVersion,
260
262
target := baseDirectory.value / " .." / " out" / " scala-2" / name.value,
263
+
264
+ disableDocSetting
261
265
)
262
266
263
267
// Settings used when compiling dotty with the reference compiler
@@ -267,6 +271,8 @@ object Build {
267
271
version := dottyNonBootstrappedVersion,
268
272
scalaVersion := referenceVersion,
269
273
excludeFromIDE := true ,
274
+
275
+ disableDocSetting
270
276
)
271
277
272
278
// Settings used when compiling dotty with a non-bootstrapped dotty
@@ -328,6 +334,8 @@ object Build {
328
334
},
329
335
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
330
336
scalaInstance in doc := scalaInstance.value,
337
+
338
+ disableDocSetting,
331
339
)
332
340
333
341
lazy val commonBenchmarkSettings = Seq (
@@ -1153,6 +1161,14 @@ object Build {
1153
1161
lazy val `scala3-bench-bootstrapped` = project.in(file(" bench" )).asDottyBench(Bootstrapped )
1154
1162
lazy val `scala3-bench-run` = project.in(file(" bench-run" )).asDottyBench(Bootstrapped )
1155
1163
1164
+ val testcasesOutputDir = taskKey[String ](" Root directory where tests classses are generated" )
1165
+ val testcasesSourceRoot = taskKey[String ](" Root directory where tests sources are generated" )
1166
+ val generateSelfDocumentation = taskKey[Unit ](" Generate example documentation" )
1167
+ val generateScala3Documentation = taskKey[Unit ](" Generate documentation for dotty lib" )
1168
+ val generateTestcasesDocumentation = taskKey[Unit ](" Generate documentation for testcases, usefull for debugging tests" )
1169
+ lazy val `scala3doc` = project.in(file(" scala3doc" )).asScala3doc
1170
+ lazy val `scala3doc-testcases` = project.in(file(" scala3doc-testcases" )).asScala3docTestcases
1171
+
1156
1172
// sbt plugin to use Dotty in your own build, see
1157
1173
// https://github.com/lampepfl/scala3-example-project for usage.
1158
1174
lazy val `sbt-dotty` = project.in(file(" sbt-dotty" )).
@@ -1192,6 +1208,7 @@ object Build {
1192
1208
publishLocal in `scala3-staging`,
1193
1209
publishLocal in `scala3-tasty-inspector`,
1194
1210
publishLocal in `scala3-doc-bootstrapped`,
1211
+ publishLocal in `scala3doc`,
1195
1212
publishLocal in `scala3-bootstrapped` // Needed because sbt currently hardcodes the dotty artifact
1196
1213
).evaluated
1197
1214
)
@@ -1393,7 +1410,7 @@ object Build {
1393
1410
def asDottyRoot (implicit mode : Mode ): Project = project.withCommonSettings.
1394
1411
aggregate(`scala3-interfaces`, dottyLibrary, dottyCompiler, tastyCore, dottyDoc, `scala3-sbt-bridge`).
1395
1412
bootstrappedAggregate(`scala3-language-server`, `scala3-staging`, `scala3-tasty-inspector`,
1396
- `scala3-library-bootstrappedJS`).
1413
+ `scala3-library-bootstrappedJS`, scala3doc ).
1397
1414
dependsOn(tastyCore).
1398
1415
dependsOn(dottyCompiler).
1399
1416
dependsOn(dottyLibrary).
@@ -1440,6 +1457,70 @@ object Build {
1440
1457
settings(commonBenchmarkSettings).
1441
1458
enablePlugins(JmhPlugin )
1442
1459
1460
+ def asScala3doc : Project = {
1461
+ def generateDocumentation (targets : String , name : String , outDir : String , params : String = " " ) = Def .taskDyn {
1462
+ val sourceMapping = " =https://github.com/lampepfl/dotty/tree/master#L"
1463
+ run.in(Compile ).toTask(s """ -d output/ $outDir -t $targets -n " $name" -s $sourceMapping $params""" )
1464
+ }
1465
+
1466
+ project.settings(commonBootstrappedSettings).
1467
+ dependsOn(`scala3-compiler-bootstrapped`).
1468
+ dependsOn(`scala3-tasty-inspector`).
1469
+ settings(
1470
+ // Needed to download dokka and its dependencies
1471
+ resolvers += Resolver .jcenterRepo,
1472
+ // Needed to download dokka-site
1473
+ resolvers += Resolver .bintrayRepo(" virtuslab" , " dokka" ),
1474
+ libraryDependencies ++= Seq (
1475
+ " com.virtuslab.dokka" % " dokka-site" % " 0.1.9" ,
1476
+ " com.vladsch.flexmark" % " flexmark-all" % " 0.42.12" ,
1477
+ " nl.big-o" % " liqp" % " 0.6.7" ,
1478
+ " args4j" % " args4j" % " 2.33" ,
1479
+
1480
+ " org.jetbrains.dokka" % " dokka-test-api" % " 1.4.10.2" % " test" ,
1481
+ " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1482
+ ),
1483
+ Test / test := (Test / test).dependsOn(compile.in(Compile ).in(`scala3doc-testcases`)).value,
1484
+ testcasesOutputDir.in(Test ) := classDirectory.in(Compile ).in(`scala3doc-testcases`).value.getAbsolutePath.toString,
1485
+ testcasesSourceRoot.in(Test ) := (baseDirectory.in(`scala3doc-testcases`).value / " src" ).getAbsolutePath.toString,
1486
+ Compile / mainClass := Some (" dotty.dokka.Main" ),
1487
+ // There is a bug in dokka that prevents parallel tests withing the same jvm
1488
+ fork.in(test) := true ,
1489
+ generateSelfDocumentation := Def .taskDyn {
1490
+ generateDocumentation(classDirectory.in(Compile ).value.getAbsolutePath, " scala3doc" , " self" , " -p documentation" )
1491
+ }.value,
1492
+ generateScala3Documentation := Def .taskDyn {
1493
+ val dottyJars = Seq (
1494
+ // All projects below will be used to generated documentation for Scala 3
1495
+ classDirectory.in(`scala3-interfaces`).in(Compile ).value,
1496
+ classDirectory.in(`tasty-core`).in(Compile ).value,
1497
+ classDirectory.in(`scala3-library`).in(Compile ).value,
1498
+ // TODO this one fails to load using TASTY
1499
+ // classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1500
+ )
1501
+ val roots = dottyJars.map(_.toString).mkString(java.io.File .pathSeparator)
1502
+
1503
+ if (dottyJars.isEmpty) Def .task { streams.value.log.error(" Dotty lib wasn't found" ) }
1504
+ else generateDocumentation(roots, " Scala 3" , " stdLib" , " -p dotty-docs/docs" )
1505
+ }.value,
1506
+ generateTestcasesDocumentation := Def .taskDyn {
1507
+ generateDocumentation(Build .testcasesOutputDir.in(Test ).value, " Scala3doc testcases" , " testcases" )
1508
+ }.value,
1509
+ buildInfoKeys in Test := Seq [BuildInfoKey ](
1510
+ Build .testcasesOutputDir.in(Test ),
1511
+ Build .testcasesSourceRoot.in(Test ),
1512
+ ),
1513
+ buildInfoPackage in Test := " dotty.dokka" ,
1514
+ BuildInfoPlugin .buildInfoScopedSettings(Test ),
1515
+ BuildInfoPlugin .buildInfoDefaultSettings,
1516
+ // Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
1517
+ // javaOptions.in(run) += "-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"
1518
+ )
1519
+ }
1520
+
1521
+ def asScala3docTestcases : Project =
1522
+ project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1523
+
1443
1524
def asDist (implicit mode : Mode ): Project = project.
1444
1525
enablePlugins(PackPlugin ).
1445
1526
withCommonSettings.
0 commit comments