Skip to content

Commit

Permalink
doc: explain how to use Parser Combinators if needed and library change
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaechler committed Jan 17, 2025
1 parent c5d34b9 commit ea71d52
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Cron4s Change Log

## 0.8.0

Breaking changes:

* In previous versions, Cron expression parsing was using [Scala Parser Combinators](https://github.com/scala/scala-parser-combinators).
Parsing is now achieved using [Atto library](https://tpolecat.github.io/atto/) by default on all targets except Native.
Both parsers should behave the same way and the API didn't change. They will be kept in sync for the time being.
In case you notice any change in behavior, please open an issue with your input.
You can always fall back to the Parser Combinator version by adding `cron4s-parserc` as a dependency of your project and
use `Cron.withParser(cron4s.parsing.Parser)` instead of `Cron` instance.

## 0.6.1

Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/mdoc/userguide/ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ assert(minutesRange.implies(fixedMinute) == fixedMinute.impliedBy(minutesRange))

It's important to notice that when using either the `implies` or `impliedBy` operation, if the two nodes are not
parameterized by the same field type, the code won't compile:
```scala mdoc:fail

```scala //mdoc:fail disabled because it breaks mdoc
minutesRange.implies(eachSecond)
```

Expand Down
23 changes: 23 additions & 0 deletions docs/src/main/mdoc/userguide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,26 @@ a `NonEmptyList` with all the validation errors that the expression had. To demo
```scala mdoc
failsValidation.swap.foreach { err => err.asInstanceOf[InvalidCron].reason.toList.mkString("\n") }
```

## Using a specific parser implementation

Cron4s has two parser implementation. Since 0.8.0, it uses the [Atto](https://tpolecat.github.io/atto/) implementation
by default for JS and JVM targets and [Scala Parser Combinators](https://github.com/scala/scala-parser-combinators)
for Native.

You can choose to use the Parser Combinators version by importing cron4s-parserc

```scala
libraryDependencies += "com.github.alonsodomin.cron4s" %%% "cron4s-parserc" % "{{site.cron4sVersion}}"
```

Then you need to specify the parser you want

```scala mdoc:invisible
import scala.annotation.nowarn
```

```scala mdoc:silent
@nowarn("cat=deprecation")
val parser = Cron.withParser(cron4s.parsing.Parser)
```

0 comments on commit ea71d52

Please sign in to comment.