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

Configure scaladoc3 -source-links and friends #337

Merged
merged 3 commits into from
Jul 16, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@

package org.typelevel.sbt

import com.typesafe.sbt.SbtGit.git
import org.typelevel.sbt.kernel.GitHelper
import sbt._

import scala.util.Try

import Keys._
import TypelevelKernelPlugin.autoImport._

object TypelevelGitHubPlugin extends AutoPlugin {

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

override def projectSettings: Seq[Setting[_]] = Seq(
Compile / doc / scalacOptions ++= {
val tagOrHash =
GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
val userRepo = gitHubUserRepo.value

if (tlIsScala3.value)
tagOrHash.toSeq flatMap { vh =>
userRepo.toSeq flatMap {
case (user, repo) => Seq(s"-source-links:github://${user}/${repo}", "-revision", vh)
}
}
else Nil // TODO move from settings plugin
}
)

private def gitHubScmInfo(user: String, repo: String) =
ScmInfo(
url(s"https://github.com/$user/$repo"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,22 @@ object TypelevelSettingsPlugin extends AutoPlugin {
),
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
Compile / doc / scalacOptions ++= {
if (tlIsScala3.value)
Seq("-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath)
else {

val tagOrHash =
GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
Seq("-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath)
},
Compile / doc / scalacOptions ++= {
val tagOrHash =
GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
val infoOpt = scmInfo.value

val infoOpt = scmInfo.value
if (tlIsScala3.value)
Seq("-project-version", version.value)
else // TODO move to GitHub plugin
tagOrHash.toSeq flatMap { vh =>
infoOpt.toSeq flatMap { info =>
val path = s"${info.browseUrl}/blob/${vh}€{FILE_PATH}.scala"
Seq(
"-doc-source-url",
path,
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath)
Seq("-doc-source-url", path)
}
}
}
},
javacOptions ++= Seq(
"-encoding",
Expand Down