Skip to content

Commit 8339efa

Browse files
BarkingBadromanowski
authored andcommitted
Fix publishing docs for scala3 libraries
1 parent 641c928 commit 8339efa

File tree

4 files changed

+98
-72
lines changed

4 files changed

+98
-72
lines changed

build.sbt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ val `scala3-interfaces` = Build.`scala3-interfaces`
44
val `scala3-compiler` = Build.`scala3-compiler`
55
val `scala3-compiler-bootstrapped` = Build.`scala3-compiler-bootstrapped`
66
val `scala3-library` = Build.`scala3-library`
7+
val `scala3-library-js` = Build.`scala3-library-js`
78
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
89
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`
910
val `scala3-sbt-bridge` = Build.`scala3-sbt-bridge`
@@ -22,7 +23,9 @@ val `tasty-core-scala2` = Build.`tasty-core-scala2`
2223
val scaladoc = Build.scaladoc
2324
val `scaladoc-nonBootstrapped` = Build.`scaladoc-nonBootstrapped`
2425
val `scaladoc-testcases` = Build.`scaladoc-testcases`
26+
val `scaladoc-testcases-nonBootstrapped` = Build.`scaladoc-testcases-nonBootstrapped`
2527
val `scaladoc-js` = Build.`scaladoc-js`
28+
val `scaladoc-js-nonBootstrapped` = Build.`scaladoc-js-nonBootstrapped`
2629
val `scala3-bench-run` = Build.`scala3-bench-run`
2730
val dist = Build.dist
2831
val `community-build` = Build.`community-build`

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ trait CommonScalaSettings { self: Settings.SettingGroup =>
4040
val help: Setting[Boolean] = BooleanSetting("-help", "Print a synopsis of standard options.", aliases = List("--help"))
4141
val pageWidth: Setting[Int] = IntSetting("-pagewidth", "Set page width", defaultPageWidth, aliases = List("--page-width"))
4242
val silentWarnings: Setting[Boolean] = BooleanSetting("-nowarn", "Silence all warnings.", aliases = List("--no-warnings"))
43+
val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Accept only sources from tasty files. The arguments are .tasty or .jar files.", aliases = List("--from-tasty"))
4344

4445
/** Other settings */
4546
val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))
@@ -115,7 +116,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
115116
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
116117
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language"))
117118
val rewrite: Setting[Option[Rewrites]] = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with a `...-migration` source version, rewrites sources to migrate to new version.", aliases = List("--rewrite"))
118-
val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Compile classes from tasty files. The arguments are .tasty or .jar files.", aliases = List("--from-tasty"))
119119

120120
val newSyntax: Setting[Boolean] = BooleanSetting("-new-syntax", "Require `then` and `do` in control expressions.")
121121
val oldSyntax: Setting[Boolean] = BooleanSetting("-old-syntax", "Require `(...)` around conditions.")

project/Build.scala

Lines changed: 94 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ import scala.util.Properties.isJavaAtLeast
3030

3131
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
3232

33-
object MyScalaJSPlugin extends AutoPlugin {
33+
abstract class DottyJSPlugin(settings: Seq[Setting[_]]) extends AutoPlugin {
3434
import Build._
3535

3636
override def requires: Plugins = ScalaJSPlugin
3737

3838
override def projectSettings: Seq[Setting[_]] = Def.settings(
39-
commonBootstrappedSettings,
39+
settings,
4040

4141
/* #11709 Remove the dependency on scala3-library that ScalaJSPlugin adds.
4242
* Instead, in this build, we use `.dependsOn` relationships to depend on
@@ -61,6 +61,8 @@ object MyScalaJSPlugin extends AutoPlugin {
6161
excludeFromIDE := true
6262
)
6363
}
64+
object BootstrappedDottyJSPlugin extends DottyJSPlugin(Build.commonBootstrappedSettings)
65+
object NonBootstrappedDottyJSPlugin extends DottyJSPlugin(Build.commonNonBootstrappedSettings)
6466

6567
object Build {
6668
val referenceVersion = "3.0.0-RC2-bin-20210318-e60ef35-NIGHTLY"
@@ -350,8 +352,6 @@ object Build {
350352
},
351353
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
352354
doc / scalaInstance := scalaInstance.value,
353-
354-
disableDocSetting,
355355
)
356356

357357
lazy val commonBenchmarkSettings = Seq(
@@ -689,6 +689,16 @@ object Build {
689689
case Bootstrapped => `scala3-library-bootstrapped`
690690
}
691691

692+
lazy val `scala3-library-js`: Project = project.in(file("library-js")).
693+
asDottyLibrary(NonBootstrapped).
694+
enablePlugins(NonBootstrappedDottyJSPlugin).
695+
settings(
696+
libraryDependencies +=
697+
("org.scala-js" %% "scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
698+
unmanagedSourceDirectories in Compile :=
699+
(unmanagedSourceDirectories in (`scala3-library`, Compile)).value
700+
)
701+
692702
/** The dotty standard library compiled with the Scala.js back-end, to produce
693703
* the corresponding .sjsir files.
694704
*
@@ -700,7 +710,7 @@ object Build {
700710
*/
701711
lazy val `scala3-library-bootstrappedJS`: Project = project.in(file("library-js")).
702712
asDottyLibrary(Bootstrapped).
703-
enablePlugins(MyScalaJSPlugin).
713+
enablePlugins(BootstrappedDottyJSPlugin).
704714
settings(
705715
libraryDependencies +=
706716
("org.scala-js" %% "scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
@@ -981,7 +991,7 @@ object Build {
981991
* useful, as that would not provide the linker and JS runners.
982992
*/
983993
lazy val sjsSandbox = project.in(file("sandbox/scalajs")).
984-
enablePlugins(MyScalaJSPlugin).
994+
enablePlugins(BootstrappedDottyJSPlugin).
985995
dependsOn(`scala3-library-bootstrappedJS`).
986996
settings(
987997
// Required to run Scala.js tests.
@@ -998,7 +1008,7 @@ object Build {
9981008
* It will grow in the future, as more stuff is confirmed to be supported.
9991009
*/
10001010
lazy val sjsJUnitTests = project.in(file("tests/sjs-junit")).
1001-
enablePlugins(MyScalaJSPlugin).
1011+
enablePlugins(BootstrappedDottyJSPlugin).
10021012
dependsOn(`scala3-library-bootstrappedJS`).
10031013
settings(
10041014
scalacOptions --= Seq("-Xfatal-warnings", "-deprecation"),
@@ -1056,7 +1066,7 @@ object Build {
10561066
(Compile / sourceManaged).value,
10571067
"org.scalajs.testsuite.utils.BuildInfo",
10581068
"scalaVersion" -> scalaVersion.value,
1059-
"hasSourceMaps" -> false, //MyScalaJSPlugin.wantSourceMaps.value,
1069+
"hasSourceMaps" -> false, //BootstrappedDottyJSPlugin.wantSourceMaps.value,
10601070
"isNoModule" -> (moduleKind == ModuleKind.NoModule),
10611071
"isESModule" -> (moduleKind == ModuleKind.ESModule),
10621072
"isCommonJSModule" -> (moduleKind == ModuleKind.CommonJSModule),
@@ -1180,9 +1190,21 @@ object Build {
11801190
case Bootstrapped => scaladoc
11811191
}
11821192

1183-
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).asScaladocTestcases
1193+
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).asScaladocTestcases(Bootstrapped)
1194+
lazy val `scaladoc-testcases-nonBootstrapped` = project.in(file("scaladoc-testcases")).asScaladocTestcases(NonBootstrapped)
1195+
1196+
def scalaDocTestcases(implicit mode: Mode): Project = mode match {
1197+
case NonBootstrapped => `scaladoc-testcases-nonBootstrapped`
1198+
case Bootstrapped => `scaladoc-testcases`
1199+
}
1200+
1201+
lazy val `scaladoc-js` = project.in(file("scaladoc-js")).asScaladocJs(Bootstrapped)
1202+
lazy val `scaladoc-js-nonBootstrapped` = project.in(file("scaladoc-js")).asScaladocJs(NonBootstrapped)
11841203

1185-
lazy val `scaladoc-js` = project.in(file("scaladoc-js")).asScaladocJs
1204+
def scalaDocJs(implicit mode: Mode): Project = mode match {
1205+
case NonBootstrapped => `scaladoc-js-nonBootstrapped`
1206+
case Bootstrapped => `scaladoc-js`
1207+
}
11861208

11871209
// sbt plugin to use Dotty in your own build, see
11881210
// https://github.com/lampepfl/scala3-example-project for usage.
@@ -1517,42 +1539,53 @@ object Build {
15171539
settings(commonBenchmarkSettings).
15181540
enablePlugins(JmhPlugin)
15191541

1520-
def scaladocBasic(mode: Mode): Project = {
1542+
def scaladocBasic(implicit mode: Mode): Project = {
15211543
val flexmarkVersion = "0.42.12"
15221544

1523-
val base = if(mode == Bootstrapped)
1524-
project.settings(commonBootstrappedSettings).
1525-
dependsOn(`scala3-compiler-bootstrapped`).
1526-
dependsOn(`scala3-tasty-inspector`)
1527-
else
1528-
project.settings(commonNonBootstrappedSettings).
1529-
dependsOn(`scala3-compiler`).
1530-
dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1531-
1532-
base.settings(
1533-
libraryDependencies ++= Seq(
1534-
"com.vladsch.flexmark" % "flexmark" % flexmarkVersion,
1535-
"com.vladsch.flexmark" % "flexmark-html-parser" % flexmarkVersion,
1536-
"com.vladsch.flexmark" % "flexmark-ext-anchorlink" % flexmarkVersion,
1537-
"com.vladsch.flexmark" % "flexmark-ext-autolink" % flexmarkVersion,
1538-
"com.vladsch.flexmark" % "flexmark-ext-emoji" % flexmarkVersion,
1539-
"com.vladsch.flexmark" % "flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1540-
"com.vladsch.flexmark" % "flexmark-ext-gfm-tables" % flexmarkVersion,
1541-
"com.vladsch.flexmark" % "flexmark-ext-gfm-tasklist" % flexmarkVersion,
1542-
"com.vladsch.flexmark" % "flexmark-ext-wikilink" % flexmarkVersion,
1543-
"com.vladsch.flexmark" % "flexmark-ext-yaml-front-matter" % flexmarkVersion,
1544-
"nl.big-o" % "liqp" % "0.6.7",
1545-
"org.jsoup" % "jsoup" % "1.13.1", // Needed to process .html files for static site
1546-
Dependencies.`jackson-dataformat-yaml`,
1547-
1548-
"com.novocode" % "junit-interface" % "0.11" % "test",
1549-
),
1550-
Compile / mainClass := Some("dotty.tools.scaladoc.Main"),
1551-
Compile / buildInfoKeys := Seq[BuildInfoKey](version),
1552-
Compile / buildInfoPackage := "dotty.tools.scaladoc",
1553-
BuildInfoPlugin.buildInfoScopedSettings(Compile),
1554-
BuildInfoPlugin.buildInfoDefaultSettings,
1555-
)
1545+
val base = if (mode == Bootstrapped)
1546+
project.settings(commonBootstrappedSettings)
1547+
.dependsOn(`scala3-compiler-bootstrapped`)
1548+
.dependsOn(`scala3-tasty-inspector`)
1549+
else
1550+
project.settings(commonNonBootstrappedSettings)
1551+
.dependsOn(`scala3-compiler`)
1552+
.dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1553+
1554+
base.settings(
1555+
Compile / resourceGenerators += Def.task {
1556+
val jsDestinationFile = (Compile / resourceManaged).value / "dotty_res" / "scripts" / "searchbar.js"
1557+
sbt.IO.copyFile((scalaDocJs / Compile / fullOptJS).value.data, jsDestinationFile)
1558+
Seq(jsDestinationFile)
1559+
}.taskValue,
1560+
Compile / resourceGenerators += Def.task {
1561+
val cssDesitnationFile = (Compile / resourceManaged).value / "dotty_res" / "styles" / "scaladoc-searchbar.css"
1562+
val cssSourceFile = (scalaDocJs / Compile / resourceDirectory).value / "scaladoc-searchbar.css"
1563+
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
1564+
Seq(cssDesitnationFile)
1565+
}.taskValue,
1566+
libraryDependencies ++= Seq(
1567+
"com.vladsch.flexmark" % "flexmark" % flexmarkVersion,
1568+
"com.vladsch.flexmark" % "flexmark-html-parser" % flexmarkVersion,
1569+
"com.vladsch.flexmark" % "flexmark-ext-anchorlink" % flexmarkVersion,
1570+
"com.vladsch.flexmark" % "flexmark-ext-autolink" % flexmarkVersion,
1571+
"com.vladsch.flexmark" % "flexmark-ext-emoji" % flexmarkVersion,
1572+
"com.vladsch.flexmark" % "flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1573+
"com.vladsch.flexmark" % "flexmark-ext-gfm-tables" % flexmarkVersion,
1574+
"com.vladsch.flexmark" % "flexmark-ext-gfm-tasklist" % flexmarkVersion,
1575+
"com.vladsch.flexmark" % "flexmark-ext-wikilink" % flexmarkVersion,
1576+
"com.vladsch.flexmark" % "flexmark-ext-yaml-front-matter" % flexmarkVersion,
1577+
"nl.big-o" % "liqp" % "0.6.7",
1578+
"org.jsoup" % "jsoup" % "1.13.1", // Needed to process .html files for static site
1579+
Dependencies.`jackson-dataformat-yaml`,
1580+
1581+
"com.novocode" % "junit-interface" % "0.11" % "test",
1582+
),
1583+
Compile / mainClass := Some("dotty.tools.scaladoc.Main"),
1584+
Compile / buildInfoKeys := Seq[BuildInfoKey](version),
1585+
Compile / buildInfoPackage := "dotty.tools.scaladoc",
1586+
BuildInfoPlugin.buildInfoScopedSettings(Compile),
1587+
BuildInfoPlugin.buildInfoDefaultSettings,
1588+
)
15561589
}
15571590

15581591
def asScaladoc: Project = {
@@ -1668,36 +1701,29 @@ object Build {
16681701
(Test / Build.testcasesSourceRoot),
16691702
Build.testDocumentationRoot,
16701703
),
1671-
Compile / resourceGenerators += Def.task {
1672-
val jsDestinationFile = (Compile / resourceManaged).value / "dotty_res" / "scripts" / "searchbar.js"
1673-
sbt.IO.copyFile((`scaladoc-js` / Compile / fullOptJS).value.data, jsDestinationFile)
1674-
Seq(jsDestinationFile)
1675-
}.taskValue,
1676-
Compile / resourceGenerators += Def.task {
1677-
val cssDesitnationFile = (Compile / resourceManaged).value / "dotty_res" / "styles" / "scaladoc-searchbar.css"
1678-
val cssSourceFile = (`scaladoc-js` / Compile / resourceDirectory).value / "scaladoc-searchbar.css"
1679-
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
1680-
Seq(cssDesitnationFile)
1681-
}.taskValue,
16821704
testDocumentationRoot := (baseDirectory.value / "test-documentations").getAbsolutePath,
16831705
Test / buildInfoPackage := "dotty.tools.scaladoc.test",
16841706
BuildInfoPlugin.buildInfoScopedSettings(Test),
16851707
)
16861708
}
16871709

1688-
def asScaladocTestcases: Project =
1689-
project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1690-
1691-
def asScaladocJs: Project =
1692-
project.
1693-
enablePlugins(MyScalaJSPlugin).
1694-
dependsOn(`scala3-library-bootstrappedJS`).
1695-
settings(
1696-
Test / fork := false,
1697-
scalaJSUseMainModuleInitializer := true,
1698-
libraryDependencies += ("org.scala-js" %%% "scalajs-dom" % "1.1.0").withDottyCompat(scalaVersion.value)
1699-
)
1700-
1710+
def asScaladocTestcases(implicit mode: Mode): Project =
1711+
if (mode == Bootstrapped)
1712+
project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1713+
else
1714+
project.dependsOn(`scala3-compiler`).settings(commonNonBootstrappedSettings)
1715+
1716+
def asScaladocJs(implicit mode: Mode): Project = {
1717+
val pr = if (mode == Bootstrapped)
1718+
project.enablePlugins(BootstrappedDottyJSPlugin).dependsOn(`scala3-library-bootstrappedJS`)
1719+
else
1720+
project.enablePlugins(NonBootstrappedDottyJSPlugin).dependsOn(`scala3-library-js`)
1721+
pr.settings(
1722+
Test / fork := false,
1723+
scalaJSUseMainModuleInitializer := true,
1724+
libraryDependencies += ("org.scala-js" %%% "scalajs-dom" % "1.1.0").withDottyCompat(scalaVersion.value)
1725+
)
1726+
}
17011727

17021728
def asDist(implicit mode: Mode): Project = project.
17031729
enablePlugins(PackPlugin).

scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ object Scaladoc:
9696

9797
allSettings.filterNot(scaladocSpecificSettings.contains).foreach(setInGlobal)
9898

99-
summary.warnings.foreach(report.warning(_))
100-
summary.errors.foreach(report.error(_))
101-
10299
def parseTastyRoots(roots: String) =
103100
roots.split(File.pathSeparatorChar).toList.map(new File(_))
104101

0 commit comments

Comments
 (0)