-
Notifications
You must be signed in to change notification settings - Fork 92
Add new config for PrettyPrinter to minimize empty tags #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
12eab7c
to
89ea693
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
89ea693
to
311f0ef
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
The Junit reports generated by scalatest are considered as invalid when using for instance these xsd: https://github.com/jenkinsci/xunit-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd The problem is that we have "<property ... > </property>" instead of "<property ... />". This is why the Jenkins XUnit plugin does not accept reports from scalatest. This issue had already been raised (see issue scalatest#4 ). Next step would be to fix org.scala.xml.PrettyPrinter which transforms "<a .../>" to "<a ...>\n </a>" when the line is too long. It is possible that the option "minimizeEmpty" from scala/scala-xml#90 will completely fix the issue.
Hello, when the option minimizeEmpty is set to true, is PretttyPrinter still transforming |
@debanne Thanks for the note. This PR is just for providing a method to use the existing feature to minimize empty tags by adding a class parameter to configure as such. If there are existing issues with the pretty printer's behavior, they aren't taken up here. So, the splitting of empty tags, making them open-close tags, and then annoyingly spreading them across two lines: That will need to be a separate issue or PR. Here's one unit test, to get it started, though!:
This assumes I've understood your question. |
311f0ef
to
74147d3
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
74147d3
to
820af8a
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
820af8a
to
95f3f25
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
needs rebase now. other than that, where do we stand, here...? |
95f3f25
to
8e76b70
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
8e76b70
to
f5e8209
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
f5e8209
to
f02b6c2
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
f02b6c2
to
6a4b3e7
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
6a4b3e7
to
ef969da
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
ef969da
to
48a9cfe
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
48a9cfe
to
072001f
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
072001f
to
a8e9085
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
a8e9085
to
2e559bf
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
2e559bf
to
58fc680
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
58fc680
to
287a2bd
Compare
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): New parameter minimizeEmpty. (PrettyPrinter.traverse): Pass config for minimizeTags to Utility.serialize(). * src/test/scala/scala/xml/UtilityTest.scala (issue90): New test. * src/test/scala/scala/xml/XMLTest.scala (issue90): New test.
* src/main/scala/scala/xml/PrettyPrinter.scala (PrettyPrinter): Convert class default parameter to alternate constructor.
287a2bd
to
8c44f6d
Compare
@@ -23,8 +23,11 @@ import Utility.sbToString | |||
* @param width the width to fit the output into | |||
* @param step indentation | |||
*/ | |||
class PrettyPrinter(width: Int, step: Int) { | |||
class PrettyPrinter(width: Int, step: Int, minimizeEmpty: Boolean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please document the expected behaviour when this parameter is set to true? (e.g. in @param
)
This commit containing a unit test was mentioned last year in #46, and I thought the copy constructor using
minimizeEmpty=true
was broken, but it appears scala-xml does the right thing!A new parameter to
PrettyPrinter
is added here for passingminimizeEmpty
to the pretty-printed XML: