@@ -136,8 +136,6 @@ object Build {
136
136
137
137
val fetchScalaJSSource = taskKey[File ](" Fetch the sources of Scala.js" )
138
138
139
- val artifactsForScala3Documentation = taskKey[Seq [File ]](" Artifacts to be documented by Scala3doc" )
140
-
141
139
lazy val SourceDeps = config(" sourcedeps" )
142
140
143
141
// Settings shared by the build (scoped in ThisBuild). Used in build.sbt
@@ -1160,6 +1158,9 @@ object Build {
1160
1158
1161
1159
val testcasesOutputDir = taskKey[String ](" Root directory where tests classses are generated" )
1162
1160
val testcasesSourceRoot = taskKey[String ](" Root directory where tests sources are generated" )
1161
+ val generateSelfDocumentation = inputKey[Unit ](" Generate example documentation" )
1162
+ val generateScala3Documentation = taskKey[Unit ](" Generate documentation for dotty lib" )
1163
+ val generateTestcasesDocumentation = taskKey[Unit ](" Generate documentation for testcases, usefull for debugging tests" )
1163
1164
lazy val `scala3doc` = project.in(file(" scala3doc" )).asScala3doc
1164
1165
lazy val `scala3doc-testcases` = project.in(file(" scala3doc-testcases" )).asScala3docTestcases
1165
1166
@@ -1450,30 +1451,69 @@ object Build {
1450
1451
settings(commonBenchmarkSettings).
1451
1452
enablePlugins(JmhPlugin )
1452
1453
1453
- def asScala3doc : Project =
1454
+ def asScala3doc : Project = {
1455
+ def generateDocumentation (targets : String , name : String , outDir : String , params : String = " " ) = Def .taskDyn {
1456
+ val sourceMapping = " =https://github.com/lampepfl/dotty/tree/master#L"
1457
+ run.in(Compile ).toTask(s """ -o output/ $outDir -t $targets -n " $name" -s $sourceMapping $params""" )
1458
+ }
1459
+
1454
1460
project.settings(commonBootstrappedSettings).
1455
1461
dependsOn(`scala3-compiler-bootstrapped`).
1456
1462
dependsOn(`scala3-tasty-inspector`).
1457
1463
settings(
1458
1464
resolvers += Resolver .jcenterRepo,
1459
1465
resolvers += Resolver .bintrayRepo(" kotlin" , " kotlin-dev" ),
1460
1466
resolvers += Resolver .bintrayRepo(" virtuslab" , " dokka" ),
1461
- artifactsForScala3Documentation := Seq (
1462
- // All projects below will be used to generated documentation for Scala 3
1463
- classDirectory.in(`scala3-interfaces`).in(Compile ).value,
1464
- classDirectory.in(`tasty-core`).in(Compile ).value,
1465
- classDirectory.in(`scala3-library`).in(Compile ).value,
1466
- // TODO this one fails to load using TASTY
1467
- // classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1467
+ libraryDependencies ++= Seq (
1468
+ " org.scala-lang" %% " scala3-tasty-inspector" % scalaVersion.value,
1469
+
1470
+ " com.virtuslab.dokka" % " dokka-site" % " 0.1.9" ,
1471
+ " com.vladsch.flexmark" % " flexmark-all" % " 0.42.12" ,
1472
+ " nl.big-o" % " liqp" % " 0.6.7" ,
1473
+ " args4j" % " args4j" % " 2.33" ,
1474
+
1475
+ " org.jetbrains.dokka" % " dokka-test-api" % " 1.4.10.2" % " test" ,
1476
+ " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1468
1477
),
1469
- test.in(Test ) := {
1470
- // Test
1471
- compile.in(Compile ).in(`scala3doc-testcases`).value
1472
- test.in(Test ).value
1473
- },
1478
+ test.in(Test ) := test.in(Test ).dependsOn(compile.in(Compile ).in(`scala3doc-testcases`)).value,
1474
1479
testcasesOutputDir.in(Test ) := classDirectory.in(Compile ).in(`scala3doc-testcases`).value.getAbsolutePath.toString,
1475
- testcasesSourceRoot.in(Test ) := (baseDirectory.in(`scala3doc-testcases`).value / " src" ).getAbsolutePath.toString
1480
+ testcasesSourceRoot.in(Test ) := (baseDirectory.in(`scala3doc-testcases`).value / " src" ).getAbsolutePath.toString,
1481
+ fork.in(run) := true ,
1482
+ Compile / mainClass := Some (" dotty.dokka.Main" ),
1483
+ // There is a bug in dokka that prevents parallel tests withing the same jvm
1484
+ fork.in(test) := true ,
1485
+ Test / parallelExecution := false ,
1486
+ generateSelfDocumentation := Def .inputTaskDyn {
1487
+ generateDocumentation(classDirectory.in(Compile ).value.getAbsolutePath, " scala3doc" , " self" , " -d documentation" )
1488
+ }.evaluated,
1489
+ generateScala3Documentation := Def .taskDyn {
1490
+ val dottyJars = Seq (
1491
+ // All projects below will be used to generated documentation for Scala 3
1492
+ classDirectory.in(`scala3-interfaces`).in(Compile ).value,
1493
+ classDirectory.in(`tasty-core`).in(Compile ).value,
1494
+ classDirectory.in(`scala3-library`).in(Compile ).value,
1495
+ // TODO this one fails to load using TASTY
1496
+ // classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1497
+ )
1498
+ val roots = dottyJars.map(_.toString).mkString(java.io.File .pathSeparator)
1499
+
1500
+ if (dottyJars.isEmpty) Def .task { streams.value.log.error(" Dotty lib wasn't found" ) }
1501
+ else generateDocumentation(roots, " Scala 3" , " stdLib" , " -d dotty-docs/docs" )
1502
+ }.value,
1503
+ generateTestcasesDocumentation := Def .taskDyn {
1504
+ generateDocumentation(Build .testcasesOutputDir.in(Test ).value, " Scala3doc testcases" , " testcases" )
1505
+ }.value,
1506
+ buildInfoKeys in Test := Seq [BuildInfoKey ](
1507
+ Build .testcasesOutputDir.in(Test ),
1508
+ Build .testcasesSourceRoot.in(Test ),
1509
+ ),
1510
+ buildInfoPackage in Test := " dotty.dokka" ,
1511
+ BuildInfoPlugin .buildInfoScopedSettings(Test ),
1512
+ BuildInfoPlugin .buildInfoDefaultSettings,
1513
+ // Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
1514
+ // javaOptions.in(run) += "-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"
1476
1515
)
1516
+ }
1477
1517
1478
1518
def asScala3docTestcases : Project =
1479
1519
project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
0 commit comments