8000 Additional webpage fixes by arainko · Pull Request #140 · arainko/ducktape · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,32 @@ lazy val docs =
.enablePlugins(NoPublishPlugin, MdocPlugin, TypelevelSitePlugin)
.disablePlugins(MimaPlugin)
.settings(
// laikaTheme := DeffSiteSettings.defaults.value.build,
// tlSiteIsTypelevelProject := Some(TypelevelProject.Affiliate),
laikaConfig := LaikaConfig.defaults
.withConfigValue(
Selections(
SelectionConfig(
"underlying-code",
ChoiceConfig("visible", "User visible code"),
ChoiceConfig("generated", "Generated code")
),
SelectionConfig(
"model",
ChoiceConfig("wire", "Wire model"),
ChoiceConfig("domain", "Domain model")
),
SelectionConfig(
"fallible-model",
ChoiceConfig("wire", "Wire model"),
ChoiceConfig("domain", "Domain model"),
ChoiceConfig("newtypes", "Newtypes")
)
Seq(
SelectionConfig(
"model",
ChoiceConfig("wire", "Wire model"),
ChoiceConfig("domain", "Domain model")
),
SelectionConfig(
"fallible-model",
ChoiceConfig("wire", "Wire model"),
ChoiceConfig("domain", "Domain model"),
ChoiceConfig("newtypes", "Newtypes")
)
) ++ (
// Going overboard with this since all selections are connected to each other (eg. you pick an option on of them)
// then all of them will change, this caused screen jumps when looking at the generated code
(1 to 15).map(num =>
SelectionConfig(
s"underlying-code-$num",
ChoiceConfig("visible", "User visible code"),
ChoiceConfig("generated", "Generated code")
)
)
): _*
)
),
tlSiteHelium := DeffSiteSettings.defaults.value,
Expand Down
8 changes: 4 additions & 4 deletions docs/fallible_transformations/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ These will be used interchangably throughout the examples below, but if you want

* 10BC8 `Source#fallibleTo[Dest]` - for any two types `Source` and `Dest`, used to create a direct transformation between `Source` and `Dest` but taking into account all of the fallible transformations between the fields:

@:select(underlying-code)
@:select(underlying-code-1)
@:choice(visible)
```scala mdoc
given Mode.Accumulating.Either[String, List] with {}
Expand All @@ -121,7 +121,7 @@ Read more about the rules under which the transformations are generated in a cha

* `Source#into[Dest].fallible` - for any two types `Source` and `Dest`, used to create a 'transformation builder' that allows fixing transformation errors and overriding transformations for selected fields or subtypes.

@:select(underlying-code)
@:select(underlying-code-2)
@:choice(visible)
```scala mdoc:nest
given Mode.FailFast.Either[String] with {}
Expand Down Expand Up @@ -155,7 +155,7 @@ Read more in the section about [configuring fallible transformations](configurin

* `Source#fallibleVia(<method reference>)` - for any type `Source` and a method reference that can be eta-expanded into a function with named arguments (which is subsequently used to expand the method's argument list with the fields of the `Source` type):

@:select(underlying-code)
@:select(underlying-code-3)
@:choice(visible)
```scala mdoc:nest
given Mode.Accumulating.Either[String, List] with {}
Expand All @@ -172,7 +172,7 @@ Docs.printCode(wirePerson.fallibleVia(domain.Person.apply))

* `Source.intoVia(<method reference>).fallible` - for any type `Source` and a method reference that can be eta-expanded into a function with named arguments, used to create a 'transformation builder' that allows fixing transformation errors and overriding transformations for selected fields or subtypes.

@:select(underlying-code)
@:select(underlying-code-4)
@:choice(visible)
```scala mdoc:nest
given Mode.FailFast.Either[String] with {}
Expand Down
10BC8
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ val good = wire.Person(name = "ValidName", age = 24, socialSecurityNo = "SOCIALN

* `Field.fallibleConst` - a fallible variant of `Field.const` that allows for supplying values wrapped in an `F`

@:select(underlying-code)
@:select(underlying-code-1)
@:choice(visible)
```scala mdoc:nest
import io.github.arainko.ducktape.*
Expand Down Expand Up @@ -116,7 +116,7 @@ Docs.printCode(
* `Field.fallibleComputed` - a fallible variant of `Field.computed` that allows for supplying functions that return values wrapped in an `F`


@:select(underlying-code)
@:select(underlying-code-2)
@:choice(visible)
```scala mdoc:nest
given Mode.Accumulating.Either[String, List] with {}
Expand Down Expand Up @@ -158,7 +158,7 @@ object domain:

* `Case.fallibleConst` - a fallible variant of `Case.const` that allows for supplying values wrapped in an `F`

@:select(underlying-code)
@:select(underlying-code-3)
@:choice(visible)
```scala mdoc:nest
given Mode.FailFast.Either[String] with {}
Expand All @@ -185,7 +185,7 @@ Docs.printCode(

* `Case.fallibleComputed` - a fallible variant of `Case.computed` that allows for supplying functions that return values wrapped in an `F`

@:select(underlying-code)
@:select(underlying-code-4)
@:choice(visible)
```scala mdoc:nest
given Mode.FailFast.Either[String] with {}
Expand Down Expand Up @@ -227,7 +227,7 @@ object domain:
case class Person(name: NonEmptyString, age: Positive, socialSecurityNo: NonEmptyString)
```

@:select(underlying-code)
@:select(underlying-code-5)
@:choice(visible)
```scala mdoc:nest:silent
given Mode.Accumulating.Either[String, List] with {}
Expand Down Expand Up @@ -255,7 +255,7 @@ Docs.printCode(

And for the ones that are not keen on writing out method arguments:

@:select(underlying-code)
@:select(underlying-code-6)
@:choice(visible)
```scala mdoc:nest:silent
given Mode.Accumulating.Either[String, List] with {}
Expand Down
4 changes: 2 additions & 2 deletions docs/fallible_transformations/making_the_most_out_of.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ val good = UnvalidatedPerson(name = "ValidName", age = 24, socialSecurityNo = "S

Fallible transformations wrapped in some type `F` are derived automatically for case classes given that a `Transformer.Fallible` instance exists for `F` and all of the fields of the source type have a corresponding counterpart in the destination type and each one of them has an instance of either `Transformer.Fallible` or a total `Transformer` in scope.

@:select(underlying-code)
@:select(underlying-code-1)
@:choice(visible)
```scala mdoc
given Mode.Accumulating.Either[String, List] with {}
Expand All @@ -79,7 +79,7 @@ Docs.printCode(bad.fallibleTo[Person])

Same goes for instances that do fail fast transformations (you need `Mode.FailFast[F]` in scope in this case)

@:select(underlying-code)
@:select(underlying-code-2)
@:choice(visible)
```scala mdoc:nest
given Mode.FailFast.Either[String] with {}
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ val wirePerson: wire.Person = wire.Person(

...then transforming between the `wire` and `domain` models is just a matter of calling `.to[domain.Person]` on the input:

@:select(underlying-code)
@:select(underlying-code-1)
@:choice(visible)
```scala mdoc
wirePerson.to[domain.Person]
Expand Down Expand Up @@ -196,7 +196,7 @@ especially the part after `@`:

the thing above is basically a path to the field/subtype under which `ducktape` was not able to create a transformation, these are meant to be copy-pastable for when you're actually trying to fix the error, eg. by setting the `name` field to a constant value:

@:select(underlying-code)
@:select(underlying-code-2)

@:choice(visible)
```scala mdoc
Expand Down
8 changes: 4 additions & 4 deletions docs/total_transformations/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ val wirePerson = wire.Person(

* `Source#to[Dest]` - for any two types `Source` and `Dest`, used to create a direct transformation between `Source` and `Dest`:

@:select(underlying-code)
@:select(underlying-code-1)
@:choice(visible)
```scala mdoc
import io.github.arainko.ducktape.*
Expand All @@ -78,7 +78,7 @@ Read more about the rules under which the transformations are generated in a cha

* `Source#into[Dest]` - for any two types `Source` and `Dest`, used to create a 'transformation builder' that allows fixing transformation errors and overriding transformations for selected fields or subtypes.

@:select(underlying-code)
@:select(underlying-code-2)
@:choice(visible)
```scala mdoc
import io.github.arainko.ducktape.*
Expand All @@ -103,7 +103,7 @@ Read more in the section about [configuring transformations](configuring_transfo

* `Source#via(<method reference>)` - for any type `Source` and a method reference that can be eta-expanded into a function with named arguments (which is subsequently used to expand the method's argument list with the fields of the `Source` type):

@:select(underlying-code)
@:select(underlying-code-3)
@:choice(visible)
```scala mdoc
import io.github.arainko.ducktape.*
Expand All @@ -122,7 +122,7 @@ To read about how these transformations are generated head on over to the sectio

* `Source.intoVia(<method reference>)` - for any type `Source` and a method reference that can be eta-expanded into a function with named arguments, used to create a 'transformation builder' that allows fixing transformation errors and overriding transformations for selected fields or subtypes.

@:select(underlying-code)
@:select(underlying-code-4)
@:choice(visible)
```scala mdoc
import io.github.arainko.ducktape.*
Expand Down
22 changes: 11 additions & 11 deletions docs/total_transformations/configuring_transformations.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ wirePerson.to[domain.Person]

The newly added field (`age`) and enum case (`PaymentMethod.Transfer`) do not have a corresponding mapping, let's say we want to set the age field to a constant value of 24 and when a `PaymentMethod.Transfer` is encountered we map it to `Cash` instead.

@:select(underlying-code)
@:select(underlying-code-1)
@:choice(visible)

```scala mdoc
Expand Down Expand Up @@ -157,7 +157,7 @@ val card: wire.PaymentMethod.Card =

* `Field.const` - allows to supply a constant value for a given field

@:select(underlying-code)
@:select(underlying-code-2)
@:choice(visible)
```scala mdoc
card
Expand All @@ -178,7 +178,7 @@ Docs.printCode(

* `Field.computed` - allows to compute a value with a function the shape of `Dest => FieldTpe`

@:select(underlying-code)
@:select(underlying-code-3)
@:choice(visible)
```scala mdoc
card
Expand All @@ -203,7 +203,7 @@ Docs.printCode(

* `Field.default` - only works when a field's got a default value defined (defaults are not taken into consideration by default)

@:select(underlying-code)
@:select(underlying-code-4)
@:choice(visible)
```scala mdoc
card
Expand All @@ -229,7 +229,7 @@ case class FieldSource(color: String, digits: Long, extra: Int)
val source = FieldSource("magenta", 123445678, 23)
```

@:select(underlying-code)
@:select(underlying-code-5)
@:choice(visible)
```scala mdoc
card
Expand Down Expand Up @@ -260,7 +260,7 @@ case class DestLevel1(extra: String = "level1", str: String)
val source = SourceToplevel(SourceLevel1("str"), 400)
```

@:select(underlying-code)
@:select(underlying-code-6)
@:choice(visible)
```scala mdoc
source
Expand All @@ -282,7 +282,7 @@ Docs.printCode(

`Field.fallbackToDefault` is a `regional` config, which means that you can control the scope where it applies:

@:select(underlying-code)
@:select(underlying-code-7)
@:choice(visible)
```scala mdoc
source
Expand Down Expand Up @@ -323,7 +323,7 @@ case class DestLevel1(extra: Option[String], str: String)
val source = SourceToplevel(SourceLevel1("str"), Some(400))
```

@:select(underlying-code)
@:select(underlying-code-8)
@:choice(visible)
```scala mdoc
source
Expand All @@ -345,7 +345,7 @@ Docs.printCode(

`Field.fallbackToNone` is a `regional` config, which means that you can control the scope where it applies:

@:select(underlying-code)
@:select(underlying-code-9)
@:choice(visible)
```scala mdoc
source
Expand Down Expand Up @@ -380,7 +380,7 @@ val transfer = wire.PaymentMethod.Transfer("2764262")

* `Case.const` - allows to supply a constant value for a given subtype of a coproduct

@:select(underlying-code)
@:select(underlying-code-10)
@:choice(visible)
```scala mdoc
transfer
Expand All @@ -402,7 +402,7 @@ Docs.printCode(

* `Case.computed` - allow to supply a function of the selected source type to the expected destination type

@:select(underlying-code)
@:select(underlying-code-11)
@:choice(visible)
```scala mdoc
transfer
Expand Down
Loading
0