-
Notifications
You must be signed in to change notification settings - Fork 90
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
Import YAML files containing multiple documents as arrays #1497
Conversation
let mut terms = de | ||
.map(|de| { | ||
RichTerm::deserialize(de) | ||
.map(attach_pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make more sense to attach the sub-span corresponding to the single document, I guess. Doesn't seem like this can be easily extracted from serde_yaml
, though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess that's also the reason that the subterms of a term imported from something other than Nickel don't carry positions. I wonder if that breaks some assumptions in the evaluator...
// we deserialize the file as an array. | ||
let de = serde_yaml::Deserializer::from_str(self.files.source(file_id)); | ||
let mut terms = de | ||
.map(|de| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that serde_yaml::Deserializer
implements Iterator<Item=serde_yaml::Deserializer>
🙀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too 🙀
deec759
to
140108f
Compare
For example, in Kubernetes deployments it is common practice to package multiple YAML documents into a single file. For processing such files with Nickel we need to support importing multiple YAML documents from a single file. The concern with this is: how does such a file fit into Nickel's data model? Importing it as an array of Nickel values felt most reasonable to me. At the same time, a YAML file containing a single document should still be transparently serialized as that document, not as a single element array.
140108f
to
505105b
Compare
For example, in Kubernetes deployments it is common practice to package multiple YAML documents into a single file. For processing such files with Nickel we need to support importing multiple YAML documents from a single file. The concern with this is: how does such a file fit into Nickel's data model? Importing it as an array of Nickel values felt most reasonable to me. At the same time, a YAML file containing a single document should still be transparently serialized as that document, not as a single element array.