Skip to content

Commit

Permalink
Merge pull request #512 from alejandrohdezma/feature/supported-scala-…
Browse files Browse the repository at this point in the history
…versions

Add new `SUPPORTED_SCALA_VERSIONS` mdoc variable with list of supported versions in markdown format
  • Loading branch information
alejandrohdezma authored Jan 9, 2024
2 parents 6c56f4e + ee76a76 commit cdb76f8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,40 @@ object SbtGithubMdocPlugin extends AutoPlugin {
displayName := SbtGithubPlugin.info.value._2,
removeVersionTimestampInMdoc := true,
mdocVariables ++= Map(
"ORGANIZATION" -> organization.value,
"NAME" -> displayName.value,
"REPO" -> repository.value.map(_.name).getOrElse(""),
"DEFAULT_BRANCH" -> repository.value.map(_.defaultBranch).getOrElse(""),
"LICENSE" -> licenses.value.headOption.map(_._1).getOrElse(""),
"ORG_NAME" -> organizationName.value,
"DESCRIPTION" -> description.value,
"ORG_EMAIL" -> organizationEmail.value.getOrElse(""),
"ORG_URL" -> organizationHomepage.value.map(url => s"$url").getOrElse(""),
"START_YEAR" -> startYear.value.fold("")(year => s"$year"),
"YEAR_RANGE" -> yearRange.value.getOrElse(""),
"VERSION" -> versionForMdoc.value,
"CONTRIBUTORS" -> contributors.value.markdownList,
"CONTRIBUTORS_LIST" -> contributors.value.markdownList,
"CONTRIBUTORS_TABLE" -> contributors.value.markdownTable,
"COLLABORATORS" -> collaborators.value.markdownList,
"COLLABORATORS_LIST" -> collaborators.value.markdownList,
"COLLABORATORS_TABLE" -> collaborators.value.markdownTable,
"ORGANIZATION" -> organization.value,
"NAME" -> displayName.value,
"REPO" -> repository.value.map(_.name).getOrElse(""),
"DEFAULT_BRANCH" -> repository.value.map(_.defaultBranch).getOrElse(""),
"SUPPORTED_SCALA_VERSIONS" -> supportedScalaVersionsForMDoc.value,
"LICENSE" -> licenses.value.headOption.map(_._1).getOrElse(""),
"ORG_NAME" -> organizationName.value,
"DESCRIPTION" -> description.value,
"ORG_EMAIL" -> organizationEmail.value.getOrElse(""),
"ORG_URL" -> organizationHomepage.value.map(url => s"$url").getOrElse(""),
"START_YEAR" -> startYear.value.fold("")(year => s"$year"),
"YEAR_RANGE" -> yearRange.value.getOrElse(""),
"VERSION" -> versionForMdoc.value,
"CONTRIBUTORS" -> contributors.value.markdownList,
"CONTRIBUTORS_LIST" -> contributors.value.markdownList,
"CONTRIBUTORS_TABLE" -> contributors.value.markdownTable,
"COLLABORATORS" -> collaborators.value.markdownList,
"COLLABORATORS_LIST" -> collaborators.value.markdownList,
"COLLABORATORS_TABLE" -> collaborators.value.markdownTable,
"COPYRIGHT_OWNER" -> organizationHomepage.value
.map(url => s"${organizationName.value} <$url>")
.getOrElse(organizationName.value)
)
)

private val versionForMdoc = Def.setting {
private val supportedScalaVersionsForMDoc: Def.Initialize[String] = Def.setting {
crossScalaVersions.value.map(version => s"`$version`") match {
case list :+ last => s"${list.mkString(", ")} and $last"
case head :: Nil => head
case Nil => ""
}
}

private val versionForMdoc: Def.Initialize[String] = Def.setting {
if (removeVersionTimestampInMdoc.value) version.value.replaceAll("\\+.*", "")
else version.value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ https://github.com/user1
| :--: | :--: |
| <a href="https://github.com/user1"><sub><b>user1</b></sub></a> | <a href="https://github.com/user2"><sub><b>user2</b></sub></a> |

The First User <https://github.com/user1>
The First User <https://github.com/user1>

`2.12.18`, `2.13.12` and `3.3.0`
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
ThisBuild / scmInfo := Some(
ScmInfo(url("http://example.com"), "scm:git:https://github.com/alejandrohdezma/sbt-github.git")
)
ThisBuild / organization := "my.org"
ThisBuild / githubEnabled := true
ThisBuild / githubAuthToken := Some(AuthToken("1234"))
ThisBuild / crossScalaVersions := Seq("2.12.18", "2.13.12", "3.3.0")
ThisBuild / organization := "my.org"
ThisBuild / githubEnabled := true
ThisBuild / githubAuthToken := Some(AuthToken("1234"))
ThisBuild / githubApiEntryPoint := {
val github = baseDirectory.value / "github"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@

@COLLABORATORS_TABLE@

@COPYRIGHT_OWNER@
@COPYRIGHT_OWNER@

@SUPPORTED_SCALA_VERSIONS@

0 comments on commit cdb76f8

Please sign in to comment.