-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support loading comments #134
Comments
Seems would be helpful for some cases but requires making some keys reserved. for instance, what if comments will be key itself? |
Yeah, I guess it would mean the Alternatively, maybe |
This would be a very useful feature for my Team. Currently, we have existing Terraform file structures we require people to duplicate and lightly modify select fields for various deployments. We use comments within these files to help segment logical blocks of code and provide context to readers. Presently, I have created a script to generate these file structures, but it wouldn't pass in a code review due to the comments being deleted. I'd love if this library allowed users to maintain the entire layout of whichever file is loaded which includes comments AND blank lines (which may not be commented). Formatting can be handled by other tooling imo. Though, maintaining overall format wouldn't be a bad idea either. I just wouldn't let that hold up the implementation of comment and blank line retention. |
Context
We use this library to parse and modify Terraform files. We do this by reading a particular resource using this library, then using the data from that to write a new resource back to the file in the same place, removing the old one (using
with_meta
to know where it was). However, since no comments are output, we end up removing any that were present inside the original block.Possible Enhancement
If possible, it would be really helpful to optionally include parsed comments in the output from
loads
/load
.For example, if I parse a resource like this:
I currently get the following dictionary representation:
But maybe comment data could be added alongside it, something like:
The text was updated successfully, but these errors were encountered: