Make .prettyPrint configurable
simonedavico opened this issue · comments
I need to be able to dump my YAML value in double quotes, since I generate strings like container:name==bla
. Right now, there is now way to configure this in moultingyaml
.
Since I am a beginner in Scala, I wanted to discuss the issue first before trying to implement this and make a pull request. I looked at the source code, and the easiest way to me seems to be changing prettyPrint
to accept an Option[DumperOptions]
with default value None
, for compatibility.
What do you say, @jcazevedo? Do you see any drawbacks?
I wouldn't like to expose a SnakeYAML class (i.e. DumperOptions
) through MoultingYAML's interface. I also wouldn't change the prettyPrint
interface. I believe it should be a reasonable default for "pretty printing" YAML documents and shouldn't be configurable.
However, I believe we could have a configurable printer (which might extend YamlValue => String
). We could provide the same options SnakeYAML does, but through our own interface. I'm also not a big fan of having a single object to specify options that is then provided to the printer's constructor. I'd much rather have those options directly in the printer's constructor.
Ok, I understand. A trait maybe?
trait ConfigurablePrinter extends (YamlValue => String) {
def apply(yaml: YamlValue): String = ???
}
Could such a printer be made configurable? I am a beginner in scala and I am not so familiar with traits yet. Shouldn't it extend Configuration => YamlValue => String
?
Ok, I understand. A trait maybe?
It can be a class whose options are supplied in the constructor. I've written a proposal for the interface in #10. Let's move the discussion of the implementation there to avoid duplicating things.
Just merged your changes from #10 and published a snapshot. Thanks!