From 77d1ab9c87ef0a8c9e1097d2182b574138c7e477 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Wed, 28 Aug 2024 10:03:10 +1000 Subject: [PATCH] Update docs with the newly added feature (i.e. `DecVer`) --- build.sbt | 1 + docs/decver/_category_.json | 6 + docs/decver/decver.md | 147 ++++++++++++++++++ docs/intro.md | 61 +++++++- docs/{how-to-use => semver}/_category_.json | 2 +- .../how-to-use.md => semver/semver.md} | 4 +- website/docusaurus.config.ts | 2 +- website/src/pages/versionsArchived.json | 8 + 8 files changed, 222 insertions(+), 9 deletions(-) create mode 100644 docs/decver/_category_.json create mode 100644 docs/decver/decver.md rename docs/{how-to-use => semver}/_category_.json (72%) rename docs/{how-to-use/how-to-use.md => semver/semver.md} (98%) diff --git a/build.sbt b/build.sbt index dba9f1e..d3f4d22 100644 --- a/build.sbt +++ b/build.sbt @@ -122,6 +122,7 @@ lazy val docs = (project in file("docs-gen-tmp/docs")) List( "io.kevinlee" %%% "just-semver-core" % latestVersion, + "io.kevinlee" %%% "just-semver-decver" % latestVersion, ) }, mdocVariables := Map( diff --git a/docs/decver/_category_.json b/docs/decver/_category_.json new file mode 100644 index 0000000..b6a3c8e --- /dev/null +++ b/docs/decver/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "DecVer", + "position": 3, + "collapsible": true, + "collapsed": false +} diff --git a/docs/decver/decver.md b/docs/decver/decver.md new file mode 100644 index 0000000..ed88680 --- /dev/null +++ b/docs/decver/decver.md @@ -0,0 +1,147 @@ + +# DecVer (Decimal Version) + +## `DecVer.parse` + +```scala mdoc:reset-object +import just.decver.DecVer + +val v = DecVer.parse("1.0") + +// To render it to `String`, +v.map(_.render) + +// Invalid version +DecVer.parse("a1.0") + +// Invalid version +DecVer.parse("a1.0.0") + +``` + +## `DecVer.unsafeParse` + +```scala mdoc:reset-object +import just.decver.DecVer + +// parse unsafe - NOT RECOMMENDED!!! +val v = DecVer.unsafeParse("1.0") + +// to String +v.render +``` + +```scala mdoc:crash + +// Invalid version +DecVer.unsafeParse("a1.0") +``` + +## DecVer with `pre-release` info +```scala mdoc:reset-object +import just.decver.DecVer + +DecVer.parse("1.0-beta1") + +val v = DecVer.parse("1.0-3.123.9a") + +v.map(_.render) +``` + +## DecVer with build `meta-info` +```scala mdoc:reset-object +import just.decver.DecVer + +val v = DecVer.parse("1.0+100.0.12abc") + +v.map(_.render) +``` + +## DecVer with `pre-release` info and build `meta-info` +```scala mdoc:reset-object +import just.decver.DecVer + +DecVer.parse("1.0-beta1") + +val v = DecVer.parse("1.0-3.123.9a+100.0.12abc") + +v.map(_.render) +``` + +## Compare `DecVer` +```scala mdoc:reset-object +import just.decver.DecVer + +for { + a <- DecVer.parse("1.0") + b <- DecVer.parse("1.1") +} yield a < b + +for { + a <- DecVer.parse("1.1") + b <- DecVer.parse("1.0") +} yield a < b + +for { + a <- DecVer.parse("1.0") + b <- DecVer.parse("1.1") +} yield a <= b + +for { + a <- DecVer.parse("1.0") + b <- DecVer.parse("1.0") +} yield a <= b + +for { + a <- DecVer.parse("1.0") + b <- DecVer.parse("1.0") +} yield a == b + +for { + a <- DecVer.parse("1.1") + b <- DecVer.parse("1.0") +} yield a > b + +for { + a <- DecVer.parse("1.0") + b <- DecVer.parse("1.1") +} yield a > b + +for { + a <- DecVer.parse("1.0") + b <- DecVer.parse("1.1") +} yield a >= b + +for { + a <- DecVer.parse("1.0") + b <- DecVer.parse("1.0") +} yield a >= b + +for { + a <- DecVer.parse("1.1") + b <- DecVer.parse("1.0") +} yield a >= b +``` + +## Matchers +```scala mdoc +DecVer.unsafeParse("1.0").unsafeMatches("1.0 - 2.0") +DecVer.unsafeParse("1.5").unsafeMatches("1.0 - 2.0") +DecVer.unsafeParse("2.0").unsafeMatches("1.0 - 2.0") +DecVer.unsafeParse("0.9").unsafeMatches("1.0 - 2.0") +DecVer.unsafeParse("2.1").unsafeMatches("1.0 - 2.0") + +DecVer.unsafeParse("1.0").unsafeMatches(">1.0 <2.0") +DecVer.unsafeParse("1.0").unsafeMatches(">=1.0 <=2.0") +DecVer.unsafeParse("1.5").unsafeMatches(">1.0 <2.0") +DecVer.unsafeParse("2.0").unsafeMatches(">1.0 <2.0") +DecVer.unsafeParse("2.0").unsafeMatches(">=1.0 <=2.0") +DecVer.unsafeParse("0.9").unsafeMatches(">=1.0 <=2.0") +DecVer.unsafeParse("2.1").unsafeMatches(">=1.0 <=2.0") + +DecVer.unsafeParse("1.0").unsafeMatches("1.0 - 2.0 || >3.0 <4.0") +DecVer.unsafeParse("2.0").unsafeMatches("1.0 - 2.0 || >3.0 <4.0") +DecVer.unsafeParse("3.0").unsafeMatches("1.0 - 2.0 || >3.0 <=4.0") +DecVer.unsafeParse("3.1").unsafeMatches("1.0 - 2.0 || >3.0 <=4.0") +DecVer.unsafeParse("4.0").unsafeMatches("1.0 - 2.0 || >3.0 <=4.0") +``` diff --git a/docs/intro.md b/docs/intro.md index 3b5a330..66e35ef 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -8,7 +8,7 @@ slug: '/' [![Build Status](https://github.com/Kevin-Lee/just-semver/workflows/Build%20All/badge.svg)](https://github.com/Kevin-Lee/just-semver/actions?workflow=Build+All) [![Release Status](https://github.com/Kevin-Lee/just-semver/workflows/Release/badge.svg)](https://github.com/Kevin-Lee/just-semver/actions?workflow=Release) -[![Coverage Status](https://coveralls.io/repos/github/Kevin-Lee/just-semver/badge.svg?branch=master)](https://coveralls.io/github/Kevin-Lee/just-semver?branch=master) +[![codecov](https://codecov.io/gh/kevin-lee/just-semver/graph/badge.svg?token=SO5LB2BWOL)](https://codecov.io/gh/kevin-lee/just-semver) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.kevinlee/just-semver_2.13/badge.svg)](https://search.maven.org/artifact/io.kevinlee/just-semver_2.13) [![Latest version](https://index.scala-lang.org/kevin-lee/just-semver/just-semver/latest.svg)](https://index.scala-lang.org/kevin-lee/just-semver/just-semver) @@ -26,14 +26,15 @@ Show [**all `just-semver` versions**](https://index.scala-lang.org/kevin-lee/jus ### `@VERSION@` -```scala -"io.kevinlee" %% "just-semver-core" % "@VERSION@" -``` - [![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.11.0.svg)](https://www.scala-js.org) Since `0.6.0` `just-semver` supports Scala.js. +#### Core +```scala +"io.kevinlee" %% "just-semver-core" % "@VERSION@" +``` + ```scala "io.kevinlee" %%% "just-semver-core" % "@VERSION@" ``` @@ -47,8 +48,58 @@ libraryDependencies += "io.kevinlee" %% "just-semver-core" % "@VERSION@" libraryDependencies += "io.kevinlee" %%% "just-semver-core" % "@VERSION@" ``` + +#### DecVer: Decimal version module +```scala +"io.kevinlee" %% "just-semver-decver" % "@VERSION@" +``` + +```scala +"io.kevinlee" %%% "just-semver-decver" % "@VERSION@" +``` + + +e.g.) +```scala +libraryDependencies += "io.kevinlee" %% "just-semver-decver" % "@VERSION@" +``` +```scala +libraryDependencies += "io.kevinlee" %%% "just-semver-decver" % "@VERSION@" +``` + +#### All modules + +```scala +"io.kevinlee" %% "just-semver-core" % "@VERSION@", +"io.kevinlee" %% "just-semver-decver" % "@VERSION@", +``` + +```scala +"io.kevinlee" %%% "just-semver-core" % "@VERSION@", +"io.kevinlee" %%% "just-semver-decver" % "@VERSION@", +``` + +```scala +libraryDependencies ++= Seq( + "io.kevinlee" %% "just-semver-core" % "@VERSION@", + "io.kevinlee" %% "just-semver-decver" % "@VERSION@", +) +``` +```scala +libraryDependencies ++= Seq( + "io.kevinlee" %%% "just-semver-core" % "@VERSION@", + "io.kevinlee" %%% "just-semver-decver" % "@VERSION@", +) +``` + + + ## Older Versions +### `0.13.0` + +### `0.12.0` + ### `0.11.0` :::info diff --git a/docs/how-to-use/_category_.json b/docs/semver/_category_.json similarity index 72% rename from docs/how-to-use/_category_.json rename to docs/semver/_category_.json index e7ace25..95f3c4d 100644 --- a/docs/how-to-use/_category_.json +++ b/docs/semver/_category_.json @@ -1,5 +1,5 @@ { - "label": "How to use", + "label": "SemVer", "position": 2, "collapsible": true, "collapsed": false diff --git a/docs/how-to-use/how-to-use.md b/docs/semver/semver.md similarity index 98% rename from docs/how-to-use/how-to-use.md rename to docs/semver/semver.md index 86cfb1c..ab30589 100644 --- a/docs/how-to-use/how-to-use.md +++ b/docs/semver/semver.md @@ -1,5 +1,5 @@ -# How to Use +# SemVer (Semantic Version) :::caution NOTE For now, please do not use any types and methods from the package other than `just.semver`. @@ -71,7 +71,7 @@ val v = SemVer.parse("1.0.0-3.123.9a+100.0.12abc") v.map(_.render) ``` -## Compare `SamVer` +## Compare `SemVer` ```scala mdoc:reset-object import just.semver.SemVer diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index 63e40f1..ce3756c 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -24,7 +24,7 @@ const classicConfig = { lastVersion: 'current', "versions": { "current": { - "label": "0.13.0" + "label": "1.0.0" }, } // Please change this to your repo. diff --git a/website/src/pages/versionsArchived.json b/website/src/pages/versionsArchived.json index 69de431..f4f4c6b 100644 --- a/website/src/pages/versionsArchived.json +++ b/website/src/pages/versionsArchived.json @@ -1,4 +1,12 @@ [ + { + "name": "0.13.0", + "label": "0.13.0" + }, + { + "name": "0.12.0", + "label": "0.12.0" + }, { "name": "0.11.0", "label": "0.11.0"