Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Scala 3 #88

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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