Skip to content

Commit

Permalink
Release PPrint 0.7.0 #73
Browse files Browse the repository at this point in the history
Updates the readme, pulls in latest version of Fansi 0.3.0, and updates the code accordingly
  • Loading branch information
lihaoyi authored Dec 11, 2021
1 parent 7fead8d commit 21fdfdf
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
7 changes: 4 additions & 3 deletions pprint/src-2/TPrintImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down
6 changes: 4 additions & 2 deletions pprint/src-3/TPrintImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ object TPrintLowPri{
printBounds(lo, hi)
case tpe: TypeRepr =>
rec(tpe, false)
}.flatMap(Seq(_, fansi.Str(", "))).dropRight(1):_*
},
sep = ", "
)
added
}
Expand Down Expand Up @@ -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) =>
Expand Down
4 changes: 2 additions & 2 deletions pprint/src/pprint/PPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ case class PPrinter(defaultWidth: Int = 100,
indent,
escapeUnicode = escapeUnicode,
showFieldNames = showFieldNames
).toSeq:_*
).toSeq
)

println(str)
Expand All @@ -84,7 +84,7 @@ case class PPrinter(defaultWidth: Int = 100,
initialOffset,
escapeUnicode = escapeUnicode,
showFieldNames = showFieldNames
).toSeq:_*
).toSeq
)
}

Expand Down
9 changes: 9 additions & 0 deletions pprint/test/src/test/pprint/AdvancedTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}


Expand Down
2 changes: 1 addition & 1 deletion pprint/test/src/test/pprint/Check.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion project/Constants.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package pprint

object Constants {
val version = "0.5.7"
val version = "0.7.0"
}
25 changes: 19 additions & 6 deletions readme/Readme.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
ga('send', 'pageview');


@sect{PPrint}
@sect{PPrint 0.7.0}
@img(
src := "Example.png",
alt := "Example use case of PPrint",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 21fdfdf

Please sign in to comment.