Support generation of YAML with comments#181
Open
jrandall wants to merge 1 commit intochyh1990:masterfrom
Open
Support generation of YAML with comments#181jrandall wants to merge 1 commit intochyh1990:masterfrom
jrandall wants to merge 1 commit intochyh1990:masterfrom
Conversation
serejkus
reviewed
Jan 14, 2022
|
|
||
| #[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord, Hash)] | ||
| pub struct Comments { | ||
| /// A before comment is a vector of strinsg representing the text from full |
There was a problem hiding this comment.
Suggested change
| /// A before comment is a vector of strinsg representing the text from full | |
| /// A before comment is a vector of strings representing the text from full |
serejkus
reviewed
Jan 14, 2022
| /// Alias, not fully supported yet. | ||
| Alias(usize), | ||
| /// Yaml node with block or line comments | ||
| CommentedYaml(self::CommentedYaml), |
There was a problem hiding this comment.
this is a breaking change, so I guess, it'll require bumping minor version (0.4.5 to 0.5.0), maybe? But I'm not the maintainer :)
There was a problem hiding this comment.
Since this is a breaking change, it might also potentially be worth adding non_exhaustic to the enum, so in the future, changes like this won't be breaking.
| #[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord, Hash)] | ||
| pub struct CommentedYaml(pub Box<Yaml>, pub Comments); | ||
|
|
||
| #[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord, Hash)] |
There was a problem hiding this comment.
Suggested change
| #[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord, Hash)] | |
| #[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord, Hash, Default)] |
It would be nice to have a default implementation given there are so many fields.
|
@jrandall Did you look into it? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address half of #146 by adding support to generate YAML with comments. Parsing YAML with comments into the internal form (and making round-tripping possible) would be the next step, but we had an immediate need on the generation side so we went ahead and implemented that, and hope that it might be useful to others as well.
Because we don't have a parser yet, the tests for comment generation are somewhat verbose (involving literal expected values). Once the parser is implemented, these tests can be replaced by round-trip tests as are used for much of the other functionality.