Skip to content

Commit

Permalink
Delegate computing Chimney version in MkDocs to a scipt, which would …
Browse files Browse the repository at this point in the history
…also handle -SNAPSHOTs
  • Loading branch information
MateuszKubuszok committed Mar 26, 2024
1 parent 68380c2 commit ebcf74d
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 144 deletions.
46 changes: 23 additions & 23 deletions docs/docs/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If we do not want to enable the same flag(s) in several places, we can define sh

```scala
//> using scala {{ scala.2_13 }}
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

implicit val transformerCfg = TransformerConfiguration.default.enableMethodAccessors.enableMacrosLogging
Expand All @@ -24,7 +24,7 @@ If we do not want to enable the same flag(s) in several places, we can define sh

```scala
//> using scala {{ scala.3 }}
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

transparent inline given TransformerConfiguration[?] =
Expand Down Expand Up @@ -189,7 +189,7 @@ You can use [`.enableMacrosLogging`](troubleshooting.md#debugging-macros) to see
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

case class Foo(baz: Foo.Baz)
Expand Down Expand Up @@ -271,7 +271,7 @@ Then you can use one simple import to enable it:
!!! example

```scala
//> using dep io.scalaland::chimney-java-collections::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-java-collections::{{ chimney_version() }}
import io.scalaland.chimney.javacollections._
```

Expand Down Expand Up @@ -337,7 +337,7 @@ new extension methods: `asValidatedNec`, `asValidatedNel`, `asValidatedChain` an
!!! example

```scala
//> using dep io.scalaland::chimney-cats::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-cats::{{ chimney_version() }}

case class RegistrationForm(
email: String,
Expand Down Expand Up @@ -415,7 +415,7 @@ explanation:
!!! example

```scala
//> using dep io.scalaland::chimney-cats::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-cats::{{ chimney_version() }}
import cats.syntax.all._
import io.scalaland.chimney.Transformer
import io.scalaland.chimney.cats._
Expand All @@ -433,7 +433,7 @@ Similarly, there exists instances for `PartialTransformer` and `partial.Result`:
!!! example

```scala
//> using dep io.scalaland::chimney-cats::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-cats::{{ chimney_version() }}
import cats.syntax.all._
import io.scalaland.chimney.PartialTransformer
import io.scalaland.chimney.cats._
Expand Down Expand Up @@ -511,7 +511,7 @@ What does it means for us?
but to NOT disable parallel semantics for some transformations when we would pass `failFast = false` later on

```scala
//> using dep io.scalaland::chimney-cats::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-cats::{{ chimney_version() }}
import cats.syntax.all._
import io.scalaland.chimney.PartialTransformer
import io.scalaland.chimney.cats._
Expand All @@ -532,7 +532,7 @@ What does it means for us?
And `partial.Result`s have to use explicit combinators to decide whether it's sequential or parallel semantics:

```scala
//> using dep io.scalaland::chimney-cats::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-cats::{{ chimney_version() }}
import cats.syntax.all._
import io.scalaland.chimney.partial
import io.scalaland.chimney.cats._
Expand Down Expand Up @@ -581,7 +581,7 @@ The automatic conversion into a protobuf with such a field can be problematic:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

object domain {
Expand Down Expand Up @@ -612,7 +612,7 @@ There are 2 ways in which Chimney could handle this issue:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

domain.Address("a", "b").into[protobuf.Address]
Expand All @@ -625,7 +625,7 @@ There are 2 ways in which Chimney could handle this issue:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

domain.Address("a", "b").into[protobuf.Address]
Expand Down Expand Up @@ -758,7 +758,7 @@ Encoding (with `Transformer`s) is pretty straightforward:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

val domainType: addressbook.AddressBookType = addressbook.AddressBookType.Private("test")
Expand All @@ -779,7 +779,7 @@ Decoding (with `PartialTransformer`s) requires handling of `Empty.Value` type
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

pbType.value
Expand All @@ -796,7 +796,7 @@ Decoding (with `PartialTransformer`s) requires handling of `Empty.Value` type
!!! example

```scala
//> using dep io.scalaland::chimney-protobufs::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-protobufs::{{ chimney_version() }}
import io.scalaland.chimney.dsl._
import io.scalaland.chimney.protobufs._ // includes support for empty scalapb.GeneratedMessage
Expand Down Expand Up @@ -882,7 +882,7 @@ could be done with:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

val domainStatus: order.CustomerStatus = order.CustomerStatus.CustomerRegistered
Expand Down Expand Up @@ -988,7 +988,7 @@ Each of these transformations is provided by the same import:
!!! example

```scala
//> using dep io.scalaland::chimney-protobufs::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney-protobufs::{{ chimney_version() }}
import io.scalaland.chimney.protobufs._
```

Expand Down Expand Up @@ -1030,7 +1030,7 @@ then Partial Transformer would have to be created manually:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.PartialTransformer
import io.scalaland.chimney.partial

Expand Down Expand Up @@ -1063,7 +1063,7 @@ we could use it to construct `PartialTransformer` automatically:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.PartialTransformer
import io.scalaland.chimney.partial

Expand Down Expand Up @@ -1111,7 +1111,7 @@ as a wrapper around another type that performs this validation e.g. Refined Type
//> using scala {{ scala.2_13 }}
//> using options -Ymacro-annotations
//> using dep io.estatico::newtype::0.4.4
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.estatico.newtype.Coercible
import io.scalaland.chimney.Transformer

Expand Down Expand Up @@ -1149,7 +1149,7 @@ We can use them to provide unwrapping `Transformer` and wrapping

```scala
//> using dep io.monix::newtypes-core::0.2.3
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.{PartialTransformer, Transformer}
import io.scalaland.chimney.partial
import monix.newtypes._
Expand Down Expand Up @@ -1190,7 +1190,7 @@ We can validate using the dedicated type class (`Validate`), while extraction is

```scala
//> using dep eu.timepit::refined::0.11.0
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import eu.timepit.refined.api.{Refined, Validate}
import io.scalaland.chimney.{PartialTransformer, Transformer}
import io.scalaland.chimney.partial
Expand Down Expand Up @@ -1225,7 +1225,7 @@ It could look like this:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney._

sealed trait MyOptional[+A]
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ From now on, forget about it! Encoding domain object with an infallible transfor
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

User(
Expand Down Expand Up @@ -120,7 +120,7 @@ Done! Decoding Protobuf into domain object with a fallible transformation, like
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

UserDTO(
Expand Down
20 changes: 10 additions & 10 deletions docs/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ To start using the library add to your sbt config:

```scala
// if you use Scala on JVM-only
libraryDependencies += "io.scalaland" %% "chimney" % "{{ git.tag or local.tag }}"
libraryDependencies += "io.scalaland" %% "chimney" % "{{ chimney_version() }}"
// if you cross-compile to Scala.js and/or Scala Native
libraryDependencies += "io.scalaland" %%% "chimney" % "{{ git.tag or local.tag }}"
libraryDependencies += "io.scalaland" %%% "chimney" % "{{ chimney_version() }}"
```

and then import in your codebase:
Expand All @@ -38,11 +38,11 @@ or try it in [Scala CLI](https://scala-cli.virtuslab.org/):

```bash
# Scala 2.12
scala-cli repl --scala "{{ scala.2_12 }}" --dependency "io.scalaland::chimney::{{ git.tag or local.tag }}"
scala-cli repl --scala "{{ scala.2_12 }}" --dependency "io.scalaland::chimney::{{ chimney_version() }}"
# Scala 2.13
scala-cli repl --scala "{{ scala.2_13 }}" --dependency "io.scalaland::chimney::{{ git.tag or local.tag }}"
scala-cli repl --scala "{{ scala.2_13 }}" --dependency "io.scalaland::chimney::{{ chimney_version() }}"
# Scala 3
scala-cli repl --scala "{{ scala.3 }}" --dependency "io.scalaland::chimney::{{ git.tag or local.tag }}"
scala-cli repl --scala "{{ scala.3 }}" --dependency "io.scalaland::chimney::{{ chimney_version() }}"
```

!!! tip
Expand All @@ -57,7 +57,7 @@ other Java's types, you need to add integration to your project:

```scala
// Java collections integrations is released only on JVM Scala!
libraryDependencies += "io.scalaland" %% "chimney-java-collections" % "{{ git.tag or local.tag }}"
libraryDependencies += "io.scalaland" %% "chimney-java-collections" % "{{ chimney_version() }}"
```

and then import:
Expand All @@ -76,9 +76,9 @@ If you are interested in Cats integrations for Partial Transformers, you need to

```scala
// if you use Scala on JVM-only
libraryDependencies += "io.scalaland" %% "chimney-cats" % "{{ git.tag or local.tag }}"
libraryDependencies += "io.scalaland" %% "chimney-cats" % "{{ chimney_version() }}"
// if you cross-compile to Scala.js and/or Scala Native
libraryDependencies += "io.scalaland" %%% "chimney-cats" % "{{ git.tag or local.tag }}"
libraryDependencies += "io.scalaland" %%% "chimney-cats" % "{{ chimney_version() }}"
```

```scala
Expand All @@ -95,9 +95,9 @@ If you want to improve support for types defined in ScalaPB, you need to add to

```scala
// if you use Scala on JVM-only
libraryDependencies += "io.scalaland" %% "chimney-protobufs" % "{{ git.tag or local.tag }}"
libraryDependencies += "io.scalaland" %% "chimney-protobufs" % "{{ chimney_version() }}"
// if you cross-compile to Scala.js and/or Scala Native
libraryDependencies += "io.scalaland" %%% "chimney-protobufs" % "{{ git.tag or local.tag }}"
libraryDependencies += "io.scalaland" %%% "chimney-protobufs" % "{{ chimney_version() }}"
```

```scala
Expand Down
14 changes: 7 additions & 7 deletions docs/docs/supported-patching.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Currently, the only supported case is updating one `case class` with another:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

case class Email(address: String) extends AnyVal
Expand Down Expand Up @@ -41,7 +41,7 @@ When the patch `case class` contains a field that does not exist in patched obje
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

case class User(id: Int, email: String, phone: Long)
Expand All @@ -63,7 +63,7 @@ But there is a way to ignore redundant patcher fields explicitly with `.ignoreRe
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

case class User(id: Int, email: String, phone: Long)
Expand Down Expand Up @@ -94,7 +94,7 @@ If the flag was enabled in the implicit config it can be disabled with `.failRed
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

case class User(id: Int, email: String, phone: Long)
Expand Down Expand Up @@ -127,7 +127,7 @@ Let’s consider the following patch:
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._

case class User(id: Int, email: String, phone: Long)
Expand Down Expand Up @@ -169,7 +169,7 @@ but it also gives a simple way to always ignore `None` from the patch with `.ign
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._
case class User(name: Option[String], age: Option[Int])
Expand Down Expand Up @@ -201,7 +201,7 @@ If the flag was enabled in the implicit config it can be disabled with `.clearOn
!!! example

```scala
//> using dep io.scalaland::chimney::{{ git.tag or local.tag }}
//> using dep io.scalaland::chimney::{{ chimney_version() }}
import io.scalaland.chimney.dsl._
case class User(name: Option[String], age: Option[Int])
Expand Down
Loading

0 comments on commit ebcf74d

Please sign in to comment.