diff --git a/README.md b/README.md index 9658381..0dfa77b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -PPrint [![Gitter Chat][gitter-badge]][gitter-link] [![Build Status][travis-badge]][travis-link] +PPrint [![Gitter Chat][gitter-badge]][gitter-link] =============================================================================================== [travis-badge]: https://travis-ci.org/lihaoyi/PPrint.svg diff --git a/build.sc b/build.sc index 709b030..7b37c27 100644 --- a/build.sc +++ b/build.sc @@ -45,7 +45,7 @@ trait PPrintModule extends PublishModule with Mima { trait PPrintMainModule extends CrossScalaModule { def millSourcePath = super.millSourcePath / offset def ivyDeps = Agg( - ivy"com.lihaoyi::fansi::0.2.14", + ivy"com.lihaoyi::fansi::0.3.0", ivy"com.lihaoyi::sourcecode::0.2.7" ) def compileIvyDeps = diff --git a/pprint/src-2/TPrintImpl.scala b/pprint/src-2/TPrintImpl.scala index 020bdfb..48acc3a 100644 --- a/pprint/src-2/TPrintImpl.scala +++ b/pprint/src-2/TPrintImpl.scala @@ -178,8 +178,9 @@ object TPrintLowPri{ }else ( fansi.Str("(") ++ fansi.Str.join( - (left +: many.init.tail.map(typePrintImplRec(c)(_, true))) - .flatMap(Seq(_, fansi.Str(", "))).init:_* + (left +: many.init.tail.map(typePrintImplRec(c)(_, true))), + sep = ", " + ) ++ ") => " ++ typePrintImplRec(c)(many.last, true), WrapType.Infix @@ -188,7 +189,7 @@ object TPrintLowPri{ case TypeRef(pre, sym, args) if tupleTypes.contains(sym.fullName) => ( fansi.Str("(") ++ - fansi.Str.join(args.map(typePrintImplRec(c)(_, true)).flatMap(Seq(_, fansi.Str(", "))).init:_*) ++ + fansi.Str.join(args.map(typePrintImplRec(c)(_, true)), sep = ", ") ++ ")", WrapType.Tuple ) diff --git a/pprint/src-3/TPrintImpl.scala b/pprint/src-3/TPrintImpl.scala index 0ef84cf..54b7524 100644 --- a/pprint/src-3/TPrintImpl.scala +++ b/pprint/src-3/TPrintImpl.scala @@ -65,7 +65,8 @@ object TPrintLowPri{ printBounds(lo, hi) case tpe: TypeRepr => rec(tpe, false) - }.flatMap(Seq(_, fansi.Str(", "))).dropRight(1):_* + }, + sep = ", " ) added } @@ -114,7 +115,8 @@ object TPrintLowPri{ fansi.Str("type " + name + " = ") ++ rec(tpe) case (name, TypeBounds(lo, hi)) => fansi.Str("type " + name) ++ printBounds(lo, hi) ++ rec(tpe) - }.flatMap(Seq(_, fansi.Str("; "))).dropRight(1):_* + }, + sep = "; " ) (pre ++ (if(refinements.isEmpty) fansi.Str("") else fansi.Str("{") ++ defs ++ "}"), WrapType.NoWrap) case AnnotatedType(parent, annot) => diff --git a/pprint/src/pprint/PPrinter.scala b/pprint/src/pprint/PPrinter.scala index c4e0699..3d88fb4 100644 --- a/pprint/src/pprint/PPrinter.scala +++ b/pprint/src/pprint/PPrinter.scala @@ -58,7 +58,7 @@ case class PPrinter(defaultWidth: Int = 100, indent, escapeUnicode = escapeUnicode, showFieldNames = showFieldNames - ).toSeq:_* + ).toSeq ) println(str) @@ -84,7 +84,7 @@ case class PPrinter(defaultWidth: Int = 100, initialOffset, escapeUnicode = escapeUnicode, showFieldNames = showFieldNames - ).toSeq:_* + ).toSeq ) } diff --git a/pprint/test/src/test/pprint/AdvancedTests.scala b/pprint/test/src/test/pprint/AdvancedTests.scala index e995771..b4ecacf 100644 --- a/pprint/test/src/test/pprint/AdvancedTests.scala +++ b/pprint/test/src/test/pprint/AdvancedTests.scala @@ -208,6 +208,15 @@ object AdvancedTests extends TestSuite{ assert(rendered.plainText == "null") } + test("XXX"){ + final class Vec2 (val x: Double, val y: Double) extends Product2[Double, Double] { + def _1 = x + def _2 = y + def canEqual(that: Any) = that.isInstanceOf[Vec2] + } + val rendered = Check.color(new Vec2(13, 37)) + rendered + } } diff --git a/pprint/test/src/test/pprint/Check.scala b/pprint/test/src/test/pprint/Check.scala index f870e8e..66d6999 100644 --- a/pprint/test/src/test/pprint/Check.scala +++ b/pprint/test/src/test/pprint/Check.scala @@ -17,7 +17,7 @@ class Check(width: Int = 100, height: Int = 99999, renderTwice: Boolean = false, else Seq(blackWhite, color) // Make sure we for (pprinter <- printers){ - val pprinted = fansi.Str.join(blackWhite.tokenize(t, width, height).toStream:_*).plainText + val pprinted = fansi.Str.join(blackWhite.tokenize(t, width, height).toStream).plainText utest.assert(expected.map(_.trim).contains(pprinted)) } diff --git a/project/Constants.scala b/project/Constants.scala index d95c643..1858327 100644 --- a/project/Constants.scala +++ b/project/Constants.scala @@ -1,5 +1,5 @@ package pprint object Constants { - val version = "0.5.7" + val version = "0.7.0" } diff --git a/readme/Readme.scalatex b/readme/Readme.scalatex index b27acaf..c5ced88 100644 --- a/readme/Readme.scalatex +++ b/readme/Readme.scalatex @@ -23,7 +23,7 @@ ga('send', 'pageview'); -@sect{PPrint} +@sect{PPrint 0.7.0} @img( src := "Example.png", alt := "Example use case of PPrint", @@ -55,13 +55,16 @@ @sect{Getting Started} @p - Add the following to your SBT config: + Add the following to your build config: @hl.scala + // SBT libraryDependencies += "com.lihaoyi" %% "pprint" % "@pprint.Constants.version" - @p - Or for Scala.js/Scala-Native: - @hl.scala - libraryDependencies += "com.lihaoyi" %%% "pprint" % "@pprint.Constants.version" + libraryDependencies += "com.lihaoyi" %%% "pprint" % "@pprint.Constants.version" // Scala.js/Native + + // Mill + ivy"com.lihaoyi::pprint:@pprint.Constants.version" + ivy"com.lihaoyi::pprint::@pprint.Constants.version" // Scala.js/Native + @p The above example then showed how to use the default pprint configuration. You can also set up your own custom implicit `pprint.Config` if you want to control e.g. colors, width, or max-height of the output. @p @@ -255,6 +258,16 @@ display.block ) @sect{Version History} + @sect{0.7.0} + @ul + @li + Overhaul and simplify TPrint implementation @lnk("#72", "https://github.com/com-lihaoyi/PPrint/pull/72") + @li + Fix PPrint for Product2 @lnk("#36", "https://github.com/com-lihaoyi/PPrint/pull/36") + @li + Make PPrint robust against @code{toString} returning @code{null} @lnk("#70", "https://github.com/com-lihaoyi/PPrint/pull/70") + @li + Add flag to control unicode escaping @lnk("#71", "https://github.com/com-lihaoyi/PPrint/pull/71") @sect{0.6.0} @ul @li