@@ -1219,6 +1219,9 @@ object Build {
1219
1219
val generateSelfDocumentation = taskKey[Unit ](" Generate example documentation" )
1220
1220
// Note: the two tasks below should be one, but a bug in Tasty prevents that
1221
1221
val generateScalaDocumentation = inputKey[Unit ](" Generate documentation for dotty lib" )
1222
+ val getJarsForScaladoc = taskKey[Seq [String ]](" Get jars for scaladoc" )
1223
+ val getDocRootForScaladoc = taskKey[Path ](" Get doc root content file for scaladol" )
1224
+ val copyTheScaladocInputs = inputKey[Unit ](" Copy sources to be provided to the scaladoc" )
1222
1225
val generateTestcasesDocumentation = taskKey[Unit ](" Generate documentation for testcases, usefull for debugging tests" )
1223
1226
1224
1227
lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).
@@ -1320,46 +1323,65 @@ object Build {
1320
1323
" scaladoc" , " scaladoc/output/self" , VersionUtil .gitHash
1321
1324
)
1322
1325
}.value,
1326
+
1323
1327
generateScalaDocumentation := Def .inputTaskDyn {
1324
1328
val extraArgs = spaceDelimited(" [output]" ).parsed
1325
1329
val dest = file(extraArgs.headOption.getOrElse(" scaladoc/output/scala3" )).getAbsoluteFile
1330
+ val roots = extraArgs.lift(1 ).map(Seq (_)).getOrElse(getJarsForScaladoc.value)
1331
+ val docRootFile = extraArgs.lift(2 ).getOrElse(getDocRootForScaladoc.value)
1326
1332
val majorVersion = (LocalProject (" scala3-library-bootstrapped" ) / scalaBinaryVersion).value
1333
+ val isDefined = extraArgs.isDefinedAt(2 )
1334
+ if (roots.isEmpty) Def .task { streams.value.log.error(" Dotty lib wasn't found" ) }
1335
+ else Def .task {
1336
+ if (! isDefined) {
1337
+ IO .write(dest / " versions" / " latest-nightly-base" , majorVersion)
1338
+
1339
+ // This file is used by GitHub Pages when the page is available in a custom domain
1340
+ IO .write(dest / " CNAME" , " dotty.epfl.ch" )
1341
+ }
1342
+ }.dependsOn(generateDocumentation(
1343
+ roots, " Scala 3" , dest.getAbsolutePath, " master" ,
1344
+ Seq (
1345
+ " -comment-syntax" , " wiki" ,
1346
+ " -siteroot" , " docs" ,
1347
+ s " -source-links:docs=github://lampepfl/dotty/master#docs " ,
1348
+ " -doc-root-content" , docRootFile.toString,
1349
+ " -Ydocument-synthetic-types" ,
1350
+ " -versions-dictionary-url" , " http://127.0.0.1:5500/docs/_site/versions.json"
1351
+ ), usingScript = false
1352
+ ))
1353
+ }.evaluated,
1327
1354
1355
+ getJarsForScaladoc := Def .task {
1328
1356
val dottyJars : Seq [java.io.File ] = Seq (
1329
1357
(`stdlib-bootstrapped`/ Compile / products).value,
1330
1358
(`scala3-interfaces`/ Compile / products).value,
1331
1359
(`tasty-core-bootstrapped`/ Compile / products).value,
1332
1360
).flatten
1361
+ dottyJars.map(_.getAbsolutePath)
1362
+ }.value,
1333
1363
1334
- val roots = dottyJars.map(_.getAbsolutePath)
1335
-
1364
+ getDocRootForScaladoc := Def .task {
1336
1365
val managedSources =
1337
1366
(`stdlib-bootstrapped`/ Compile / sourceManaged).value / " scala-library-src"
1338
1367
val projectRoot = (ThisBuild / baseDirectory).value.toPath
1339
1368
val stdLibRoot = projectRoot.relativize(managedSources.toPath.normalize())
1340
- val docRootFile = stdLibRoot.resolve(" rootdoc.txt" )
1341
-
1342
- val dottyManagesSources =
1343
- (`stdlib-bootstrapped`/ Compile / sourceManaged).value / " dotty-library-src"
1344
-
1345
- val dottyLibRoot = projectRoot.relativize(dottyManagesSources.toPath.normalize())
1369
+ stdLibRoot.resolve(" rootdoc.txt" )
1370
+ }.value,
1346
1371
1347
- if (dottyJars.isEmpty) Def .task { streams.value.log.error(" Dotty lib wasn't found" ) }
1348
- else Def .task{
1349
- IO .write(dest / " versions" / " latest-nightly-base" , majorVersion)
1372
+ copyTheScaladocInputs := Def .inputTask {
1373
+ val extraArgs = spaceDelimited(" [output]" ).parsed
1374
+ val dest = extraArgs.lift(0 ).getOrElse(" output" )
1375
+ val ref = extraArgs.lift(1 ).getOrElse(" 0.0.0" )
1376
+ val jars = getJarsForScaladoc.value.foreach { jar =>
1377
+ val file = new File (jar)
1378
+ val d = new File (s " $dest/ $ref" + jar(0 ))
1379
+ sbt.IO .copyDirectory(file, d)
1380
+ }
1350
1381
1351
- // This file is used by GitHub Pages when the page is available in a custom domain
1352
- IO .write(dest / " CNAME" , " dotty.epfl.ch" )
1353
- }.dependsOn(generateDocumentation(
1354
- roots, " Scala 3" , dest.getAbsolutePath, " master" ,
1355
- Seq (
1356
- " -comment-syntax" , " wiki" ,
1357
- " -siteroot" , " docs" ,
1358
- s " -source-links:docs=github://lampepfl/dotty/master#docs " ,
1359
- " -doc-root-content" , docRootFile.toString,
1360
- " -Ydocument-synthetic-types"
1361
- ), usingScript = false
1362
- ))
1382
+ val path = getDocRootForScaladoc.value
1383
+ val d = new File (s " $dest/ $ref.txt " )
1384
+ sbt.IO .copyFile(path.toFile, d)
1363
1385
}.evaluated,
1364
1386
1365
1387
generateTestcasesDocumentation := Def .taskDyn {
0 commit comments