question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reading yaml comments not working

See original GitHub issue

Hi! I have been looking into this project because of the comment support that I couldn’t find in snakeyaml. The docs guided me mostly through, and I saw comments are used everywhere. I made my own ConfigManager class to manage the currently saved config and merging values from a default mapping. Sadly in the process comments got lost. I looked into it and saw that it was the reader. This is the class I made: Github Gist I am making a spigot plugin. The main class only provides me with the folder where to store the files (#getDataFolder()) and a short way of getting a resource as an input stream (#getResource(String)). This is my config.yml resource file:

# test
test: true
# test2
test2: false

And this is the console log:

[08:47:05 INFO]: test: true
[08:47:05 INFO]: test2: false

[08:47:05 INFO]: test: true
[08:47:05 INFO]: test2: true

[08:47:05 INFO]: test: true
[08:47:05 INFO]: test2: true

As you can see no comments got readed nor logged. So I am wondering if it’s not a feature yet, or it is a bug. Am I maybe missing some API or method calls?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexProgrammerDEcommented, Feb 19, 2021

@amihaiemil It seems to work seamlessly now. I didn’t notice that only yamlsequances were allowed to have comments above them. Doing as you said:

test: true # test
test2: false # test2

Works great. The comments get merged together with their node into the mapping. Thanks for this awesome project!

0reactions
charlesmikecommented, Feb 19, 2021

@amihaiemil thank you for resolving this ticket. I’ve just added it to your active invoice. You can always check all your invoices and more on the Contributor Dashboard.

Read more comments on GitHub >

github_iconTop Results From Across the Web

YAML parsing with comments for doc purpose
1 Answer 1 ... In ruamel.yaml , the YAML() instance only keeps the information to load resp. dump your YAML document. It does...
Read more >
Load comments · Issue #90 · yaml/pyyaml
How do I load (and dump) comments? In the following code, how can I print out the first comment? import yaml code =...
Read more >
YAML - Comments
YAML does not support multi line comments. If you want to provide comments for multiple lines, you can do so as shown in...
Read more >
YAML Syntax — Ansible Documentation
This page provides a basic overview of correct YAML syntax, which is how Ansible playbooks (our configuration management language) are expressed. We use...
Read more >
Disable with comments — yamllint 1.28.0 documentation
To prevent yamllint from reporting problems for a specific line, add a directive comment ( # yamllint disable-line ... ) on that line,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found