Skip to content

Commit 7ebfadd

Browse files
BarkingBadromanowski
authored andcommitted
Refactor scalacOptions of doc tasks
1 parent f67a086 commit 7ebfadd

File tree

4 files changed

+27
-59
lines changed

4 files changed

+27
-59
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ 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"))
4443

4544
/** Other settings */
4645
val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))
@@ -116,6 +115,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
116115
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
117116
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language"))
118117
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: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,25 @@ object Build {
343343
appConfiguration.value
344344
)
345345
},
346+
Compile / doc / scalacOptions ++= Seq(
347+
"-external-mappings:" +
348+
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
349+
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
350+
"-skip-by-regex:.+\\.internal($|\\..+)",
351+
"-skip-by-regex:.+\\.impl($|\\..+)",
352+
"-project-logo", "docs/logo.svg",
353+
"-social-links:" +
354+
"github::https://github.com/lampepfl/dotty," +
355+
"gitter::https://gitter.im/scala/scala," +
356+
"twitter::https://twitter.com/scala_lang",
357+
// contains special definitions which are "transplanted" elsewhere
358+
// and which therefore confuse Scaladoc when accessed from this pkg
359+
"-skip-by-id:scala.runtime.stdLibPatches",
360+
// MatchCase is a special type that represents match type cases,
361+
// Reflect doesn't expect to see it as a standalone definition
362+
// and therefore it's easier just not to document it
363+
"-skip-by-id:scala.runtime.MatchCase",
364+
),
346365
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
347366
scalaInstance in doc := scalaInstance.value
348367
)
@@ -754,7 +773,6 @@ object Build {
754773
// when compiling a project that depends on scala3-staging (see sbt-dotty/sbt-test/sbt-dotty/quoted-example-project),
755774
// but we always need it to be present on the JVM classpath at runtime.
756775
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
757-
settings(commonBootstrappedSettings).
758776
settings(
759777
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value
760778
)
@@ -765,7 +783,6 @@ object Build {
765783
// when compiling a project that depends on scala3-tasty-inspector (see sbt-dotty/sbt-test/sbt-dotty/tasty-inspector-example-project),
766784
// but we always need it to be present on the JVM classpath at runtime.
767785
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
768-
settings(commonBootstrappedSettings).
769786
settings(
770787
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value
771788
)
@@ -1615,14 +1632,6 @@ object Build {
16151632
generateDocumentation(
16161633
classDirectory.in(Compile).value.getAbsolutePath :: Nil,
16171634
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash,
1618-
Seq(
1619-
"-siteroot", "scaladoc/documentation",
1620-
"-project-logo", "scaladoc/documentation/logo.svg",
1621-
"-external-mappings:" +
1622-
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
1623-
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/"
1624-
)
1625-
16261635
)
16271636
}.value,
16281637
generateScalaDocumentation := Def.inputTaskDyn {
@@ -1653,26 +1662,9 @@ object Build {
16531662
}.dependsOn(generateDocumentation(
16541663
roots, "Scala 3", dest.getAbsolutePath, "master",
16551664
Seq(
1656-
// contains special definitions which are "transplanted" elsewhere
1657-
// and which therefore confuse Scaladoc when accessed from this pkg
1658-
"-skip-by-id:scala.runtime.stdLibPatches",
1659-
// MatchCase is a special type that represents match type cases,
1660-
// Reflect doesn't expect to see it as a standalone definition
1661-
// and therefore it's easier just not to document it
1662-
"-skip-by-id:scala.runtime.MatchCase",
1663-
"-skip-by-regex:.+\\.internal($|\\..+)",
1664-
"-skip-by-regex:.+\\.impl($|\\..+)",
16651665
"-comment-syntax", "wiki",
16661666
"-siteroot", "docs",
1667-
"-project-logo", "docs/logo.svg",
1668-
"-external-mappings:.*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
1669-
"-social-links:" +
1670-
"github::https://github.com/lampepfl/dotty," +
1671-
"gitter::https://gitter.im/scala/scala," +
1672-
"twitter::https://twitter.com/scala_lang",
1673-
s"-source-links:" +
1674-
s"$stdLibRoot=github://scala/scala/v${stdlibVersion(Bootstrapped)}#src/library," +
1675-
s"docs=github://lampepfl/dotty/master#docs",
1667+
s"-source-links:docs=github://lampepfl/dotty/master#docs",
16761668
"-doc-root-content", docRootFile.toString
16771669
)
16781670
))

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)