-
Notifications
You must be signed in to change notification settings - Fork 324
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
Control Indent Mapping Context #241
base: master
Are you sure you want to change the base?
Conversation
Possibly related to #224 |
src/emitter.c
Outdated
@@ -1825,6 +1827,7 @@ yaml_emitter_write_indicator(yaml_emitter_t *emitter, | |||
|
|||
emitter->whitespace = is_whitespace; | |||
emitter->indention = (emitter->indention && is_indention); | |||
/* emitter->open_ended = 0; */ |
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.
The test suite is passing although this was commented out. That seems suspicious.
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.
That was a change that exists upstream that I'm trying to harmonize. If I leave that in, it breaks tests. I suspect it may be a reverted change from earlier and can be safely removed.
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.
I removed this.
src/emitter.c
Outdated
if (emitter->root_context) | ||
{ | ||
emitter->open_ended = 1; | ||
} |
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.
See above comment. This is basically a revert from a previous commit, but the test suite doesn't catch that.
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.
I pushed this change up.
@perlpunk Hi. Any chance to get this reviewed? Looks useful so that Ruby |
To me the description of the PR isn't really helpful. It has a lot of text and then some testsuite output diff, but it doesn't show any example of what it is doing. |
@perlpunk yea, the diff looks like there an additional flag that disables indentation of sequences. Not sure if it helps ruby/psych#591 |
I have the code from this library copied into a project, r-yaml. The only change at present is this indentation change. If I take it out, my issue bucket lights up with complaints. I NEED this behavior. It'd be nice to enable it somehow either via compile or via flag. Then the library in the r-yaml project would not be divergent. |
@spgarbet if you can provide an example of output without the patch and with it, it would be most helpful to understand what the PR does. |
I think the idea here is good so I want to add some context with the hope that this discussion can continue: Given a (for example) Ruby object like:
When dumping this object to YAML with libyaml 0.2.5, you currently get this output: ---
a:
- 1
- 2
- 3 With this PR (or a similar change which makes the ---
a:
- 1
- 2
- 3 It seems like this is a relatively common request in
I do think the strategy in this PR is a good solution as it allows the emitter to be configured with either style, and I would love to see this configuration consistently available in other |
Problem: Downstream consumer of libyaml has some divergent formatting changes. Would prefer to use libyaml without modification. Possibly towards using system installed library: vubiostat/r-yaml#102
It was felt important enough to downstream users to change this bit of formatting on output, so this is important to some users.
Goal: Merge this change in with necessary tests, and understand why the formatting directive was necessary.
Needs: (1) Blessing from dev team. (2) Test cases.
This pull requests has the divergence between the two with one line commented out due to breaking two tests. If the line is commented in the following test snippet occurs with 2 broken tests: