From 893e6cad56301ee95cf45a83277dfcc7668fd624 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Fri, 18 Oct 2024 16:23:32 +0200 Subject: [PATCH] Use sbt-mdoc, update mdoc to 2.6.1 (#55) --- .github/workflows/ci.yml | 19 +++++++++++++- README.md | 57 +++++++++++++++++++++++++++++----------- build.sbt | 7 +++-- project/plugins.sbt | 1 + 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70f1bc3..203465d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,24 @@ jobs: jvm: 8 - name: Compile - run: sbt +test +mimaReportBinaryIssues "readme/run --check" + run: sbt +test +mimaReportBinaryIssues + + readme: + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: coursier/cache-action@v6 + - uses: coursier/setup-action@v1 + with: + jvm: 17 + + - name: Compile + run: sbt readme/mdoc publish: needs: test diff --git a/README.md b/README.md index 1101c22..1f8ca4a 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ Version parsing and comparison is handled by `coursier.version.Version`. Parse a version with ```scala val version = Version("1.2.0-RC3") -// version: Version = Version("1.2.0-RC3") +// version: Version = Version(repr = "1.2.0-RC3") val items = version.items // items: Vector[Version.Item] = Vector( -// Number(1), -// Number(2), -// Number(0), -// Tag("rc"), -// Number(3) +// Number(value = 1), +// Number(value = 2), +// Number(value = 0), +// Tag(value = "rc"), +// Number(value = 3) // ) ``` @@ -71,18 +71,33 @@ Parse a version constraint with ```scala val intervalConstraint = VersionParse.versionConstraint("[1.2,1.3)") // intervalConstraint: VersionConstraint = VersionConstraint( -// VersionInterval(Some(Version("1.2")), Some(Version("1.3")), true, false), -// List() +// interval = VersionInterval( +// from = Some(value = Version(repr = "1.2")), +// to = Some(value = Version(repr = "1.3")), +// fromIncluded = true, +// toIncluded = false +// ), +// preferred = List() // ) val intervalSelectorConstraint = VersionParse.versionConstraint("1.2+") // intervalSelectorConstraint: VersionConstraint = VersionConstraint( -// VersionInterval(Some(Version("1.2")), Some(Version("1.2.max")), true, true), -// List() +// interval = VersionInterval( +// from = Some(value = Version(repr = "1.2")), +// to = Some(value = Version(repr = "1.2.max")), +// fromIncluded = true, +// toIncluded = true +// ), +// preferred = List() // ) val simpleVersionConstraint = VersionParse.versionConstraint("1.4.2") // simpleVersionConstraint: VersionConstraint = VersionConstraint( -// VersionInterval(None, None, false, false), -// List(Version("1.4.2")) +// interval = VersionInterval( +// from = None, +// to = None, +// fromIncluded = false, +// toIncluded = false +// ), +// preferred = List(Version(repr = "1.4.2")) // ) ``` @@ -94,7 +109,11 @@ Like for versions, parsing is meant to be very loose, trying to make sense of an `ModuleMatcher` aims at representing glob-based module matchers, like ```scala val matcher = ModuleMatcher("org.scala-lang.modules", "*") -// matcher: ModuleMatcher = ModuleMatcher("org.scala-lang.modules", "*", Map()) +// matcher: ModuleMatcher = ModuleMatcher( +// organizationMatcher = "org.scala-lang.modules", +// nameMatcher = "*", +// attributeMatchers = Map() +// ) val matchesScalaXml = matcher.matches("org.scala-lang.modules", "scala-xml_2.13") // matchesScalaXml: Boolean = true val matchesCoursier = matcher.matches("io.get-coursier", "coursier_2.13") @@ -114,9 +133,15 @@ val allButScalaLib = ModuleMatchers( includeByDefault = true ) // allButScalaLib: ModuleMatchers = ModuleMatchers( -// Set(ModuleMatcher("org.scala-lang", "scala-library", Map())), -// Set(), -// true +// exclude = Set( +// ModuleMatcher( +// organizationMatcher = "org.scala-lang", +// nameMatcher = "scala-library", +// attributeMatchers = Map() +// ) +// ), +// include = Set(), +// includeByDefault = true // ) val notScalaLib = allButScalaLib.matches("io.get-coursier", "coursier_2.13") // notScalaLib: Boolean = true diff --git a/build.sbt b/build.sbt index e9cdbe3..6c4760f 100644 --- a/build.sbt +++ b/build.sbt @@ -60,13 +60,12 @@ lazy val versionsJS = versions.js lazy val readme = project .dependsOn(versionsJVM) .disablePlugins(MimaPlugin) + .enablePlugins(MdocPlugin) .settings( shared, (publish / skip) := true, - (run / fork) := true, - (Compile / run / forkOptions) := (Compile / run / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value), - libraryDependencies += "org.scalameta" %% "mdoc" % "2.2.2", - watchTriggers += ((ThisBuild / baseDirectory).value / "README.template.md").toGlob + mdocIn := (ThisBuild / baseDirectory).value / "README.template.md", + mdocOut := (ThisBuild / baseDirectory).value / "README.md" ) crossScalaVersions := Nil diff --git a/project/plugins.sbt b/project/plugins.sbt index 3ef9f09..967b7d6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,5 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.8.0") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.1" ) addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.20") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.17.0")