djspiewak / sbt-spiewak

A plugin which represents my personal SBT project baseline
Apache License 2.0
53 stars 20 forks source link

Scaladoc backlink settings #8

Closed djspiewak closed 4 years ago

djspiewak commented 4 years ago

It surprises me that I never did this:

scalacOptions in (Compile, doc) ++= {
    val isSnapshot = git.gitCurrentTags.value.map(git.gitTagToVersionNumber.value).flatten.isEmpty

    val path =
      if (isSnapshot)
        scmInfo.value.get.browseUrl + "/blob/" + git.gitHeadCommit.value.get + "€{FILE_PATH}.scala"
      else
        scmInfo.value.get.browseUrl + "/blob/v" + version.value + "€{FILE_PATH}.scala"

    Seq("-doc-source-url", path, "-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath)
  },
djspiewak commented 4 years ago

Also scalajs things:

scalacOptions += {
    val hasVersion = git.gitCurrentTags.value.map(git.gitTagToVersionNumber.value).flatten.nonEmpty
    val versionOrHash =
      if (hasVersion)
        s"v${version.value}"
      else
        git.gitHeadCommit.value.get

    val l = (baseDirectory in LocalRootProject).value.toURI.toString
    val g = s"https://raw.githubusercontent.com/typelevel/cats-effect/$versionOrHash/"
    s"-P:scalajs:mapSourceURI:$l->$g"
  },