Skip to content

Commit

Permalink
[WNNMGDS-270] Update prop doc rendering (#622)
Browse files Browse the repository at this point in the history
* Show children prop documentation and update component docs

* Update autocomplete props

* Hide prop docs with @HidePropDoc instead of _

* Fix tests

* Update backstop references

* PR feedback and rename flag to @hide-prop

Co-authored-by: Scott Weber <[email protected]>
  • Loading branch information
bernardwang and line47 authored Feb 18, 2020
1 parent 8378bf8 commit 4ae2c28
Show file tree
Hide file tree
Showing 65 changed files with 53 additions and 32 deletions.
2 changes: 1 addition & 1 deletion guides/WRITING-DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Button.propTypes = {
};
```
For internal/private props that you don't want to be displayed in the documentation, prefix the prop with an underscore (ie. `_parentDefaultSelectedId`).
For internal/private props that you don't want to be displayed in the documentation, include the **`@hide-prop`** flag in the React prop description (ie. `_selectedId` in `<VerticalNav>`).
## General documentation pages
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/Alert/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Alert.defaultProps = {
role: 'region'
};
Alert.propTypes = {
/**
* The alert's body content
*/
children: PropTypes.node,
/**
* Text for the alert heading
Expand Down
21 changes: 8 additions & 13 deletions packages/core/src/components/Autocomplete/Autocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,13 @@ Autocomplete.propTypes = {
*/
ariaClearLabel: PropTypes.string,
/**
* Control the `TextField` autocomplete attribute. Changed to "off" to support accessibility. Chrome 70 appears to support this correct behavior in early testing.
*
* https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
* Control the `TextField` autocomplete attribute. Defaults to "off" to support accessibility. [Read more.](https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion)
*/
autoCompleteLabel: PropTypes.string,
children: PropTypes.node,
/**
* Must contain a `TextField` component
*/
children: PropTypes.node.isRequired,
/**
* Additional classes to be added to the root element.
* Useful for adding utility classes.
Expand Down Expand Up @@ -250,9 +251,7 @@ Autocomplete.propTypes = {
*/
inputRef: PropTypes.func,
/**
* Used to determine the string value for the selected item (which is used to compute the `inputValue`).
*
* Also see: https://github.com/paypal/downshift#itemtostring
* Used to determine the string value for the selected item (which is used to compute the `inputValue`). [Read more on downshift docs.](https://github.com/paypal/downshift#itemtostring)
*/
itemToString: PropTypes.func,
/**
Expand Down Expand Up @@ -285,15 +284,11 @@ Autocomplete.propTypes = {
*/
noResultsMessage: PropTypes.node,
/**
* Called when the user selects an item and the selected item has changed. Called with the item that was selected and the new state.
*
* Also see: https://github.com/paypal/downshift#onchange
* Called when the user selects an item and the selected item has changed. Called with the item that was selected and the new state. [Read more on downshift docs.](https://github.com/paypal/downshift#onchange)
*/
onChange: PropTypes.func,
/**
* Called when the child `TextField` value changes. Returns a String `inputValue`.
*
* Also see: https://github.com/paypal/downshift#oninputvaluechange
* Called when the child `TextField` value changes. Returns a String `inputValue`. [Read more on downshift docs.](https://github.com/paypal/downshift#oninputvaluechange)
*/
onInputValueChange: PropTypes.func
};
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/components/Badge/Badge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ Badge.propTypes = {
*/
className: PropTypes.string,
/**
* In most cases this will be the badge's label, but you could also use this
* to nest more advanced JSX.
* Label text or HTML.
*/
children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]).isRequired,
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/**
* Sets the font size of the Badge
*/
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ export class Button extends React.PureComponent {

Button.defaultProps = { type: 'button' };
Button.propTypes = {
children: PropTypes.node.isRequired,
/**
* Label text or HTML
*/
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/**
* Additional classes to be added to the root button element.
* Useful for adding utility classes.
Expand Down Expand Up @@ -136,7 +139,7 @@ Button.propTypes = {
*/
onClick: PropTypes.func,
/**
* (Deprecated) Access a reference to the `button` or `a` element. Please use `inputRef` instead.
* @hide-prop [Deprecated] Access a reference to the `button` or `a` element. Please use `inputRef` instead.
*/
buttonRef: PropTypes.func,
size: PropTypes.oneOf(['small', 'big']),
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/ChoiceList/Choice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Choice.propTypes = {
/**
* Label text or HTML.
*/
children: PropTypes.node.isRequired,
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/**
* Sets the input's `checked` state. Use this in combination with `onChange`
* for a controlled component; otherwise, set `defaultChecked`.
Expand Down Expand Up @@ -200,7 +200,7 @@ Choice.propTypes = {
*/
inversed: PropTypes.bool,
/**
* (Deprecated) Placement of the input relative to the text label
* @hide-prop [Deprecated] Placement of the input relative to the text label
*/
inputPlacement: PropTypes.oneOf(['left', 'right']),
size: PropTypes.oneOf(['small']),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/ChoiceList/ChoiceList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ ChoiceList.propTypes = {
*/
type: PropTypes.oneOf(['checkbox', 'radio']),
/**
* (Deprecated) Adds `aria-label` attribute if component renders a select
* @hide-prop [Deprecated] Adds `aria-label` attribute if component renders a select
*/
ariaLabel: PropTypes.string
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Dropdown.propTypes = {
*/
fieldClassName: PropTypes.string,
/**
* (Deprecated) Access a reference to the `select` element. Please use `inputRef` instead.
* @hide-prop [Deprecated] Access a reference to the `select` element. Please use `inputRef` instead.
*/
fieldRef: PropTypes.func,
/**
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/components/FormLabel/FormLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ export class FormLabel extends React.PureComponent {

FormLabel.defaultProps = { component: 'label' };
FormLabel.propTypes = {
children: PropTypes.node.isRequired,
/**
* Label text or HTML.
*/
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/**
* Additional classes to be added to the root element.
*/
Expand Down Expand Up @@ -108,7 +111,7 @@ FormLabel.propTypes = {
*/
inversed: PropTypes.bool,
/**
* (Deprecated) Additional classes to be added to the label text. Please use `textClassName` instead.
* @hide-prop [Deprecated] Additional classes to be added to the label text. Please use `textClassName` instead.
*/
labelClassName: PropTypes.string,
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/Review/Review.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ Review.defaultProps = {
};

Review.propTypes = {
/**
* `Review` component's body HTML.
*/
children: PropTypes.node.isRequired,
className: PropTypes.string,
/**
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/components/SkipNav/SkipNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ SkipNav.defaultProps = {
};

SkipNav.propTypes = {
children: PropTypes.node.isRequired,
/**
* Skip nav label
*/
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/**
* The anchor or target for the link (where the link will jump the user to)
*/
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/components/Tabs/Tab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ Tab.defaultProps = {
};

Tab.propTypes = {
children: PropTypes.node.isRequired,
/**
* Tab label text or HTML.
*/
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/**
* Additional classes to be added to the root tab element.
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/Tabs/Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ export class Tabs extends React.PureComponent {
}

Tabs.propTypes = {
/**
* Must only contain `TabPanel` components
*/
children: PropTypes.node.isRequired,
/**
* Sets the initial selected `TabPanel` state. If this isn't set, the first
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/Tabs/_Tabs.docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Style guide: components.tabs.react-tabpanel
/*
`<Tab>`
@hide-example
@react-component Tab
Style guide: components.tabs.react-tab
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/TextField/TextField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ TextField.propTypes = {
*/
fieldClassName: PropTypes.string,
/**
* (Deprecated) Access a reference to the `input` or `textarea` element. Please use `inputRef` instead.
* @hide-prop [Deprecated] Access a reference to the `input` or `textarea` element. Please use `inputRef` instead.
*/
fieldRef: PropTypes.func,
/**
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/components/VerticalNav/VerticalNavItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ VerticalNavItem.defaultProps = {
};

VerticalNavItem.propTypes = {
// This gets passed through from the parent VerticalNav to a nested VerticalNav
/**
* @hide-prop This gets passed through from the parent VerticalNav to a nested VerticalNav
*/
_selectedId: PropTypes.string,
/**
* Aria label for the toggle button when the sub-navigation is collapsed
Expand Down
8 changes: 5 additions & 3 deletions packages/docs/src/scripts/components/ReactPropDocs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ class ReactPropDocs extends React.PureComponent {
const props = Object.getOwnPropertyNames(this.props.propDocs);

return props.map(prop => {
if (prop === 'children' || prop.match(/^_/)) return null;

return <ReactPropDoc key={prop} name={prop} {...this.props.propDocs[prop]} />;
// Hides docs for react props with `@hide-prop` tag in the description
const description = this.props.propDocs[prop].description;
if (!description.match(/@hide-prop/i)) {
return <ReactPropDoc key={prop} name={prop} {...this.props.propDocs[prop]} />;
}
});
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4ae2c28

Please sign in to comment.