Skip to content

Commit

Permalink
Add support for Scala3
Browse files Browse the repository at this point in the history
  • Loading branch information
pikinier20 committed Oct 7, 2021
1 parent 9153b20 commit f02c2cd
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/main/scala/sbtunidoc/ScalaUnidocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ object ScalaUnidocPlugin extends AutoPlugin {
)

lazy val allScalaSources = Def.taskDyn {
val f = (unidoc / unidocScopeFilter).value
sources.all(f)
val f = (unidocScopeFilter in unidoc).value
if(ScalaArtifacts.isScala3(scalaVersion.value)) {
tastyFiles.all(f) // Since Scaladoc 3 works on TASTy files
} else {
sources.all(f)
}
}
}
4 changes: 3 additions & 1 deletion src/main/scala/sbtunidoc/Unidoc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ object Unidoc {
def apply(cache: File, cs: Compilers, srcs: Seq[File], cp: Classpath,
sOpts: Seq[String], jOpts: Seq[String], xapis: Map[File, URL], maxErrors: Int,
out: File, config: Configuration, s: TaskStreams, spm: Seq[xsbti.Position => Option[xsbti.Position]], converter: FileConverter): File = {
val hasScala = srcs.exists(_.name.endsWith(".scala"))
val hasScala = srcs.exists(_.name.endsWith(".scala")) ||
srcs.exists(_.name.endsWith(".tasty")) || // Condition for Scaladoc 3
sOpts.contains("-siteroot") // Condition for Scaladoc 3
val hasJava = srcs.exists(_.name.endsWith(".java"))
val label = nameForSrc(config.name)
val reporter = new ManagedLoggedReporter(
Expand Down
1 change: 1 addition & 0 deletions src/sbt-test/unidoc/scala3-unidoc/.bsp/sbt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"sbt","version":"1.5.3","bspVersion":"2.0.0-M5","languages":["scala"],"argv":["/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/bin/java","-Xms100m","-Xmx100m","-classpath","/usr/local/Cellar/sbt/1.5.3/libexec/bin/sbt-launch.jar","xsbt.boot.Boot","-bsp","--sbt-launch-jar=/usr/local/Cellar/sbt/1.5.3/libexec/bin/sbt-launch.jar"]}
3 changes: 3 additions & 0 deletions src/sbt-test/unidoc/scala3-unidoc/a/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package example

class A
3 changes: 3 additions & 0 deletions src/sbt-test/unidoc/scala3-unidoc/b/B.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package example

class B
24 changes: 24 additions & 0 deletions src/sbt-test/unidoc/scala3-unidoc/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
val commonSettings = Seq(
scalaVersion := "3.0.2"
)

lazy val a = project.settings(
commonSettings
)

lazy val b = project.settings(
commonSettings
)

lazy val c = project.settings(
commonSettings
)

lazy val root = project.in(file(".")).settings(
commonSettings,
unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject -- inProjects(c)
).enablePlugins(
ScalaUnidocPlugin
).aggregate(
a, b, c
)
3 changes: 3 additions & 0 deletions src/sbt-test/unidoc/scala3-unidoc/c/C.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package example

class C
1 change: 1 addition & 0 deletions src/sbt-test/unidoc/scala3-unidoc/project/plugin.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % System.getProperty("plugin.version"))
4 changes: 4 additions & 0 deletions src/sbt-test/unidoc/scala3-unidoc/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
> unidoc
$ exists target/scala-3.0.2/unidoc/api/example/A.html
$ exists target/scala-3.0.2/unidoc/api/example/B.html
-$ exists target/scala-3.0.2/unidoc/api/example/C.html

0 comments on commit f02c2cd

Please sign in to comment.