You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context:
Let's say you need to generate a config yaml file for users, but you want some of the config options to be commented out.
This way your users can easily comment in and out some of the config options.
The feature needed is a way to tell the js-yaml parser what items to comment out (items of an array OR key-value pairs of an object)
To the best of my knowledge, this will be the first library that implements this kind of feature, I could not find it anywhere else.
Real world use case:
I've already implemented this behavior for my company, it can be viewed by going to https://app.datree.io/settings/user-settings (after signup) and clicking on Download policies.yaml
API suggestion:
Have a flag option: withComments: boolean [default: false]
Every time a JSON array has an item that equals to "JS_YAML_ARRAY_START_COMMENTS" - array items will start to be commented out.
Every time a JSON array has an item that equals "JS_YAML_ARRAY_STOP_COMMENTS" - array items will stop being commented out.
Every time an object has a key that equals "JS_YAML_OBJECT_COMMENTS" - the value of that key should be a string, comma-separated list of keys to comment out of the current object.
All special indicators (e.g "JS_YAML_ARRAY_START_COMMENTS") should be removed for the final yaml output.
Implementation:
As I've stated, I already implemented the specific use case for my company as a wrapper to this library, it should be possible to implement it for the general use case as well.
That being said, this is definitely tricky and should be marked as an experimental feature.
Wrap up:
Is this something that given a working implementation, will be accepted to the library?
Any concerns/suggestions regarding the suggested API?
Any concerns regarding the implementation?
The text was updated successfully, but these errors were encountered:
Context:
Let's say you need to generate a config yaml file for users, but you want some of the config options to be commented out.
This way your users can easily comment in and out some of the config options.
The feature needed is a way to tell the js-yaml parser what items to comment out (items of an array OR key-value pairs of an object)
To the best of my knowledge, this will be the first library that implements this kind of feature, I could not find it anywhere else.
Real world use case:
I've already implemented this behavior for my company, it can be viewed by going to https://app.datree.io/settings/user-settings (after signup) and clicking on
Download policies.yaml
API suggestion:
withComments: boolean
[default: false]"JS_YAML_ARRAY_START_COMMENTS"
- array items will start to be commented out."JS_YAML_ARRAY_STOP_COMMENTS"
- array items will stop being commented out."JS_YAML_OBJECT_COMMENTS"
- the value of that key should be a string, comma-separated list of keys to comment out of the current object."JS_YAML_ARRAY_START_COMMENTS"
) should be removed for the final yaml output.Implementation:
As I've stated, I already implemented the specific use case for my company as a wrapper to this library, it should be possible to implement it for the general use case as well.
That being said, this is definitely tricky and should be marked as an experimental feature.
Wrap up:
The text was updated successfully, but these errors were encountered: