Skip to content

Commit 62f202b

Browse files
authored
Merge pull request #12364 from lampepfl/scaladoc/scalajs-fix
Scaladoc: Fix problems with documenting scala.js projects
2 parents e1557e5 + bb29442 commit 62f202b

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ trait CommonScalaSettings { self: Settings.SettingGroup =>
4444
/** Other settings */
4545
val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))
4646
val usejavacp: Setting[Boolean] = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.", aliases = List("--use-java-class-path"))
47+
val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))
4748

4849
/** Plugin-related setting */
4950
val plugin: Setting[List[String]] = MultiStringSetting ("-Xplugin", "paths", "Load a plugin from each classpath.")
@@ -54,7 +55,7 @@ trait CommonScalaSettings { self: Settings.SettingGroup =>
5455
val pluginOptions: Setting[List[String]] = MultiStringSetting ("-P", "plugin:opt", "Pass an option to a plugin, e.g. -P:<plugin>:<opt>")
5556
}
5657

57-
class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
58+
trait AllScalaSettings extends CommonScalaSettings { self: Settings.SettingGroup =>
5859
// Keep synchronized with `classfileVersion` in `BCodeIdiomatic`
5960
private val minTargetVersion = 8
6061
private val maxTargetVersion = 17
@@ -80,7 +81,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
8081
val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature"))
8182
val release: Setting[String] = ChoiceSetting("-release", "release", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version.", supportedReleaseVersions, "", aliases = List("--release"))
8283
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source"))
83-
val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))
8484
val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", aliases = List("--unchecked"))
8585
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
8686
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language"))
@@ -225,3 +225,5 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
225225

226226
val wikiSyntax: Setting[Boolean] = BooleanSetting("-Xwiki-syntax", "Retains the Scala2 behavior of using Wiki Syntax in Scaladoc.")
227227
}
228+
229+
class ScalaSettings extends Settings.SettingGroup with AllScalaSettings

scaladoc/src/dotty/tools/scaladoc/DocContext.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ extension (r: report.type)
6666
def warn(m: String, e: Throwable)(using CompilerContext): Unit =
6767
r.warning(s"$m: ${throwableToString(e)}")
6868

69+
def echo(m: String)(using CompilerContext): Unit =
70+
r.echo(m)
71+
6972
case class NavigationNode(name: String, dri: DRI, nested: Seq[NavigationNode])
7073

7174
case class DocContext(args: Scaladoc.Args, compilerContext: CompilerContext):

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import collection.immutable.ArraySeq
99
import java.nio.file.Files
1010

1111
import dotty.tools.dotc.config.Settings._
12-
import dotty.tools.dotc.config.CommonScalaSettings
12+
import dotty.tools.dotc.config.{ CommonScalaSettings, AllScalaSettings }
1313
import dotty.tools.dotc.reporting.Reporter
1414
import dotty.tools.dotc.core.Contexts._
1515

@@ -100,7 +100,15 @@ object Scaladoc:
100100
}
101101

102102
val commonScalaSettings = (new SettingGroup with CommonScalaSettings).allSettings
103-
allSettings.filter(commonScalaSettings.contains).foreach(setInGlobal)
103+
val allScalaSettings = (new SettingGroup with AllScalaSettings).allSettings
104+
105+
val (shared, other) = allSettings
106+
.filter(s => !s.isDefaultIn(summary.sstate))
107+
.filter(allScalaSettings.contains)
108+
.partition(commonScalaSettings.contains)
109+
shared.foreach(setInGlobal)
110+
111+
if !other.isEmpty then report.echo(s"Skipping unused scalacOptions: ${other.map(_.name).mkString(", ")}")
104112

105113
def parseTastyRoots(roots: String) =
106114
roots.split(File.pathSeparatorChar).toList.map(new File(_))

scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import collection.immutable.ArraySeq
99
import java.nio.file.Files
1010

1111
import dotty.tools.dotc.config.Settings._
12-
import dotty.tools.dotc.config.CommonScalaSettings
12+
import dotty.tools.dotc.config.AllScalaSettings
1313
import dotty.tools.scaladoc.Scaladoc._
1414
import dotty.tools.dotc.config.Settings.Setting.value
1515
import dotty.tools.dotc.config.Properties._
1616
import dotty.tools.dotc.config.CliCommand
1717
import dotty.tools.dotc.core.Contexts._
1818

19-
class ScaladocSettings extends SettingGroup with CommonScalaSettings:
19+
class ScaladocSettings extends SettingGroup with AllScalaSettings:
2020
val unsupportedSettings = Seq(
2121
// Options that we like to support
2222
bootclasspath, extdirs, javabootclasspath, encoding, usejavacp,

0 commit comments

Comments
 (0)