Skip to content

Commit cb485e6

Browse files
BarkingBadromanowski
authored andcommitted
Refactor scalacOptions of doc tasks
1 parent 8339efa commit cb485e6

File tree

4 files changed

+29
-63
lines changed

4 files changed

+29
-63
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: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,25 @@ object Build {
350350
appConfiguration.value
351351
)
352352
},
353+
Compile / doc / scalacOptions ++= Seq(
354+
"-external-mappings:" +
355+
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
356+
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
357+
"-skip-by-regex:.+\\.internal($|\\..+)",
358+
"-skip-by-regex:.+\\.impl($|\\..+)",
359+
"-project-logo", "docs/logo.svg",
360+
"-social-links:" +
361+
"github::https://github.com/lampepfl/dotty," +
362+
"gitter::https://gitter.im/scala/scala," +
363+
"twitter::https://twitter.com/scala_lang",
364+
// contains special definitions which are "transplanted" elsewhere
365+
// and which therefore confuse Scaladoc when accessed from this pkg
366+
"-skip-by-id:scala.runtime.stdLibPatches",
367+
// MatchCase is a special type that represents match type cases,
368+
// Reflect doesn't expect to see it as a standalone definition
369+
// and therefore it's easier just not to document it
370+
"-skip-by-id:scala.runtime.MatchCase",
371+
),
353372
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
354373
doc / scalaInstance := scalaInstance.value,
355374
)
@@ -752,7 +771,6 @@ object Build {
752771
// when compiling a project that depends on scala3-staging (see sbt-dotty/sbt-test/sbt-dotty/quoted-example-project),
753772
// but we always need it to be present on the JVM classpath at runtime.
754773
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
755-
settings(commonBootstrappedSettings).
756774
settings(
757775
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value
758776
)
@@ -763,7 +781,6 @@ object Build {
763781
// when compiling a project that depends on scala3-tasty-inspector (see sbt-dotty/sbt-test/sbt-dotty/tasty-inspector-example-project),
764782
// but we always need it to be present on the JVM classpath at runtime.
765783
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
766-
settings(commonBootstrappedSettings).
767784
settings(
768785
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value
769786
)
@@ -1597,7 +1614,7 @@ object Build {
15971614
val scala3version = stdlibVersion(Bootstrapped)
15981615
// TODO add versions etc.
15991616
val srcManaged = s"out/bootstrap/stdlib-bootstrapped/scala-$baseVersion/src_managed/main/scala-library-src"
1600-
val sourceLinks = s"-source-links:$srcManaged=github://scala/scala/v$scala3version#src/library"
1617+
val sourceLinks = s"-source-links:$srcManaged=github://scala/scala/v${stdlibVersion(Bootstrapped)}}#src/library"
16011618
val revision = Seq("-revision", ref, "-project-version", projectVersion)
16021619
val cmd = Seq("-d", outDir, "-project", name, sourceLinks) ++ revision ++ params ++ targets
16031620
import _root_.scala.sys.process._
@@ -1618,14 +1635,6 @@ object Build {
16181635
generateDocumentation(
16191636
(Compile / classDirectory).value.getAbsolutePath :: Nil,
16201637
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash,
1621-
Seq(
1622-
"-siteroot", "scaladoc/documentation",
1623-
"-project-logo", "scaladoc/documentation/logo.svg",
1624-
"-external-mappings:" +
1625-
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
1626-
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/"
1627-
)
1628-
16291638
)
16301639
}.value,
16311640
generateScalaDocumentation := Def.inputTaskDyn {
@@ -1661,29 +1670,10 @@ object Build {
16611670
}.dependsOn(generateDocumentation(
16621671
roots, "Scala 3", dest.getAbsolutePath, "master",
16631672
Seq(
1664-
// contains special definitions which are "transplanted" elsewhere
1665-
// and which therefore confuse Scaladoc when accessed from this pkg
1666-
"-skip-by-id:scala.runtime.stdLibPatches",
1667-
// MatchCase is a special type that represents match type cases,
1668-
// Reflect doesn't expect to see it as a standalone definition
1669-
// and therefore it's easier just not to document it
1670-
"-skip-by-id:scala.runtime.MatchCase",
1671-
"-skip-by-regex:.+\\.internal($|\\..+)",
1672-
"-skip-by-regex:.+\\.impl($|\\..+)",
16731673
"-comment-syntax", "wiki",
16741674
"-siteroot", "docs",
1675-
"-project-logo", "docs/logo.svg",
1676-
"-external-mappings:.*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
1677-
"-social-links:" +
1678-
"github::https://github.com/lampepfl/dotty," +
1679-
"gitter::https://gitter.im/scala/scala," +
1680-
"twitter::https://twitter.com/scala_lang",
1681-
s"-source-links:" +
1682-
s"$dottyLibRoot=github://lampepfl/dotty/master#library/src," +
1683-
s"$stdLibRoot=github://scala/scala/v${stdlibVersion(Bootstrapped)}#src/library," +
1684-
s"docs=github://lampepfl/dotty/master#docs",
1685-
"-doc-root-content", docRootFile.toString,
1686-
"-Ydocument-synthetic-types"
1675+
s"-source-links:docs=github://lampepfl/dotty/master#docs",
1676+
"-doc-root-content", docRootFile.toString
16871677
)
16881678
))
16891679
}.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
@@ -474,8 +474,7 @@ object DottyPlugin extends AutoPlugin {
474474
else
475475
s"${name.value}-${configuration.value}"
476476
Seq(
477-
"-project", projectName,
478-
"-from-tasty"
477+
"-project", projectName
479478
)
480479
}
481480
else

0 commit comments

Comments
 (0)