Skip to content

Commit

Permalink
Merge pull request scala#12364 from lampepfl/scaladoc/scalajs-fix
Browse files Browse the repository at this point in the history
Scaladoc: Fix problems with documenting scala.js projects
  • Loading branch information
pikinier20 authored May 10, 2021
2 parents e1557e5 + bb29442 commit 62f202b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ trait CommonScalaSettings { self: Settings.SettingGroup =>
/** Other settings */
val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))
val usejavacp: Setting[Boolean] = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.", aliases = List("--use-java-class-path"))
val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))

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

class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
trait AllScalaSettings extends CommonScalaSettings { self: Settings.SettingGroup =>
// Keep synchronized with `classfileVersion` in `BCodeIdiomatic`
private val minTargetVersion = 8
private val maxTargetVersion = 17
Expand All @@ -80,7 +81,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature"))
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"))
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source"))
val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))
val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", aliases = List("--unchecked"))
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language"))
Expand Down Expand Up @@ -225,3 +225,5 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {

val wikiSyntax: Setting[Boolean] = BooleanSetting("-Xwiki-syntax", "Retains the Scala2 behavior of using Wiki Syntax in Scaladoc.")
}

class ScalaSettings extends Settings.SettingGroup with AllScalaSettings
3 changes: 3 additions & 0 deletions scaladoc/src/dotty/tools/scaladoc/DocContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ extension (r: report.type)
def warn(m: String, e: Throwable)(using CompilerContext): Unit =
r.warning(s"$m: ${throwableToString(e)}")

def echo(m: String)(using CompilerContext): Unit =
r.echo(m)

case class NavigationNode(name: String, dri: DRI, nested: Seq[NavigationNode])

case class DocContext(args: Scaladoc.Args, compilerContext: CompilerContext):
Expand Down
12 changes: 10 additions & 2 deletions scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import collection.immutable.ArraySeq
import java.nio.file.Files

import dotty.tools.dotc.config.Settings._
import dotty.tools.dotc.config.CommonScalaSettings
import dotty.tools.dotc.config.{ CommonScalaSettings, AllScalaSettings }
import dotty.tools.dotc.reporting.Reporter
import dotty.tools.dotc.core.Contexts._

Expand Down Expand Up @@ -100,7 +100,15 @@ object Scaladoc:
}

val commonScalaSettings = (new SettingGroup with CommonScalaSettings).allSettings
allSettings.filter(commonScalaSettings.contains).foreach(setInGlobal)
val allScalaSettings = (new SettingGroup with AllScalaSettings).allSettings

val (shared, other) = allSettings
.filter(s => !s.isDefaultIn(summary.sstate))
.filter(allScalaSettings.contains)
.partition(commonScalaSettings.contains)
shared.foreach(setInGlobal)

if !other.isEmpty then report.echo(s"Skipping unused scalacOptions: ${other.map(_.name).mkString(", ")}")

def parseTastyRoots(roots: String) =
roots.split(File.pathSeparatorChar).toList.map(new File(_))
Expand Down
4 changes: 2 additions & 2 deletions scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import collection.immutable.ArraySeq
import java.nio.file.Files

import dotty.tools.dotc.config.Settings._
import dotty.tools.dotc.config.CommonScalaSettings
import dotty.tools.dotc.config.AllScalaSettings
import dotty.tools.scaladoc.Scaladoc._
import dotty.tools.dotc.config.Settings.Setting.value
import dotty.tools.dotc.config.Properties._
import dotty.tools.dotc.config.CliCommand
import dotty.tools.dotc.core.Contexts._

class ScaladocSettings extends SettingGroup with CommonScalaSettings:
class ScaladocSettings extends SettingGroup with AllScalaSettings:
val unsupportedSettings = Seq(
// Options that we like to support
bootclasspath, extdirs, javabootclasspath, encoding, usejavacp,
Expand Down

0 comments on commit 62f202b

Please sign in to comment.