Getting along with YAML comments with Psych
summary
A small Ruby gem called psych-comments preserves YAML comments by extending the parser-level API (pars) around Psych/LibYAML using two-pass parsing to scan comments and a reimplemented emitter; the parser is about 100-line parser and the emitter about a 300-line generator. It handles extra hash marks, comments before delimiters, key/value pairs (keys become pair nodes) and sequence bullets attaching to elements, but cannot change the underlying C lib, keeps scope strictly to comments, and some PRs were withdrawn.
AI-written summary · about
chapters (13)
- 0:00Introduction and motivation
- 3:15YAML processing basics
- 5:52Psych library levels
- 7:03Implementation approach
- 9:53Parser implementation details
- 12:10Generator implementation
- 14:07Problem with tag abuse
- 16:46Library scope decision
- 17:32Conclusion and future
- 18:47Q&A on comment attachment
- 21:23Limitations of YAML comments
- 23:09Comment support in other libraries
- 25:09Psych's role and maintenance
related talks
54mHacking parse.y
32mParsing Ruby
01h 17mAll comments must be haiku! Custom linting with RuboCop
27mGenerate Parsers! Prevent Exploits!
33mSyntax Isn't Everything: NLP for Rubyists
39mYAML and YAMLScript
27mSynchronizing Objects to YAML using Black Magic
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
