Skip to content

Commit b2cabec

Browse files
authored
Merge pull request #316 from armanbilge/doc/auto-populate-startyear-sjsv
Auto-populate startYear and SJS version in docs
2 parents 947ce2b + 7278b65 commit b2cabec

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

build.sbt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,28 @@ lazy val docs = project
198198
"mdoc" -> url("https://scalameta.org/mdoc/"),
199199
"Laika" -> url("https://planet42.github.io/Laika/"),
200200
"sbt-unidoc" -> url("https://github.com/sbt/sbt-unidoc")
201-
)
201+
),
202+
mdocVariables ++= {
203+
import coursier.complete.Complete
204+
import java.time._
205+
import scala.concurrent._
206+
import scala.concurrent.duration._
207+
import scala.concurrent.ExecutionContext.Implicits._
208+
209+
val startYear = YearMonth.now().getYear.toString
210+
211+
val sjsVersionFuture =
212+
Complete().withInput(s"org.scala-js:scalajs-library_2.13:").complete().future()
213+
val sjsVersion =
214+
try {
215+
Await.result(sjsVersionFuture, 5.seconds)._2.last
216+
} catch {
217+
case ex: TimeoutException => scalaJSVersion // not the latest but better than nothing
218+
}
219+
220+
Map(
221+
"START_YEAR" -> startYear,
222+
"LATEST_SJS_VERSION" -> sjsVersion
223+
)
224+
}
202225
)

docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Check out the [**sbt-typelevel-site**](site.md) plugin.
101101
We recommend explicitly setting your Scala.js version in `project/plugins.sbt`.
102102

103103
```scala
104-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")
104+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "@LATEST_SJS_VERSION@")
105105
```
106106

107107
**sbt-typelevel** ships with a conservative Scala.js version to enable certain settings.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ThisBuild / tlBaseVersion := "0.4" // your current series x.y
7171

7272
ThisBuild / organization := "org.typelevel"
7373
ThisBuild / organizationName := "Typelevel"
74-
ThisBuild / startYear := Some(2022)
74+
ThisBuild / startYear := Some(@START_YEAR@)
7575
ThisBuild / licenses := Seq(License.Apache2)
7676
ThisBuild / developers := List(
7777
// your GitHub handle and name

project/build.sbt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ Compile / unmanagedSourceDirectories ++= modules.map { module =>
2424
Compile / unmanagedResourceDirectories ++= modules.map { module =>
2525
baseDirectory.value.getParentFile / module / "src" / "main" / "resources"
2626
}
27+
28+
libraryDependencies ++= Seq(
29+
"io.get-coursier" %% "coursier" % "2.1.0-M6"
30+
)

0 commit comments

Comments
 (0)