-
Notifications
You must be signed in to change notification settings - Fork 6
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
Configuration Documentation #4
Comments
Agreed; it would be great to be able to extract documentation from a ConfigStruct, rather than maintaining it separately. I like the idea of adding Types are a bit of a conundrum. Currently, the closest thing we have to a "type" is support for validation/coercion blocks on attributes, e.g. attribute :port { |arg| Integer(arg) } It probably makes sense to deprecate that approach, and move to modelling types as objects, with both descriptions and coercion behaviour, e.g. attribute :port, type: Integer I reckon we could leverage dry-types here; it provides a pattern for type objects that respond to I think the method to access documentation should just be MyConfigModel.documentation
#=> {
".postion" => {
"description" => "The position of our object"
},
".postion.x" => {
"default" => 0,
"description" => "x-coordinate",
"type" => "Integer"
},
".postion.y" => {
"default" => 0,
"description" => "y-coordinate",
"type" => "Integer"
}
} |
FYI, I've started work (on |
👍 on the merging of type/validation/coercion and 👍 for using dry-types. Great changes so far 😄 |
We're currently using ConfigMapper::ConfigStruct classes for defining our configuration data structure, and also maintain a separate 'configuration reference' yaml document for our users.
E.g. for the following code:
We would also write a companion
config-reference.yml
document containing:It would be great if
ConfigStruct
elements (attributes, components and component_dicts) supported some additional documentation options, so that a config reference document could be generated.I'm thinking this would involve adding
description
option to all elements and atype
option for attributes, e.g.Then exposing a method on
ConfigStruct
objects (maybe#reference_yaml
?) that would return a yaml object of theconfig-reference
data above.Happy to make a PR but would like some feedback first :)
The text was updated successfully, but these errors were encountered: