Skip to content

Commit 302c450

Browse files
committed
Refactor scalacOptions of doc tasks
1 parent 66a730f commit 302c450

File tree

4 files changed

+28
-58
lines changed

4 files changed

+28
-58
lines changed

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

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

3332
/** Other settings */
3433
val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))
@@ -102,6 +101,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
102101
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
103102
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language"))
104103
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"))
104+
val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Compile classes from tasty files. The arguments are .tasty or .jar files.", aliases = List("--from-tasty"))
105105

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

project/Build.scala

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,25 @@ object Build {
342342
appConfiguration.value
343343
)
344344
},
345+
Compile / doc / scalacOptions ++= Seq(
346+
"-external-mappings:" +
347+
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
348+
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
349+
"-skip-by-regex:.+\\.internal($|\\..+)",
350+
"-skip-by-regex:.+\\.impl($|\\..+)",
351+
"-project-logo", "docs/logo.svg",
352+
"-social-links:" +
353+
"github::https://github.com/lampepfl/dotty," +
354+
"gitter::https://gitter.im/scala/scala," +
355+
"twitter::https://twitter.com/scala_lang",
356+
// contains special definitions which are "transplanted" elsewhere
357+
// and which therefore confuse Scaladoc when accessed from this pkg
358+
"-skip-by-id:scala.runtime.stdLibPatches",
359+
// MatchCase is a special type that represents match type cases,
360+
// Reflect doesn't expect to see it as a standalone definition
361+
// and therefore it's easier just not to document it
362+
"-skip-by-id:scala.runtime.MatchCase",
363+
),
345364
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
346365
scalaInstance in doc := scalaInstance.value
347366
)
@@ -751,7 +770,6 @@ object Build {
751770
// when compiling a project that depends on scala3-staging (see sbt-dotty/sbt-test/sbt-dotty/quoted-example-project),
752771
// but we always need it to be present on the JVM classpath at runtime.
753772
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
754-
settings(commonBootstrappedSettings).
755773
settings(
756774
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value
757775
)
@@ -762,7 +780,6 @@ object Build {
762780
// when compiling a project that depends on scala3-tasty-inspector (see sbt-dotty/sbt-test/sbt-dotty/tasty-inspector-example-project),
763781
// but we always need it to be present on the JVM classpath at runtime.
764782
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
765-
settings(commonBootstrappedSettings).
766783
settings(
767784
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value
768785
)
@@ -1611,14 +1628,6 @@ object Build {
16111628
generateDocumentation(
16121629
classDirectory.in(Compile).value.getAbsolutePath :: Nil,
16131630
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash,
1614-
Seq(
1615-
"-siteroot", "scaladoc/documentation",
1616-
"-project-logo", "scaladoc/documentation/logo.svg",
1617-
"-external-mappings:" +
1618-
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
1619-
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/"
1620-
)
1621-
16221631
)
16231632
}.value,
16241633
generateScalaDocumentation := Def.inputTaskDyn {
@@ -1649,25 +1658,10 @@ object Build {
16491658
}.dependsOn(generateDocumentation(
16501659
roots, "Scala 3", dest.getAbsolutePath, "master",
16511660
Seq(
1652-
// contains special definitions which are "transplanted" elsewhere
1653-
// and which therefore confuse Scaladoc when accessed from this pkg
1654-
"-skip-by-id:scala.runtime.stdLibPatches",
1655-
// MatchCase is a special type that represents match type cases,
1656-
// Reflect doesn't expect to see it as a standalone definition
1657-
// and therefore it's easier just not to document it
1658-
"-skip-by-id:scala.runtime.MatchCase",
1659-
"-skip-by-regex:.+\\.internal($|\\..+)",
1660-
"-skip-by-regex:.+\\.impl($|\\..+)",
16611661
"-comment-syntax", "wiki",
16621662
"-siteroot", "docs",
1663-
"-project-logo", "docs/logo.svg",
1664-
"-external-mappings:.*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
1665-
"-social-links:" +
1666-
"github::https://github.com/lampepfl/dotty," +
1667-
"gitter::https://gitter.im/scala/scala," +
1668-
"twitter::https://twitter.com/scala_lang",
1669-
s"-source-links:$stdLibRoot=github://scala/scala/v${stdlibVersion(Bootstrapped)}#src/library",
1670-
"-doc-root-content", docRootFile.toString
1663+
"-doc-root-content", docRootFile.toString,
1664+
s"-source-links:$stdLibRoot=github://scala/scala/v${stdlibVersion(Bootstrapped)}#src/library"
16711665
)
16721666
))
16731667
}.evaluated,

sbt-bridge/src/xsbt/DottydocRunner.java

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,14 @@ public void run() {
4343
return msg.toString();
4444
});
4545

46-
// When running with `-from-tasty`, remove the source files from arg list.
4746
String[] args;
48-
boolean fromTasty = false;
47+
48+
ArrayList<String> retained = new ArrayList<>(args0.length);
4949
for (String arg : args0) {
50-
if ("-from-tasty".equals(arg)) {
51-
fromTasty = true;
52-
break;
53-
}
54-
}
55-
if (fromTasty) {
56-
ArrayList<String> excluded = new ArrayList<>(args0.length);
57-
ArrayList<String> retained = new ArrayList<>(args0.length);
58-
for (String arg : args0) {
59-
if ((arg.endsWith(".scala") || arg.endsWith(".java")) && Files.exists(Paths.get(arg)))
60-
excluded.add(arg);
61-
else
62-
retained.add(arg);
63-
}
64-
log.debug(() -> {
65-
StringBuilder msg =
66-
new StringBuilder("Running `-from-tasty`, excluding source files:");
67-
for (String arg : excluded) {
68-
msg.append("\n\t");
69-
msg.append(arg);
70-
}
71-
return msg.toString();
72-
});
73-
args = retained.toArray(new String[retained.size()]);
74-
} else {
75-
args = args0;
50+
if (!((arg.endsWith(".scala") || arg.endsWith(".java")) && Files.exists(Paths.get(arg))))
51+
retained.add(arg);
7652
}
53+
args = retained.toArray(new String[retained.size()]);
7754

7855
Context ctx = new ContextBase().initialCtx().fresh()
7956
.setReporter(new DelegatingReporter(delegate));

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ object DottyPlugin extends AutoPlugin {
471471
else
472472
s"${name.value}-${configuration.value}"
473473
Seq(
474-
"-project", projectName,
475-
"-from-tasty"
474+
"-project", projectName
476475
)
477476
}
478477
else

0 commit comments

Comments
 (0)