From cbae07bb461a1e3f7f2d569d85bf4c2626f4b2f7 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Mon, 27 Sep 2021 08:30:15 +0100 Subject: [PATCH 1/3] Updat metaconfig, publish cli for Scala 3 --- build.sbt | 83 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/build.sbt b/build.sbt index 359969e77..bc1a6476a 100644 --- a/build.sbt +++ b/build.sbt @@ -116,21 +116,36 @@ val V = new { val munit = "0.7.29" val coursier = "1.0.4" val scalacheck = "1.15.4" -} + val kindProjector = "0.13.2" + val evilplot = "0.8.1" -lazy val pprintVersion = Def.setting { - if (scalaVersion.value.startsWith("2.11")) "0.5.4" - else "0.6.0" -} + val flexmark = "0.62.2" + val diffutils = "1.3.0" + val directoryWatcher = "0.15.0" + val undertow = "2.2.10.Final" + val xnio = "3.8.4.Final" + val slf4j = "1.7.32" -lazy val fansiVersion = Def.setting { - if (scalaVersion.value.startsWith("2.11")) "0.2.6" - else "0.2.9" -} + object npm { + val ms = "2.1.1" + } + + def pprint(scalaV: String) = + if (scalaV.startsWith("2.11")) "0.5.4" + else "0.6.0" + + def fansi(scalaV: String) = + if (scalaV.startsWith("2.11")) "0.2.6" + else "0.2.9" + + def fs2(scalaV: String) = + if (scalaV.startsWith("2.11")) "2.1.0" + else "2.5.5" + + def metaconfig(scalaV: String) = + if (scalaV.startsWith("2.11")) "0.9.10" + else "0.9.15" -lazy val fs2Version = Def.setting { - if (scalaVersion.value.startsWith("2.11")) "2.1.0" - else "2.5.5" } lazy val interfaces = project @@ -164,7 +179,7 @@ lazy val runtime = project libraryDependencies ++= crossSetting( scalaVersion.value, if2 = List( - "com.lihaoyi" %% "pprint" % pprintVersion.value, + "com.lihaoyi" %% "pprint" % V.pprint(scalaVersion.value), "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided, "org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided ), @@ -181,13 +196,13 @@ lazy val cli = project .settings( sharedSettings, moduleName := "mdoc-cli", - scalaVersion := scala213, - crossScalaVersions := scala2Versions, libraryDependencies ++= List( "io.get-coursier" % "interface" % V.coursier, - "com.vladsch.flexmark" % "flexmark-all" % "0.62.2", - "org.scalameta" %% "scalameta" % V.scalameta, - "com.geirsson" %% "metaconfig-typesafe-config" % "0.9.10" + "com.vladsch.flexmark" % "flexmark-all" % V.flexmark, + ("org.scalameta" %% "scalameta" % V.scalameta cross CrossVersion.for3Use2_13) + .exclude("com.lihaoyi", "sourcecode_2.13") + .exclude("org.scala-lang.modules", "scala-collection-compat_2.13"), + "com.geirsson" %% "metaconfig-typesafe-config" % V.metaconfig(scalaVersion.value) ) ) @@ -223,17 +238,17 @@ lazy val mdoc = project if2 = List( "org.scala-lang" % "scala-compiler" % scalaVersion.value, "org.scalameta" %% "scalameta" % V.scalameta, - "com.geirsson" %% "metaconfig-typesafe-config" % "0.9.10", - "com.lihaoyi" %% "fansi" % fansiVersion.value + "com.geirsson" %% "metaconfig-typesafe-config" % V.metaconfig(scalaVersion.value), + "com.lihaoyi" %% "fansi" % V.fansi(scalaVersion.value) ) ), libraryDependencies ++= List( - "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0", - "io.methvin" % "directory-watcher" % "0.15.0", + "com.googlecode.java-diff-utils" % "diffutils" % V.diffutils, + "io.methvin" % "directory-watcher" % V.directoryWatcher, // live reload - "io.undertow" % "undertow-core" % "2.2.10.Final", - "org.jboss.xnio" % "xnio-nio" % "3.8.4.Final", - "org.slf4j" % "slf4j-api" % "1.7.32" + "io.undertow" % "undertow-core" % V.undertow, + "org.jboss.xnio" % "xnio-nio" % V.xnio, + "org.slf4j" % "slf4j-api" % V.slf4j ) ) .dependsOn(runtime, cli) @@ -282,7 +297,7 @@ val jsdocs = project ), scalaJSUseMainModuleInitializer := true, Compile / npmDependencies ++= List( - "ms" -> "2.1.1" + "ms" -> V.npm.ms ), webpackBundlingMode := BundlingMode.LibraryOnly() ) @@ -307,11 +322,16 @@ lazy val unit = project Compile / unmanagedSourceDirectories ++= multiScalaDirectories("tests/unit").value, libraryDependencies ++= { if (isScala3.value) List() - else List(compilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")) + else + List( + compilerPlugin( + "org.typelevel" %% "kind-projector" % V.kindProjector cross CrossVersion.full + ) + ) }, scala212LibraryDependencies( List( - "io.github.cibotech" %% "evilplot" % "0.8.1" + "io.github.cibotech" %% "evilplot" % V.evilplot ) ), libraryDependencies ++= List( @@ -320,11 +340,10 @@ lazy val unit = project libraryDependencies ++= crossSetting( scalaVersion.value, if3 = List( - ("co.fs2" %% "fs2-core" % fs2Version.value) - .cross(CrossVersion.for3Use2_13) + "co.fs2" %% "fs2-core" % V.fs2(scalaVersion.value) ), if2 = List( - "co.fs2" %% "fs2-core" % fs2Version.value + "co.fs2" %% "fs2-core" % V.fs2(scalaVersion.value) ) ), buildInfoPackage := "tests.cli", @@ -425,7 +444,7 @@ lazy val docs = project mdocAutoDependency := false, libraryDependencies ++= List( "org.scala-sbt" % "sbt" % sbtVersion.value, - "io.github.cibotech" %% "evilplot" % "0.8.1" + "io.github.cibotech" %% "evilplot" % V.evilplot ), watchSources += (ThisBuild / baseDirectory).value / "docs", Global / cancelable := true, From 91fe2abf7fa939e524b95d412ad4fd67e2cf9297 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 5 Oct 2021 20:48:46 +0100 Subject: [PATCH 2/3] Fixes for pprint rendering? --- .scalafmt.conf | 2 -- build.sbt | 14 +++++------ .../scala/tests/markdown/DefaultSuite.scala | 23 +++++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 68e35e708..444d207cb 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -8,6 +8,4 @@ assumeStandardLibraryStripMargin = true project.excludeFilters = [ "mdoc/src/main/scala-3" "runtime/src/main/scala-3" - "runtime/src/main/scala-0.26" - "runtime/src/main/scala-0.27" ] diff --git a/build.sbt b/build.sbt index bc1a6476a..a2a52c912 100644 --- a/build.sbt +++ b/build.sbt @@ -140,7 +140,7 @@ val V = new { def fs2(scalaV: String) = if (scalaV.startsWith("2.11")) "2.1.0" - else "2.5.5" + else "2.5.9" def metaconfig(scalaV: String) = if (scalaV.startsWith("2.11")) "0.9.10" @@ -190,7 +190,9 @@ lazy val runtime = project ) .dependsOn(interfaces) -val excludePprint = ExclusionRule(organization = "com.lihaoyi") +val excludeSourcecode = ExclusionRule("com.lihaoyi", "sourcecode_2.13") +val excludeCollectionCompat = + ExclusionRule("org.scala-lang.modules", "scala-collection-compat_2.13") lazy val cli = project .settings( @@ -200,8 +202,7 @@ lazy val cli = project "io.get-coursier" % "interface" % V.coursier, "com.vladsch.flexmark" % "flexmark-all" % V.flexmark, ("org.scalameta" %% "scalameta" % V.scalameta cross CrossVersion.for3Use2_13) - .exclude("com.lihaoyi", "sourcecode_2.13") - .exclude("org.scala-lang.modules", "scala-collection-compat_2.13"), + .excludeAll(excludeSourcecode, excludeCollectionCompat), "com.geirsson" %% "metaconfig-typesafe-config" % V.metaconfig(scalaVersion.value) ) ) @@ -231,9 +232,8 @@ lazy val mdoc = project scalaVersion.value, if3 = List( "org.scala-lang" %% "scala3-compiler" % scalaVersion.value, - ("org.scalameta" %% "scalameta" % V.scalameta) - .excludeAll(excludePprint) - .cross(CrossVersion.for3Use2_13) + ("org.scalameta" %% "scalameta" % V.scalameta cross CrossVersion.for3Use2_13) + .excludeAll(excludeSourcecode, excludeCollectionCompat) ), if2 = List( "org.scala-lang" % "scala-compiler" % scalaVersion.value, diff --git a/tests/unit/src/test/scala/tests/markdown/DefaultSuite.scala b/tests/unit/src/test/scala/tests/markdown/DefaultSuite.scala index 6e708843b..605fb6b7c 100644 --- a/tests/unit/src/test/scala/tests/markdown/DefaultSuite.scala +++ b/tests/unit/src/test/scala/tests/markdown/DefaultSuite.scala @@ -136,17 +136,22 @@ class DefaultSuite extends BaseMarkdownSuite { """|```scala |case class User(name: String, age: Int) |User("John", 42) - |// res0: User = User("John", 42) + |// res0: User = User(name = "John", age = 42) |``` - """.stripMargin, + |""".stripMargin, compat = Map( - Compat.Scala213 -> - """|```scala - |case class User(name: String, age: Int) - |User("John", 42) - |// res0: User = User(name = "John", age = 42) - |``` - |""".stripMargin + Compat.Scala212 -> """|```scala + |case class User(name: String, age: Int) + |User("John", 42) + |// res0: User = User("John", 42) + |``` + """.stripMargin, + Compat.Scala211 -> """|```scala + |case class User(name: String, age: Int) + |User("John", 42) + |// res0: User = User("John", 42) + |``` + """.stripMargin ) ) From 20f721eb1b1450ffd1e5efd1786b0121d8d153e1 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 5 Oct 2021 20:55:09 +0100 Subject: [PATCH 3/3] Scala 3 stuff is pretty printed now --- .../scala/tests/cli/ScalacOptionsSuite.scala | 2 +- .../scala/tests/markdown/SemanticsSuite.scala | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/unit/src/test/scala/tests/cli/ScalacOptionsSuite.scala b/tests/unit/src/test/scala/tests/cli/ScalacOptionsSuite.scala index d37af6a07..1ce5bf5dd 100644 --- a/tests/unit/src/test/scala/tests/cli/ScalacOptionsSuite.scala +++ b/tests/unit/src/test/scala/tests/cli/ScalacOptionsSuite.scala @@ -200,7 +200,7 @@ class ScalacOptionsSuite extends BaseCliSuite { |final case class Test(value: Int) | |val test = Test(123) - |// test: Test = Test(123) + |// test: Test = Test(value = 123) | |test.value |// res0: Int = 123 diff --git a/tests/unit/src/test/scala/tests/markdown/SemanticsSuite.scala b/tests/unit/src/test/scala/tests/markdown/SemanticsSuite.scala index 261dda59f..eea7bbd19 100644 --- a/tests/unit/src/test/scala/tests/markdown/SemanticsSuite.scala +++ b/tests/unit/src/test/scala/tests/markdown/SemanticsSuite.scala @@ -37,21 +37,23 @@ class SemanticsSuite extends BaseMarkdownSuite { | implicit val ordering: Ordering[User] = Ordering.by(_.name) |} |List(User("Susan"), User("John")).sorted - |// res0: List[User] = List(User("John"), User("Susan")) + |// res0: List[User] = List(User(name = "John"), User(name = "Susan")) |``` - """.stripMargin, - compat = Map( - Compat.Scala213 -> + |""".stripMargin, + compat = { + val oldScalaOutput = """|```scala |case class User(name: String) |object User { | implicit val ordering: Ordering[User] = Ordering.by(_.name) |} |List(User("Susan"), User("John")).sorted - |// res0: List[User] = List(User(name = "John"), User(name = "Susan")) + |// res0: List[User] = List(User("John"), User("Susan")) |``` - |""".stripMargin - ) + """.stripMargin + + Map(Compat.Scala212 -> oldScalaOutput, Compat.Scala211 -> oldScalaOutput) + } ) check(