Skip to content

Commit

Permalink
Use sbt-mdoc, update mdoc to 2.6.1 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Oct 18, 2024
1 parent 79a7279 commit 893e6ca
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 21 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 41 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
// )
```

Expand Down Expand Up @@ -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"))
// )
```

Expand All @@ -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")
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 893e6ca

Please sign in to comment.