@@ -1254,16 +1254,31 @@ object Build {
1254
1254
lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).
1255
1255
dependsOn(`scala3-compiler-bootstrapped`).
1256
1256
settings(commonBootstrappedSettings)
1257
- lazy val `scaladoc-js` = project.in(file(" scaladoc-js" )).
1257
+
1258
+ lazy val `scaladoc-js-common` = project.in(file(" scaladoc-js/common" )).
1258
1259
enablePlugins(DottyJSPlugin ).
1259
1260
dependsOn(`scala3-library-bootstrappedJS`).
1260
1261
settings(
1261
- Compile / scalaJSMainModuleInitializer := (sys.env.get(" scaladoc.projectFormat" ) match {
1262
- case Some (" md" ) => Some (ModuleInitializer .mainMethod(" dotty.tools.scaladoc.Main" , " markdownMain" ))
1263
- case _ => Some (ModuleInitializer .mainMethod(" dotty.tools.scaladoc.Main" , " main" ))
1264
- }),
1265
1262
Test / fork := false ,
1266
- Compile / scalaJSUseMainModuleInitializer := true ,
1263
+ libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).cross(CrossVersion .for3Use2_13)
1264
+ )
1265
+
1266
+ lazy val `scaladoc-js-main` = project.in(file(" scaladoc-js/main" )).
1267
+ enablePlugins(DottyJSPlugin ).
1268
+ dependsOn(`scaladoc-js-common`).
1269
+ settings(scalaJSUseMainModuleInitializer := true )
1270
+
1271
+ lazy val `scaladoc-js-markdown` = project.in(file(" scaladoc-js/markdown" )).
1272
+ enablePlugins(DottyJSPlugin ).
1273
+ dependsOn(`scaladoc-js-common`).
1274
+ settings(scalaJSUseMainModuleInitializer := true )
1275
+
1276
+ lazy val `scaladoc-js-contributors` = project.in(file(" scaladoc-js/contributors" )).
1277
+ enablePlugins(DottyJSPlugin ).
1278
+ dependsOn(`scala3-library-bootstrappedJS`).
1279
+ settings(
1280
+ Test / fork := false ,
1281
+ scalaJSUseMainModuleInitializer := true ,
1267
1282
libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).cross(CrossVersion .for3Use2_13)
1268
1283
)
1269
1284
@@ -1318,14 +1333,30 @@ object Build {
1318
1333
).
1319
1334
settings(
1320
1335
Compile / resourceGenerators += Def .task {
1321
- val jsDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " scaladoc-scalajs.js"
1322
- sbt.IO .copyFile((`scaladoc-js` / Compile / fullOptJS).value.data, jsDestinationFile)
1323
- Seq (jsDestinationFile)
1336
+ val contributorsFile = (`scaladoc-js-contributors` / Compile / fullOptJS).value.data
1337
+ val contributorsDestinationFile = Paths .get(" docs-for-dotty-page" , " js" , " contributors.js" ).toFile
1338
+ sbt.IO .copyFile(contributorsFile, contributorsDestinationFile)
1339
+
1340
+ val mainFile = (`scaladoc-js-main` / Compile / fullOptJS).value.data
1341
+ val mainDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " scaladoc-scalajs.js"
1342
+ sbt.IO .copyFile(mainFile, mainDestinationFile)
1343
+
1344
+ Seq (mainDestinationFile, contributorsDestinationFile)
1324
1345
}.taskValue,
1325
1346
Compile / resourceGenerators += Def .task {
1326
- Seq (" code-snippets.css" , " searchbar.css" , " content-contributors.css" , " social-links.css" , " ux.css" , " versions-dropdown.css" ).map { file =>
1347
+ {
1348
+ val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / " code-snippets.css"
1349
+ val cssSourceFile = (`scaladoc-js-common` / Compile / resourceDirectory).value / " code-snippets.css"
1350
+ sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1351
+ Seq (cssDesitnationFile)
1352
+ } ++ {
1353
+ val cssDesitnationFile = Paths .get(" docs-for-dotty-page" , " css" , " content-contributors.css" ).toFile
1354
+ val cssSourceFile = (`scaladoc-js-contributors` / Compile / resourceDirectory).value / " content-contributors.css"
1355
+ sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1356
+ Seq (cssDesitnationFile)
1357
+ } ++ Seq (" searchbar.css" , " social-links.css" , " ux.css" , " versions-dropdown.css" ).map { file =>
1327
1358
val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / file
1328
- val cssSourceFile = (`scaladoc-js` / Compile / resourceDirectory).value / file
1359
+ val cssSourceFile = (`scaladoc-js-main ` / Compile / resourceDirectory).value / file
1329
1360
sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1330
1361
cssDesitnationFile
1331
1362
}
@@ -1341,27 +1372,27 @@ object Build {
1341
1372
sbt.IO .touch(inkuireDestinationFile)
1342
1373
1343
1374
def tryFetch (retries : Int , timeout : Duration ): Unit = {
1344
- // val downloadProcess = (new java.net.URL(inkuireLink) #> inkuireDestinationFile).run()
1345
- // val result: Future[Int] = Future(blocking(downloadProcess.exitValue()))
1346
- // try {
1347
- // Await.result(result, timeout) match {
1348
- // case 0 =>
1349
- // case res if retries > 0 =>
1350
- // println(s"Failed to fetch inkuire.js from $inkuireLink: Error code $res. $retries retries left")
1351
- // tryFetch(retries - 1, timeout)
1352
- // case res => throw new MessageOnlyException(s"Failed to fetch inkuire.js from $inkuireLink: Error code $res")
1353
- // }
1354
- // } catch {
1355
- // case e: TimeoutException =>
1356
- // downloadProcess.destroy()
1357
- // if (retries > 0) {
1358
- // println(s"Failed to fetch inkuire.js from $inkuireLink: Download timeout. $retries retries left")
1359
- // tryFetch(retries - 1, timeout)
1360
- // }
1361
- // else {
1362
- // throw new MessageOnlyException(s"Failed to fetch inkuire.js from $inkuireLink: Download timeout")
1363
- // }
1364
- // }
1375
+ val downloadProcess = (new java.net.URL (inkuireLink) #> inkuireDestinationFile).run()
1376
+ val result : Future [Int ] = Future (blocking(downloadProcess.exitValue()))
1377
+ try {
1378
+ Await .result(result, timeout) match {
1379
+ case 0 =>
1380
+ case res if retries > 0 =>
1381
+ println(s " Failed to fetch inkuire.js from $inkuireLink: Error code $res. $retries retries left " )
1382
+ tryFetch(retries - 1 , timeout)
1383
+ case res => throw new MessageOnlyException (s " Failed to fetch inkuire.js from $inkuireLink: Error code $res" )
1384
+ }
1385
+ } catch {
1386
+ case e : TimeoutException =>
1387
+ downloadProcess.destroy()
1388
+ if (retries > 0 ) {
1389
+ println(s " Failed to fetch inkuire.js from $inkuireLink: Download timeout. $retries retries left " )
1390
+ tryFetch(retries - 1 , timeout)
1391
+ }
1392
+ else {
1393
+ throw new MessageOnlyException (s " Failed to fetch inkuire.js from $inkuireLink: Download timeout " )
1394
+ }
1395
+ }
1365
1396
}
1366
1397
1367
1398
tryFetch(5 , Duration (60 , " s" ))
@@ -1456,10 +1487,10 @@ object Build {
1456
1487
case _ => throw new IllegalArgumentException (" No js destination provided" )
1457
1488
}
1458
1489
val jsDestinationFile : File = Paths .get(destJS).toFile
1459
- sbt.IO .copyFile((`scaladoc-js` / Compile / fullOptJS).value.data, jsDestinationFile)
1490
+ sbt.IO .copyFile((`scaladoc-js-markdown ` / Compile / fullOptJS).value.data, jsDestinationFile)
1460
1491
csses.map { file =>
1461
1492
val cssDesitnationFile = Paths .get(destCSS).toFile / file
1462
- val cssSourceFile = (`scaladoc-js` / Compile / resourceDirectory).value / file
1493
+ val cssSourceFile = (`scaladoc-js-markdown ` / Compile / resourceDirectory).value / file
1463
1494
sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1464
1495
cssDesitnationFile
1465
1496
}
0 commit comments