Skip to content
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

[docs] Handle optional params #10685

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/src/modules/utils/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ function generatePropDescription(description, type) {
}
}

const parsed = parseDoctrine(description);
const parsed = parseDoctrine(description, {
sloppy: true,
});

// Two new lines result in a newline in the table.
// All other new lines must be eliminated to prevent markdown mayhem.
Expand Down Expand Up @@ -90,6 +92,10 @@ function generatePropDescription(description, type) {
return `${tag.name}: any`;
}

if (tag.type.type === 'OptionalType') {
return `${tag.name}?: ${tag.type.expression.name}`;
}

return `${tag.name}: ${tag.type.name}`;
})
.join(', ');
Expand Down
2 changes: 1 addition & 1 deletion pages/api/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ filename: /src/Select/Select.js
| <span class="prop-name">MenuProps</span> | <span class="prop-type">object | | Properties applied to the `Menu` element. |
| <span class="prop-name">multiple</span> | <span class="prop-type">bool | <span class="prop-default">false</span> | If true, `value` must be an array and the menu will support multiple selections. You can only use it when the `native` property is `false` (default). |
| <span class="prop-name">native</span> | <span class="prop-type">bool | <span class="prop-default">false</span> | If `true`, the component will be using a native `select` element. |
| <span class="prop-name">onChange</span> | <span class="prop-type">func | | Callback function fired when a menu item is selected.<br><br>**Signature:**<br>`function(event: object, child: object) => void`<br>*event:* The event source of the callback<br>*child:* The react element that was selected |
| <span class="prop-name">onChange</span> | <span class="prop-type">func | | Callback function fired when a menu item is selected.<br><br>**Signature:**<br>`function(event: object, child?: object) => void`<br>*event:* The event source of the callback<br>*child:* The react element that was selected when `native` is `false` (default). |
| <span class="prop-name">onClose</span> | <span class="prop-type">func | | Callback fired when the component requests to be closed. Useful in controlled mode (see open).<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback |
| <span class="prop-name">onOpen</span> | <span class="prop-type">func | | Callback fired when the component requests to be opened. Useful in controlled mode (see open).<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback |
| <span class="prop-name">open</span> | <span class="prop-type">bool | | Control `select` open state. You can only use it when the `native` property is `false` (default). |
Expand Down
2 changes: 1 addition & 1 deletion src/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Select.propTypes = {
* Callback function fired when a menu item is selected.
*
* @param {object} event The event source of the callback
* @param {object} child The react element that was selected
* @param {object} [child] The react element that was selected when `native` is `false` (default).
*/
onChange: PropTypes.func,
/**
Expand Down