This question is an exact duplicate of:
I want to generate a YAML document with some comments between sequence elements but I can't really figure out how to do this. Any pointers?
You can’t emit YAML documents containing comments with Psych. Psych basically dumps a Hash, and you can’t have comments in a Hash either.
来源:https://stackoverflow.com/questions/16889044/how-can-i-emit-comments-in-a-yaml-document-using-psych