Skip to content
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

Add Comments to Yaml #57

Open
Articdive opened this issue Mar 24, 2019 · 9 comments
Open

Add Comments to Yaml #57

Articdive opened this issue Mar 24, 2019 · 9 comments
Assignees
Milestone

Comments

@Articdive
Copy link

I'm aware of SnakeYaml not supporting comments during the parse, however since you have your own yaml writer you can definitely support outputting comments, you would just need to bridge the YamlCommentedConfiguration's comment Map to your Writer and then when writing line for line, check if it's a node, if it is a node, add said comment for said node. Obviously you also need to calculate things such as Whitespace e.t.c and it wouldn't be the easiest solution, but it would allow for Comment output on Yaml

@Articdive
Copy link
Author

A proof of concept would be here in the save() method.

@Articdive Articdive changed the title [YAML] Add Comments to Yaml Add Comments to Yaml Mar 24, 2019
@TheElectronWill
Copy link
Owner

Actually my "yaml writer" only exists to unwrap Config to Map<String, Object>. It then gives everything to snakeyaml, which does the real writing.

Supporting comments in yaml would indeed be very nice, both in reading and writing. However that would require more work and isn't a top priority, I'll add it to the backlog.

@Articdive
Copy link
Author

I created my own custom implementation of this, if you are interested I can also PR it, however It's not the most efficient code and I'm nearly positive it can be improved.

@TheElectronWill
Copy link
Owner

TheElectronWill commented Mar 26, 2019

Yep I'm interested. I would have liked to be able to read and write comments in order to preserve the configs but just writing comments is better than nothing 😃

@Articdive
Copy link
Author

Yep I'm interested. I would have liked to be able to read and write comments in order to preserve the configs but just writing comments is better than nothing 😃

https://github.com/Articdive/EnumToConfiguration/tree/master/src/main/java/de/articdive/enum_to_configuration/yaml

@ArcheCraft
Copy link

ArcheCraft commented Nov 9, 2021

Is this still being considered?

@TheElectronWill
Copy link
Owner

TheElectronWill commented Nov 10, 2021

It is, but it won't be ready before several months because it requires some work. I know the snakeyaml's limitation is problematic.

@maurxce
Copy link

maurxce commented Jul 4, 2023

Any updates on this?

@TheElectronWill
Copy link
Owner

Not yet, I would have to write a new yaml parser 😅

@TheElectronWill TheElectronWill self-assigned this Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants