-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Dumping broken in way too many ways #140
Comments
Though the canonical output is certainly not pretty, it is valid YAML and the only problem with it is that NimYAML cannot parse it (which, admittedly, is bad). Can you explain what you think is „broken“ here? Possibly canonical is a bad term here. The YAML specification, in version 1.2.1, named this explanatory format:
The revised YAML version 1.2.2 doesn't mention or use this format anymore. I inherited the term canonical form for this format from PyYAML but did not realize that it isn't a term from the specification, which uses the term canonical form only for representation of scalars. In any case, it's a format designed for debugging and inspection, not for production use. The configuration you get via dumper.presentation.quoting = sqUnset # Supposed to be the default, but if unset by library user, everything is force quoted. It would be the default if you used the default values (via So there are three implementation issues I see here:
Also did you try using Does this sum up your complaints? Thanks for reporting! |
I remember, that the tags stuff was already some particularly YAML specific stuff, so I had the thought, this might be the case here, as well, but when I further inspected the output, it was utterly clear to me, that this would never ever be a type of output anyone would use in a scenario, where the user gets to see it. Therefore, it was natural to me to (apparently falsely) assume, that this must be either some intermediate step during the serialisation, where you did not apply the last step by serialising it as actual YAML or at best it could be some form of debug output. Otherwise, have never seen this before and I don't see any use case for it, other than behind the scenes technical exchange of data, which is never seen by any human eyes.
Realised this, after posting the issue. Indeed!
...
Like a hughmonguous one. All I found was this Dumping API Example. Now, after looking at this page again, I realised, that Dumper is mentioned several times there. So, just checked out "Dumping API" & saw this All the rest was me checking out NimYAML's source code, manually. It'd be nice to have a big documentation example of the "default" Dumper object & then some big example of a highly customised Of course, I'd be willing to add this documentation!
With your work, it's never a complaint, it's always trying to help you progress with your project. 🙂 I think, this is now "resolved" as in, I got the message & fully understand what you're saying. I'm closing this issue & if you say, I should work on examples for the documentation, then I'll open another issue. Thank you very much, as always. 😃 |
* certain configurations of the Dumper added twice the requested indentation. * ref #140
* verbatim tags containing '[', ']' or ',' were not properly parsed in flow style collections * ref #140
Can you tell me how you generated the Unquoted JSON stuff? I have trouble reproducing the error that emits block scalars in flow style. Regarding the documentation, well, the first example in the Quickstart on the main page uses In case you're interested why you got additional newlines: When you set |
* ensure no block scalars (literal, folded) are output inside of flow collections * ref #140
Indeed. I am currently tweaking my
I see, now. The thing is, that I didn't remember how lazy you made the defaults, so I was oriented towards "migrating" from my lazy configuration, to the "new" lazy configuration, so I just omitted the "Quickstart" section, as I expected no specific configuration there, which, I feared, would've not been the lazy dumping I want. Lazy, as in no tags, no nothing. Just the slim YAML.
import pkg/yaml
var dumper = minimalDumper()
# https://github.com/flyx/NimYAML/blob/854d33378e2b31ada7e54716439a4d6990460268/yaml/presenter.nim#L69-L80
dumper.presentation.containers = cBlock # Without it, broken output, too.
dumper.presentation.outputVersion = ovNone
dumper.presentation.newlines = nlLF
dumper.presentation.indentationStep = 1 # Have to set 1, to get an indentation of 2 spaces.
dumper.presentation.condenseFlow = false # Must be false to not break output.
dumper.presentation.suppressAttrs = false
dumper.presentation.directivesEnd = deNever
dumper.presentation.quoting = sqUnset # Supposed to be the default, but if unset by library user, everything is force quoted.
dumper.serialization.tagStyle = tsNone
dumper.serialization.handles = @[]
dumper.dump(config, fStream)
Nevermind. Just checked file history timestamps & wasn't difficult to find. Thanks Visual Studio Code Local History! var dumper = minimalDumper()
# https://github.com/flyx/NimYAML/blob/854d33378e2b31ada7e54716439a4d6990460268/yaml/presenter.nim#L69-L80
# it.presentation.containers = cBlock
dumper.presentation.outputVersion = ovNone
dumper.presentation.newlines = nlLF
dumper.presentation.indentationStep = 1
dumper.presentation.condenseFlow = false
dumper.presentation.suppressAttrs = false
dumper.presentation.directivesEnd = deNever
dumper.presentation.quoting = sqUnset
dumper.serialization.tagStyle = tsNone
dumper.serialization.handles = @[]
dumper.dump(config, fStream) Product of above code.
|
Quick heads up, this has now been released in NimYAML 2.1.0. This took far longer than anticipated because of a regression in Nim 2.0.2, for which a workaround is now in place. Apart from the various fixes regarding output style, I also added a new yaml/style module with pragmas that let you customize the output style of certain fields in the object types you serialize – see new Quickstart example. I hope that together with the general dumper options, this gives enough control over output style for most use-cases. I did some updates to the documentation and hope that things are now clearer for both new and existing users. Feedback is always welcome. |
So, I had the chance to thoroughly test NimYAML 2.0.0 dumping.
Unfortunately, this ended up in a disaster.
Output of
canonicalDumper()
without any options whatsoever.In all my trials, the following is the closest I could get to "working".
Output of
minimalDumper()
with the following options.And now we are back to those additional newlines, which you already had fixed, though I cannot find the issue, we discussed it in, because I don't think it was #135 ...
Hall of Fame
Without
dumper.presentation.quoting = sqUnset
.?
Unquoted JSON.
The text was updated successfully, but these errors were encountered: