Skip to content

Commit

Permalink
fix UserGuidePage version
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Aug 11, 2023
1 parent fb7ae9d commit f5e98ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ noPublishSettings
commonJvmSettings
libraryDependencies ++= scalameter.value
libraryDependencies += "org.specs2" %% "specs2-html" % specs2Version.value % "test"
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0" % Test
disableScala3

dependsOn(
Expand Down
18 changes: 17 additions & 1 deletion src/test/scala/org/atnos/site/UserGuidePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.specs2.io._
import org.specs2.specification.Snippets
import org.specs2.specification.core._
import org.specs2.specification.create.SpecificationCreation
import scala.collection.compat._
import scala.reflect.ClassTag

abstract class UserGuidePage
Expand Down Expand Up @@ -35,7 +36,22 @@ abstract class UserGuidePage
load(FilePath.unsafe("src/test/scala/" + name.replace(".", "/") + ".scala"))
}

val version = org.atnos.eff.BuildInfo.version
val version: String = {
val v = org.atnos.eff.BuildInfo.version
val suffix = "-SNAPSHOT"
if (v.endsWith(suffix)) {
v.dropRight(suffix.length).split('.').toSeq match {
case xs :+ x =>
x.toIntOption.filter(_ > 0).fold(v) { a =>
(xs :+ (a - 1).toString).mkString(".")
}
case _ =>
v
}
} else {
v
}
}

override implicit def defaultSnippetParameters[T] =
Snippet.defaultParams[T].copy(asCode = (s1: String, s2: String) => splitText(Snippet.markdownCode()(s1, s2)))
Expand Down

0 comments on commit f5e98ea

Please sign in to comment.