Skip to content

Commit f67a086

Browse files
BarkingBadromanowski
authored andcommitted
Fix publishing docs for scala3 libraries
1 parent cbf7daa commit f67a086

File tree

5 files changed

+100
-74
lines changed

5 files changed

+100
-74
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: 95 additions & 69 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
// Replace the JVM JUnit dependency by the Scala.js one
4242
libraryDependencies ~= {
@@ -53,6 +53,8 @@ object MyScalaJSPlugin extends AutoPlugin {
5353
excludeFromIDE := true
5454
)
5555
}
56+
object BootstrappedDottyJSPlugin extends DottyJSPlugin(Build.commonBootstrappedSettings)
57+
object NonBootstrappedDottyJSPlugin extends DottyJSPlugin(Build.commonNonBootstrappedSettings)
5658

5759
object Build {
5860
val referenceVersion = "3.0.0-RC1"
@@ -342,9 +344,7 @@ object Build {
342344
)
343345
},
344346
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
345-
scalaInstance in doc := scalaInstance.value,
346-
347-
disableDocSetting,
347+
scalaInstance in doc := scalaInstance.value
348348
)
349349

350350
lazy val commonBenchmarkSettings = Seq(
@@ -691,6 +691,16 @@ object Build {
691691
case Bootstrapped => `scala3-library-bootstrapped`
692692
}
693693

694+
lazy val `scala3-library-js`: Project = project.in(file("library-js")).
695+
asDottyLibrary(NonBootstrapped).
696+
enablePlugins(NonBootstrappedDottyJSPlugin).
697+
settings(
698+
libraryDependencies +=
699+
("org.scala-js" %% "scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
700+
unmanagedSourceDirectories in Compile :=
701+
(unmanagedSourceDirectories in (`scala3-library`, Compile)).value
702+
)
703+
694704
/** The dotty standard library compiled with the Scala.js back-end, to produce
695705
* the corresponding .sjsir files.
696706
*
@@ -702,7 +712,7 @@ object Build {
702712
*/
703713
lazy val `scala3-library-bootstrappedJS`: Project = project.in(file("library-js")).
704714
asDottyLibrary(Bootstrapped).
705-
enablePlugins(MyScalaJSPlugin).
715+
enablePlugins(BootstrappedDottyJSPlugin).
706716
settings(
707717
libraryDependencies +=
708718
("org.scala-js" %% "scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
@@ -982,7 +992,7 @@ object Build {
982992
* useful, as that would not provide the linker and JS runners.
983993
*/
984994
lazy val sjsSandbox = project.in(file("sandbox/scalajs")).
985-
enablePlugins(MyScalaJSPlugin).
995+
enablePlugins(BootstrappedDottyJSPlugin).
986996
dependsOn(`scala3-library-bootstrappedJS`).
987997
settings(
988998
// Required to run Scala.js tests.
@@ -999,7 +1009,7 @@ object Build {
9991009
* It will grow in the future, as more stuff is confirmed to be supported.
10001010
*/
10011011
lazy val sjsJUnitTests = project.in(file("tests/sjs-junit")).
1002-
enablePlugins(MyScalaJSPlugin).
1012+
enablePlugins(BootstrappedDottyJSPlugin).
10031013
dependsOn(`scala3-library-bootstrappedJS`).
10041014
settings(
10051015
scalacOptions --= Seq("-Xfatal-warnings", "-deprecation"),
@@ -1057,7 +1067,7 @@ object Build {
10571067
(sourceManaged in Compile).value,
10581068
"org.scalajs.testsuite.utils.BuildInfo",
10591069
"scalaVersion" -> scalaVersion.value,
1060-
"hasSourceMaps" -> false, //MyScalaJSPlugin.wantSourceMaps.value,
1070+
"hasSourceMaps" -> false, //BootstrappedDottyJSPlugin.wantSourceMaps.value,
10611071
"isNoModule" -> (moduleKind == ModuleKind.NoModule),
10621072
"isESModule" -> (moduleKind == ModuleKind.ESModule),
10631073
"isCommonJSModule" -> (moduleKind == ModuleKind.CommonJSModule),
@@ -1177,9 +1187,21 @@ object Build {
11771187
case Bootstrapped => scaladoc
11781188
}
11791189

1180-
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).asScaladocTestcases
1190+
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).asScaladocTestcases(Bootstrapped)
1191+
lazy val `scaladoc-testcases-nonBootstrapped` = project.in(file("scaladoc-testcases")).asScaladocTestcases(NonBootstrapped)
11811192

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

11841206
// sbt plugin to use Dotty in your own build, see
11851207
// https://github.com/lampepfl/scala3-example-project for usage.
@@ -1514,42 +1536,53 @@ object Build {
15141536
settings(commonBenchmarkSettings).
15151537
enablePlugins(JmhPlugin)
15161538

1517-
def scaladocBasic(mode: Mode): Project = {
1539+
def scaladocBasic(implicit mode: Mode): Project = {
15181540
val flexmarkVersion = "0.42.12"
15191541

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

15551588
def asScaladoc: Project = {
@@ -1658,36 +1691,29 @@ object Build {
16581691
Build.testcasesSourceRoot.in(Test),
16591692
Build.testDocumentationRoot,
16601693
),
1661-
Compile / resourceGenerators += Def.task {
1662-
val jsDestinationFile = (Compile / resourceManaged).value / "dotty_res" / "scripts" / "searchbar.js"
1663-
sbt.IO.copyFile((fullOptJS in Compile in `scaladoc-js`).value.data, jsDestinationFile)
1664-
Seq(jsDestinationFile)
1665-
}.taskValue,
1666-
Compile / resourceGenerators += Def.task {
1667-
val cssDesitnationFile = (Compile / resourceManaged).value / "dotty_res" / "styles" / "scaladoc-searchbar.css"
1668-
val cssSourceFile = (resourceDirectory in Compile in `scaladoc-js`).value / "scaladoc-searchbar.css"
1669-
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
1670-
Seq(cssDesitnationFile)
1671-
}.taskValue,
16721694
testDocumentationRoot := (baseDirectory.value / "test-documentations").getAbsolutePath,
16731695
buildInfoPackage in Test := "dotty.tools.scaladoc.test",
16741696
BuildInfoPlugin.buildInfoScopedSettings(Test),
16751697
)
16761698
}
16771699

1678-
def asScaladocTestcases: Project =
1679-
project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1680-
1681-
def asScaladocJs: Project =
1682-
project.
1683-
enablePlugins(MyScalaJSPlugin).
1684-
dependsOn(`scala3-library-bootstrappedJS`).
1685-
settings(
1686-
fork in Test := false,
1687-
scalaJSUseMainModuleInitializer := true,
1688-
libraryDependencies += ("org.scala-js" %%% "scalajs-dom" % "1.1.0").withDottyCompat(scalaVersion.value)
1689-
)
1690-
1700+
def asScaladocTestcases(implicit mode: Mode): Project =
1701+
if (mode == Bootstrapped)
1702+
project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1703+
else
1704+
project.dependsOn(`scala3-compiler`).settings(commonNonBootstrappedSettings)
1705+
1706+
def asScaladocJs(implicit mode: Mode): Project = {
1707+
val pr = if (mode == Bootstrapped)
1708+
project.enablePlugins(BootstrappedDottyJSPlugin).dependsOn(`scala3-library-bootstrappedJS`)
1709+
else
1710+
project.enablePlugins(NonBootstrappedDottyJSPlugin).dependsOn(`scala3-library-js`)
1711+
pr.settings(
1712+
fork in Test := false,
1713+
scalaJSUseMainModuleInitializer := true,
1714+
libraryDependencies += ("org.scala-js" %%% "scalajs-dom" % "1.1.0").withDottyCompat(scalaVersion.value)
1715+
)
1716+
}
16911717

16921718
def asDist(implicit mode: Mode): Project = project.
16931719
enablePlugins(PackPlugin).

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ object DottyPlugin extends AutoPlugin {
463463
Def.task { tastyFiles.value }
464464
else Def.task { originalSources }
465465
}.value,
466-
scalacOptions ++= {
466+
scalacOptions := {
467467
if (isDotty.value) {
468468
val projectName =
469469
if (configuration.value == Compile)

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

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

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

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

0 commit comments

Comments
 (0)