Skip to content

Commit 927287d

Browse files
committed
Decouple Scala.js jses. Move contributors to be independent asset/
1 parent 3643a58 commit 927287d

35 files changed

+110
-67
lines changed

build.sbt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
2020
val `tasty-core-scala2` = Build.`tasty-core-scala2`
2121
val scaladoc = Build.scaladoc
2222
val `scaladoc-testcases` = Build.`scaladoc-testcases`
23-
val `scaladoc-js` = Build.`scaladoc-js`
23+
val `scaladoc-js-common` = Build.`scaladoc-js-common`
24+
val `scaladoc-js-main` = Build.`scaladoc-js-main`
25+
val `scaladoc-js-markdown` = Build.`scaladoc-js-markdown`
26+
val `scaladoc-js-contributors` = Build.`scaladoc-js-contributors`
2427
val `scala3-bench-run` = Build.`scala3-bench-run`
2528
val dist = Build.dist
2629
val `community-build` = Build.`community-build`

docs/_layouts/main.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
---
22
layout: base
3+
extraJS:
4+
- js/contributors.js
5+
extraCSS:
6+
- css/content-contributors.css
37
---
48
<div id="content-wrapper">
5-
{% if page.movedTo %}
6-
<aside class="warning">
7-
The content of this page is outdated. Click <a href="{{ page.movedTo }}">here</a> to find the up to date version of this page.
8-
</aside>
9-
{% endif %}
109
{{ content }}
1110
</div>
1211
<script>

docs/_layouts/static-site-main.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<nav class="navigation" role="menu">
88
<ul class="navigation-menu">
99
<li class="navigation-menu-item">
10-
<a href="/" class="active">Documentation</a>
10+
<a href="https://docs.scala-lang.org/" class="active">Documentation</a>
1111
</li>
1212
<li class="navigation-menu-item">
1313
<a href="https://www.scala-lang.org/download/">Download</a>
@@ -28,6 +28,11 @@
2828
</nav>
2929
</div>
3030
</div>
31+
{% if page.movedTo %}
32+
<aside class="warning">
33+
The content of this page is outdated. Click <a href="{{ page.movedTo }}">here</a> to find the up to date version of this page.
34+
</aside>
35+
{% endif %}
3136
{{ content }}
3237
<nav class="arrows-wrapper" aria-label="Page navigation">
3338
{% if page.previous %}

project/Build.scala

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dotty.tools.scaladoc
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js.annotation.JSGlobalScope
5+
6+
@js.native
7+
@JSGlobalScope
8+
object Globals extends js.Object {
9+
val githubContributorsUrl: String = js.native
10+
}
11+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package dotty.tools.scaladoc
2+
import scala.scalajs.js.annotation._
3+
4+
object Main extends App:
5+
ContentContributors()
File renamed without changes.

scaladoc-js/src/Globals.scala renamed to scaladoc-js/main/src/Globals.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import scala.scalajs.js.annotation.JSGlobalScope
88
object Globals extends js.Object {
99
val pathToRoot: String = js.native
1010
val versionsDictionaryUrl: String = js.native
11-
val githubContributorsUrl: String = js.native
1211
}
1312

1413
object StringUtils {

scaladoc-js/main/src/Main.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package dotty.tools.scaladoc
2+
import scala.scalajs.js.annotation._
3+
4+
object Main extends App:
5+
Searchbar()
6+
SocialLinks()
7+
DropdownHandler()
8+
Ux()
9+
TooltipNormalizer()
10+
CodeSnippets()
File renamed without changes.

scaladoc-js/markdown/src/Main.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package dotty.tools.scaladoc
2+
import scala.scalajs.js.annotation._
3+
4+
object Main extends App:
5+
CodeSnippets()

scaladoc-js/src/Main.scala

Lines changed: 0 additions & 24 deletions
This file was deleted.

scaladoc/src/dotty/tools/scaladoc/renderers/Resources.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
9090
"styles/filter-bar.css",
9191
"styles/code-snippets.css",
9292
"styles/searchbar.css",
93-
"styles/content-contributors.css",
9493
"styles/social-links.css",
9594
"styles/ux.css",
9695
"styles/versions-dropdown.css",

0 commit comments

Comments
 (0)