Skip to content

Commit e2df0e2

Browse files
authored
Merge pull request #337 from armanbilge/issue/323
Configure scaladoc3 `-source-links` and friends
2 parents 590dfc7 + 4718b61 commit e2df0e2

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616

1717
package org.typelevel.sbt
1818

19+
import com.typesafe.sbt.SbtGit.git
20+
import org.typelevel.sbt.kernel.GitHelper
1921
import sbt._
2022

2123
import scala.util.Try
2224

2325
import Keys._
26+
import TypelevelKernelPlugin.autoImport._
2427

2528
object TypelevelGitHubPlugin extends AutoPlugin {
2629

@@ -51,6 +54,22 @@ object TypelevelGitHubPlugin extends AutoPlugin {
5154
homepage := homepage.value.orElse(scmInfo.value.map(_.browseUrl))
5255
)
5356

57+
override def projectSettings: Seq[Setting[_]] = Seq(
58+
Compile / doc / scalacOptions ++= {
59+
val tagOrHash =
60+
GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
61+
val userRepo = gitHubUserRepo.value
62+
63+
if (tlIsScala3.value)
64+
tagOrHash.toSeq flatMap { vh =>
65+
userRepo.toSeq flatMap {
66+
case (user, repo) => Seq(s"-source-links:github://${user}/${repo}", "-revision", vh)
67+
}
68+
}
69+
else Nil // TODO move from settings plugin
70+
}
71+
)
72+
5473
private def gitHubScmInfo(user: String, repo: String) =
5574
ScmInfo(
5675
url(s"https://github.com/$user/$repo"),

settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,22 @@ object TypelevelSettingsPlugin extends AutoPlugin {
177177
),
178178
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
179179
Compile / doc / scalacOptions ++= {
180-
if (tlIsScala3.value)
181-
Seq("-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath)
182-
else {
183-
184-
val tagOrHash =
185-
GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
180+
Seq("-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath)
181+
},
182+
Compile / doc / scalacOptions ++= {
183+
val tagOrHash =
184+
GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
185+
val infoOpt = scmInfo.value
186186

187-
val infoOpt = scmInfo.value
187+
if (tlIsScala3.value)
188+
Seq("-project-version", version.value)
189+
else // TODO move to GitHub plugin
188190
tagOrHash.toSeq flatMap { vh =>
189191
infoOpt.toSeq flatMap { info =>
190192
val path = s"${info.browseUrl}/blob/${vh}€{FILE_PATH}.scala"
191-
Seq(
192-
"-doc-source-url",
193-
path,
194-
"-sourcepath",
195-
(LocalRootProject / baseDirectory).value.getAbsolutePath)
193+
Seq("-doc-source-url", path)
196194
}
197195
}
198-
}
199196
},
200197
javacOptions ++= Seq(
201198
"-encoding",

0 commit comments

Comments
 (0)