Skip to content

Commit

Permalink
feat: pull constants off of apidocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Cayla Hamann committed Jun 10, 2020
1 parent c4e1708 commit 1f08aae
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/hooks/useApiDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,25 @@ const useApiDoc = (name) => {
return structuredTypeDefs;
};

const getConstants = (api) => {
return Object.getOwnPropertyNames(api)
.filter((member) =>
!IGNORED_METHODS.includes(member) &&
typeof api[member] !== 'function'
)
.map((member) => {
return {
name: `${name}.${member}`,
value: api[member]
}
})
}

return {
description: apiDocs?.text,
usage: `import { ${name} } from 'nr1'`,
typeDefs: getTypeDefs(api),
constants: getConstants(api),
methods: Object.getOwnPropertyNames(api)
.filter(
(member) =>
Expand Down

0 comments on commit 1f08aae

Please sign in to comment.