@@ -1254,16 +1254,31 @@ object Build {
12541254 lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).
12551255 dependsOn(`scala3-compiler-bootstrapped`).
12561256 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" )).
12581259 enablePlugins(DottyJSPlugin ).
12591260 dependsOn(`scala3-library-bootstrappedJS`).
12601261 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- }),
12651262 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 ,
12671282 libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).cross(CrossVersion .for3Use2_13)
12681283 )
12691284
@@ -1318,14 +1333,30 @@ object Build {
13181333 ).
13191334 settings(
13201335 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)
13241345 }.taskValue,
13251346 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 =>
13271358 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
13291360 sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
13301361 cssDesitnationFile
13311362 }
@@ -1341,27 +1372,27 @@ object Build {
13411372 sbt.IO .touch(inkuireDestinationFile)
13421373
13431374 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+ }
13651396 }
13661397
13671398 tryFetch(5 , Duration (60 , " s" ))
@@ -1456,10 +1487,10 @@ object Build {
14561487 case _ => throw new IllegalArgumentException (" No js destination provided" )
14571488 }
14581489 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)
14601491 csses.map { file =>
14611492 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
14631494 sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
14641495 cssDesitnationFile
14651496 }
0 commit comments