Skip to content

Commit 21fdfdf

Browse files
authored
Release PPrint 0.7.0 #73
Updates the readme, pulls in latest version of Fansi 0.3.0, and updates the code accordingly
1 parent 7fead8d commit 21fdfdf

File tree

9 files changed

+42
-17
lines changed

9 files changed

+42
-17
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PPrint [![Gitter Chat][gitter-badge]][gitter-link] [![Build Status][travis-badge]][travis-link]
1+
PPrint [![Gitter Chat][gitter-badge]][gitter-link]
22
===============================================================================================
33

44
[travis-badge]: https://travis-ci.org/lihaoyi/PPrint.svg

build.sc

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trait PPrintModule extends PublishModule with Mima {
4545
trait PPrintMainModule extends CrossScalaModule {
4646
def millSourcePath = super.millSourcePath / offset
4747
def ivyDeps = Agg(
48-
ivy"com.lihaoyi::fansi::0.2.14",
48+
ivy"com.lihaoyi::fansi::0.3.0",
4949
ivy"com.lihaoyi::sourcecode::0.2.7"
5050
)
5151
def compileIvyDeps =

pprint/src-2/TPrintImpl.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ object TPrintLowPri{
178178
}else (
179179
fansi.Str("(") ++
180180
fansi.Str.join(
181-
(left +: many.init.tail.map(typePrintImplRec(c)(_, true)))
182-
.flatMap(Seq(_, fansi.Str(", "))).init:_*
181+
(left +: many.init.tail.map(typePrintImplRec(c)(_, true))),
182+
sep = ", "
183+
183184
) ++
184185
") => " ++ typePrintImplRec(c)(many.last, true),
185186
WrapType.Infix
@@ -188,7 +189,7 @@ object TPrintLowPri{
188189
case TypeRef(pre, sym, args) if tupleTypes.contains(sym.fullName) =>
189190
(
190191
fansi.Str("(") ++
191-
fansi.Str.join(args.map(typePrintImplRec(c)(_, true)).flatMap(Seq(_, fansi.Str(", "))).init:_*) ++
192+
fansi.Str.join(args.map(typePrintImplRec(c)(_, true)), sep = ", ") ++
192193
")",
193194
WrapType.Tuple
194195
)

pprint/src-3/TPrintImpl.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ object TPrintLowPri{
6565
printBounds(lo, hi)
6666
case tpe: TypeRepr =>
6767
rec(tpe, false)
68-
}.flatMap(Seq(_, fansi.Str(", "))).dropRight(1):_*
68+
},
69+
sep = ", "
6970
)
7071
added
7172
}
@@ -114,7 +115,8 @@ object TPrintLowPri{
114115
fansi.Str("type " + name + " = ") ++ rec(tpe)
115116
case (name, TypeBounds(lo, hi)) =>
116117
fansi.Str("type " + name) ++ printBounds(lo, hi) ++ rec(tpe)
117-
}.flatMap(Seq(_, fansi.Str("; "))).dropRight(1):_*
118+
},
119+
sep = "; "
118120
)
119121
(pre ++ (if(refinements.isEmpty) fansi.Str("") else fansi.Str("{") ++ defs ++ "}"), WrapType.NoWrap)
120122
case AnnotatedType(parent, annot) =>

pprint/src/pprint/PPrinter.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ case class PPrinter(defaultWidth: Int = 100,
5858
indent,
5959
escapeUnicode = escapeUnicode,
6060
showFieldNames = showFieldNames
61-
).toSeq:_*
61+
).toSeq
6262
)
6363

6464
println(str)
@@ -84,7 +84,7 @@ case class PPrinter(defaultWidth: Int = 100,
8484
initialOffset,
8585
escapeUnicode = escapeUnicode,
8686
showFieldNames = showFieldNames
87-
).toSeq:_*
87+
).toSeq
8888
)
8989
}
9090

pprint/test/src/test/pprint/AdvancedTests.scala

+9
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ object AdvancedTests extends TestSuite{
208208
assert(rendered.plainText == "null")
209209

210210
}
211+
test("XXX"){
212+
final class Vec2 (val x: Double, val y: Double) extends Product2[Double, Double] {
213+
def _1 = x
214+
def _2 = y
215+
def canEqual(that: Any) = that.isInstanceOf[Vec2]
216+
}
217+
val rendered = Check.color(new Vec2(13, 37))
218+
rendered
219+
}
211220
}
212221

213222

pprint/test/src/test/pprint/Check.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Check(width: Int = 100, height: Int = 99999, renderTwice: Boolean = false,
1717
else Seq(blackWhite, color)
1818
// Make sure we
1919
for (pprinter <- printers){
20-
val pprinted = fansi.Str.join(blackWhite.tokenize(t, width, height).toStream:_*).plainText
20+
val pprinted = fansi.Str.join(blackWhite.tokenize(t, width, height).toStream).plainText
2121

2222
utest.assert(expected.map(_.trim).contains(pprinted))
2323
}

project/Constants.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package pprint
22

33
object Constants {
4-
val version = "0.5.7"
4+
val version = "0.7.0"
55
}

readme/Readme.scalatex

+19-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
ga('send', 'pageview');
2424

2525

26-
@sect{PPrint}
26+
@sect{PPrint 0.7.0}
2727
@img(
2828
src := "Example.png",
2929
alt := "Example use case of PPrint",
@@ -55,13 +55,16 @@
5555

5656
@sect{Getting Started}
5757
@p
58-
Add the following to your SBT config:
58+
Add the following to your build config:
5959
@hl.scala
60+
// SBT
6061
libraryDependencies += "com.lihaoyi" %% "pprint" % "@pprint.Constants.version"
61-
@p
62-
Or for Scala.js/Scala-Native:
63-
@hl.scala
64-
libraryDependencies += "com.lihaoyi" %%% "pprint" % "@pprint.Constants.version"
62+
libraryDependencies += "com.lihaoyi" %%% "pprint" % "@pprint.Constants.version" // Scala.js/Native
63+
64+
// Mill
65+
ivy"com.lihaoyi::pprint:@pprint.Constants.version"
66+
ivy"com.lihaoyi::pprint::@pprint.Constants.version" // Scala.js/Native
67+
6568
@p
6669
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.
6770
@p
@@ -255,6 +258,16 @@
255258
display.block
256259
)
257260
@sect{Version History}
261+
@sect{0.7.0}
262+
@ul
263+
@li
264+
Overhaul and simplify TPrint implementation @lnk("#72", "https://github.com/com-lihaoyi/PPrint/pull/72")
265+
@li
266+
Fix PPrint for Product2 @lnk("#36", "https://github.com/com-lihaoyi/PPrint/pull/36")
267+
@li
268+
Make PPrint robust against @code{toString} returning @code{null} @lnk("#70", "https://github.com/com-lihaoyi/PPrint/pull/70")
269+
@li
270+
Add flag to control unicode escaping @lnk("#71", "https://github.com/com-lihaoyi/PPrint/pull/71")
258271
@sect{0.6.0}
259272
@ul
260273
@li

0 commit comments

Comments
 (0)