Skip to content

Commit

Permalink
Merge pull request #151 from tgodzik/bump-pprint
Browse files Browse the repository at this point in the history
Bump pprint to 0.7.1
  • Loading branch information
tgodzik authored Jan 14, 2022
2 parents 5a5097a + 60c3953 commit e5f4acf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ jobs:
- run: ./bin/scalafmt --check
- run: sbt scalafixCheckAll
- run: sbt coreJVM/mimaReportBinaryIssues
- run: sbt docs/docusaurusCreateSite
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: olafurpg/setup-scala@v13
- uses: olafurpg/setup-gpg@v3
- name: Publish ${{ github.ref }}
run: sbt ci-release docs/docusaurusPublishGhpages
run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
Expand Down
8 changes: 3 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
moduleName := "metaconfig-core",
libraryDependencies ++= List(
"org.typelevel" %%% "paiges-core" % "0.4.2",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.5.0"
) :+ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => "com.lihaoyi" %%% "pprint" % "0.5.4"
case _ => "com.lihaoyi" %%% "pprint" % "0.6.6"
})
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.5.0",
"com.lihaoyi" %%% "pprint" % "0.7.1"
)
)
.settings(
libraryDependencies += {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class Macros(val c: blackbox.Context) {

val field = q"""new ${weakTypeOf[Field]}(
${param.name.decodedName.toString},
$tpeString.render,
$tpeString.render.render,
_root_.scala.List.apply(..$finalAnnots),
$underlying
)"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private[generic] def deriveSurfaceImpl[T: Type](using q: Quotes) =
fieldType.asType match
case '[t] =>
val renderer = Expr.summon[pprint.TPrint[t]].get
'{ $renderer.render }
'{ $renderer.render.render }

val fieldExpr = '{
new Field($fieldName, $tpeString, $finalAnnots, $underlying)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package metaconfig
import java.io.File
import metaconfig.generic.Settings
import metaconfig.generic.Surface
import pprint.TPrintColors

class DeriveSurfaceSuite extends munit.FunSuite {

Expand Down Expand Up @@ -76,13 +77,20 @@ class DeriveSurfaceSuite extends munit.FunSuite {
case class CustomTypePrinting(a: Int, b: Option[Int], c: List[String])
test("tprint") {
import pprint.TPrint
implicit val intPrint = TPrint.literal[Int]("number")
implicit val intPrint = new TPrint[Int] {
def render(implicit tpc: TPrintColors): fansi.Str = fansi.Str("number")
}
implicit def optionPrint[T](implicit ev: TPrint[T]): TPrint[Option[T]] =
TPrint.make { implicit colors => "(" + ev.render + ")" }
new TPrint[Option[T]] {
def render(implicit tpc: TPrintColors): fansi.Str =
"(" + ev.render + ")"
}
implicit def iterablePrint[C[x] <: Iterable[x], T](
implicit ev: TPrint[T]
): TPrint[C[T]] =
TPrint.make { implicit colors => "[" + ev.render + " ...]" }
): TPrint[C[T]] = new TPrint[C[T]] {
def render(implicit tpc: TPrintColors): fansi.Str =
"[" + ev.render + " ...]"
}
implicit val surface = generic.deriveSurface[CustomTypePrinting]
val a :: b :: c :: Nil = Settings[CustomTypePrinting].settings
assertEquals(a.tpe, "number")
Expand Down

0 comments on commit e5f4acf

Please sign in to comment.