diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-02 02:48:19 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-02 02:48:19 +0800 |
commit | e5b93d1f0292cb6cc38d3f92d623b27cba6ac233 (patch) | |
tree | 08581c03706d9c7b79e75870ec9e7aea073c7189 /packages/react-docs/src/utils | |
parent | 32e1c2ac970069f5251bd3cd7a31072f0547cf2c (diff) | |
download | dexon-sol-tools-e5b93d1f0292cb6cc38d3f92d623b27cba6ac233.tar dexon-sol-tools-e5b93d1f0292cb6cc38d3f92d623b27cba6ac233.tar.gz dexon-sol-tools-e5b93d1f0292cb6cc38d3f92d623b27cba6ac233.tar.bz2 dexon-sol-tools-e5b93d1f0292cb6cc38d3f92d623b27cba6ac233.tar.lz dexon-sol-tools-e5b93d1f0292cb6cc38d3f92d623b27cba6ac233.tar.xz dexon-sol-tools-e5b93d1f0292cb6cc38d3f92d623b27cba6ac233.tar.zst dexon-sol-tools-e5b93d1f0292cb6cc38d3f92d623b27cba6ac233.zip |
Add callpath to properties
Diffstat (limited to 'packages/react-docs/src/utils')
-rw-r--r-- | packages/react-docs/src/utils/typedoc_utils.ts | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index 1e7c29ce8..1c685f915 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -283,6 +283,9 @@ export const typeDocUtils = { _convertProperty(entity: TypeDocNode, sections: SectionsMap, sectionName: string, docId: string): Property { const source = entity.sources[0]; const commentIfExists = !_.isUndefined(entity.comment) ? entity.comment.shortText : undefined; + const isConstructor = false; + const isStatic = _.isUndefined(entity.flags.isStatic) ? false : entity.flags.isStatic; + const callPath = typeDocUtils._getCallPath(sectionName, sections, isStatic, isConstructor, docId, entity.name); const property = { name: entity.name, type: typeDocUtils._convertType(entity.type, sections, sectionName, docId), @@ -291,6 +294,7 @@ export const typeDocUtils = { line: source.line, }, comment: commentIfExists, + callPath, }; return property; }, @@ -306,22 +310,6 @@ export const typeDocUtils = { const hasComment = !_.isUndefined(signature.comment); const isStatic = _.isUndefined(entity.flags.isStatic) ? false : entity.flags.isStatic; - // HACK: we use the fact that the sectionName is the same as the property name at the top-level - // of the public interface. In the future, we shouldn't use this hack but rather get it from the JSON. - let callPath; - if (isConstructor || entity.name === '__type') { - callPath = ''; - // TODO: Get rid of this 0x-specific logic - } else if (docId === 'ZERO_EX_JS') { - const topLevelInterface = isStatic ? 'ZeroEx.' : 'zeroEx.'; - callPath = - !_.isUndefined(sections.zeroEx) && sectionName !== sections.zeroEx - ? `${topLevelInterface}${sectionName}.` - : topLevelInterface; - } else { - callPath = `${sectionName}.`; - } - const parameters = _.map(signature.parameters, param => { return typeDocUtils._convertParameter(param, sections, sectionName, docId); }); @@ -330,6 +318,7 @@ export const typeDocUtils = { ? undefined : typeDocUtils._convertTypeParameter(signature.typeParameter[0], sections, sectionName, docId); + const callPath = typeDocUtils._getCallPath(sectionName, sections, isStatic, isConstructor, docId, entity.name); const method = { isConstructor, isStatic, @@ -347,6 +336,24 @@ export const typeDocUtils = { }; return method; }, + _getCallPath(sectionName: string, sections: SectionsMap, isStatic: boolean, isConstructor: boolean, docId: string, entityName: string) { + // HACK: we use the fact that the sectionName is the same as the property name at the top-level + // of the public interface. In the future, we shouldn't use this hack but rather get it from the JSON. + let callPath; + if (isConstructor || entityName === '__type') { + callPath = ''; + // TODO: Get rid of this 0x-specific logic + } else if (docId === 'ZERO_EX_JS') { + const topLevelInterface = isStatic ? 'ZeroEx.' : 'zeroEx.'; + callPath = + !_.isUndefined(sections.zeroEx) && sectionName !== sections.zeroEx + ? `${topLevelInterface}${sectionName}.` + : topLevelInterface; + } else { + callPath = `${sectionName}.`; + } + return callPath; + }, _convertFunction( entity: TypeDocNode, sections: SectionsMap, |