From c27b82f321042e7976ad12bf35fd0a1d777a8ab6 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 16 Jul 2022 01:43:00 +0000 Subject: [PATCH 1/3] Configure scaladoc3 source-links --- .../typelevel/sbt/TypelevelGitHubPlugin.scala | 19 ++++++++++++++++ .../sbt/TypelevelSettingsPlugin.scala | 22 ++++++++----------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala b/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala index 96c87d17..7e87f379 100644 --- a/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala +++ b/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala @@ -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 { @@ -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"), diff --git a/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala b/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala index a70966c3..f38e0ce7 100644 --- a/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala +++ b/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala @@ -177,25 +177,21 @@ 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) Nil + 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", From 50ac35cfa6f779045feba196fa7fa7d3ec8d2bbe Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 16 Jul 2022 01:49:23 +0000 Subject: [PATCH 2/3] Configure more scaladoc3 options --- .../scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala b/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala index f38e0ce7..952f8966 100644 --- a/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala +++ b/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala @@ -184,7 +184,9 @@ object TypelevelSettingsPlugin extends AutoPlugin { GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value) val infoOpt = scmInfo.value - if (tlIsScala3.value) Nil + if (tlIsScala3.value) + Seq("-project-version", version.value) ++ + infoOpt.toSeq.flatMap(i => Seq("-project-url", i.browseUrl.toString)) else // TODO move to GitHub plugin tagOrHash.toSeq flatMap { vh => infoOpt.toSeq flatMap { info => From 4718b6154c82a617ba569d5c5cecfae79f8b00b1 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 16 Jul 2022 01:58:14 +0000 Subject: [PATCH 3/3] -project-url doesn't seem to work, ffs --- .../main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala b/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala index 952f8966..c8b4db04 100644 --- a/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala +++ b/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala @@ -185,8 +185,7 @@ object TypelevelSettingsPlugin extends AutoPlugin { val infoOpt = scmInfo.value if (tlIsScala3.value) - Seq("-project-version", version.value) ++ - infoOpt.toSeq.flatMap(i => Seq("-project-url", i.browseUrl.toString)) + Seq("-project-version", version.value) else // TODO move to GitHub plugin tagOrHash.toSeq flatMap { vh => infoOpt.toSeq flatMap { info =>