-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a86e16f
commit a96cb28
Showing
3 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
const IGNORED_PREVIEWS = ['Dropdown', 'Modal', 'Tooltip']; | ||
|
||
exports.getExamples = (component) => { | ||
return (component.__docs__.tags.examples || []).map( | ||
exports.getExamples = (name, obj) => { | ||
return (obj[name].__docs__.tags.examples || []).map( | ||
({ label, options, sourceCode }) => ({ | ||
label, | ||
sourceCode, | ||
preview: IGNORED_PREVIEWS.includes(component.name) ? false : options.live, | ||
preview: IGNORED_PREVIEWS.includes(name) ? false : options.live, | ||
}) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { getExamples } = require('./exampleInfo'); | ||
|
||
const IGNORED_METHODS = [ | ||
'prototype', | ||
'length', | ||
'name', | ||
'propTypes', | ||
'getDerivedStateFromProps', | ||
'defaultProps', | ||
]; | ||
|
||
exports.getMethods = (name, sdk) => { | ||
const obj = sdk[name]; | ||
|
||
return Object.getOwnPropertyNames(obj) | ||
.filter( | ||
(member) => | ||
!IGNORED_METHODS.includes(member) && typeof obj[member] === 'function' | ||
) | ||
.map((member) => { | ||
const methodDocs = obj[member].__docs__ || {}; | ||
const tags = methodDocs.tags || {}; | ||
|
||
return { | ||
name: `${name}.${member}`, | ||
description: methodDocs.text, | ||
returnValue: (tags.return || [])[0] || { type: 'undefined' }, | ||
params: tags.param || [], | ||
examples: getExamples(member, obj), | ||
}; | ||
}); | ||
}; |