Skip to content

Commit

Permalink
Merge pull request #924 from elisherer/feature/add-excludeTypesProps
Browse files Browse the repository at this point in the history
Add propTablesExclude option
  • Loading branch information
ndelangen authored May 10, 2017
2 parents 56d779b + 42cb794 commit 902ad20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/addon-info/src/components/Story.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default class Story extends React.Component {
}

// depth-first traverse and collect types
function extract(children) {
const extract = children => {
if (!children) {
return;
}
Expand All @@ -260,13 +260,15 @@ export default class Story extends React.Component {
if (children.props && children.props.children) {
extract(children.props.children);
}
if (typeof children === 'string' || typeof children.type === 'string') {
if (typeof children === 'string' || typeof children.type === 'string' ||
(Array.isArray(this.props.propTablesExclude) && // also ignore excluded types
~this.props.propTablesExclude.indexOf(children.type))) {
return;
}
if (children.type && !types.has(children.type)) {
types.set(children.type, true);
}
}
};

// extract components from children
extract(this.props.children);
Expand Down Expand Up @@ -311,6 +313,7 @@ Story.propTypes = {
context: PropTypes.object,
info: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
propTables: PropTypes.arrayOf(PropTypes.func),
propTablesExclude: PropTypes.arrayOf(PropTypes.func),
showInline: PropTypes.bool,
showHeader: PropTypes.bool,
showSource: PropTypes.bool,
Expand Down
1 change: 1 addition & 0 deletions packages/addon-info/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default {
showHeader: Boolean(options.header),
showSource: Boolean(options.source),
propTables: options.propTables,
propTablesExclude: options.propTablesExclude,
styles: typeof options.styles === 'function' ? options.styles : s => s,
mtrcConf,
};
Expand Down

0 comments on commit 902ad20

Please sign in to comment.