Skip to content

Commit c27b82f

Browse files
committed
Configure scaladoc3 source-links
1 parent 590dfc7 commit c27b82f

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-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: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,21 @@ 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) Nil
188+
else // TODO move to GitHub plugin
188189
tagOrHash.toSeq flatMap { vh =>
189190
infoOpt.toSeq flatMap { info =>
190191
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)
192+
Seq("-doc-source-url", path)
196193
}
197194
}
198-
}
199195
},
200196
javacOptions ++= Seq(
201197
"-encoding",

0 commit comments

Comments
 (0)