-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
lib.options: automatically generate example for booleans #18816
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,16 +93,24 @@ rec { | |
| visible = opt.visible or true; | ||
| readOnly = opt.readOnly or false; | ||
| type = opt.type.name or null; | ||
| } | ||
| // (if opt ? example then { example = scrubOptionValue opt.example; } else {}) | ||
| // (if opt ? default then { default = scrubOptionValue opt.default; } else {}) | ||
| // (if opt ? defaultText then { default = opt.defaultText; } else {}); | ||
| }; | ||
| docOptionDefault = | ||
| if opt ? defaultText then { default = opt.defaultText; } | ||
| else if opt ? default then { default = scrubOptionValue opt.default; } | ||
| else { }; | ||
| docOptionExample = | ||
| if opt ? example then { example = scrubOptionValue opt.example; } | ||
| else if opt.type == lib.types.bool then | ||
| { example = !docOptionDefault.default or false; } | ||
| else if opt ? type && isBool (docOptionDefault.default or null) && opt.type.check (!docOptionDefault.default) then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That should never happen since it's only evaluated if |
||
| { example = !docOptionDefault.default or false; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: !(… or …)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll check if I can factor that out, but I'd rather not add a let. |
||
| else { }; | ||
|
|
||
| subOptions = | ||
| let ss = opt.type.getSubOptions opt.loc; | ||
| in if ss != {} then optionAttrSetToDocList' opt.loc ss else []; | ||
| in | ||
| [ docOption ] ++ subOptions) (collect isOption options); | ||
| [ (docOption // docOptionDefault // docOptionExample) ] ++ subOptions) (collect isOption options); | ||
|
|
||
|
|
||
| /* This function recursively removes all derivation attributes from | ||
|
|
||
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.
nit: !(docOptionDefault.default or false)
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.
I'll change that to improve readability.