-
Notifications
You must be signed in to change notification settings - Fork 18
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
Yaml fixer #18
base: master
Are you sure you want to change the base?
Yaml fixer #18
Conversation
return $content; | ||
} | ||
|
||
$fixed = Yaml::dump($array); |
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.
return Yaml::dump($array);
@ninsuo Awesome work man. 👍 I agree, comments and formatting are the issue, must think about possible solutions, if you have ideas feel free to share them. |
@ninsuo I think, current impl can handle also transforming |
@akovalyov we don't need to escape |
@ninsuo I like last indention changes. 👍 |
I believe @akovalyov is correct. We know we do not edit any keys. Can we check where the comments are relative a key, store them, run Yaml parser and dump and then re-add the comments? |
Yep. This may be the solution. Will try it soon 👍 |
There's interest about this in the Symfony core and someone asked about this on Twitter yesterday: symfony/symfony#18079. @ninsuo are you still interested in this? Thanks! |
Hello @weaverryan, I'm quite busy those last days, if somebody from the core want to tackle this, go ahead 👍 Thank you ! A |
Or some other community member ;). Thanks @ninsuo for starting this and for the quick reply - now we know this issue is open for someone else! |
@ninsuo So, comments is the issue we need to solve? @weaverryan What do you think about the formatting? Is it acceptable? |
Yes, my solution is quite naive and runs Yaml parser / dumper to clean your config files up. But using this way, you drop all comments. Bad... I'm guessing there will be no choice but develop a Yaml fixer that will keep formatting and comments, based on regular expressions or maybe more sophisticated... |
I agree with @ninsuo - this solution won't do it. But the good news is that:
Cheers! |
Just want to add that we can think bigger then this. If we can do it using some third party tool, or e.g. ruby library, I would merge that as well. We just need yaml parser/dumper that keeps comments. I would try to avoid using regex magic, but if someone is good with that, why not. The point is, this is just a tool that gets he job done, it does not necessarily need to be fancy, nor perfect as @weaverryan said. I will try to look deeper if there is something out there that we can use to easily do this. Thank you all for the effort. 👍 |
You could think about forking the Symfony YAML component. What you would need to do then is to modify it such that comments were not stripped (probably you would have to mark them somehow to be able to dump them properly again). The advantage is that the Symfony parser already knows all the deprecated features and it's easy to handle them, most of them will probably be handled implicitly (I suggest to take the one from the upcoming 3.1 release as there are some more deprecations). |
I am not really satisfied by the result:
dump's current formatting is quite not friendly (especially for hashes)(fixed)Anyway this is a first draw, I'm open to suggestions :)