diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-04 16:09:59 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-04 16:09:59 +0800 |
commit | 4527e9ce000d3eafcd55552df0809ea31271ba89 (patch) | |
tree | a3bbc80de68ac79cd5a0907f42ce5c9e90dae874 /packages/react-docs/src/utils | |
parent | 7759e67a5a51a213e19083f63df13e80ea4aefa2 (diff) | |
download | dexon-sol-tools-4527e9ce000d3eafcd55552df0809ea31271ba89.tar dexon-sol-tools-4527e9ce000d3eafcd55552df0809ea31271ba89.tar.gz dexon-sol-tools-4527e9ce000d3eafcd55552df0809ea31271ba89.tar.bz2 dexon-sol-tools-4527e9ce000d3eafcd55552df0809ea31271ba89.tar.lz dexon-sol-tools-4527e9ce000d3eafcd55552df0809ea31271ba89.tar.xz dexon-sol-tools-4527e9ce000d3eafcd55552df0809ea31271ba89.tar.zst dexon-sol-tools-4527e9ce000d3eafcd55552df0809ea31271ba89.zip |
Remove prefix hack and add prefix for objectLiteral functions
Diffstat (limited to 'packages/react-docs/src/utils')
-rw-r--r-- | packages/react-docs/src/utils/typedoc_utils.ts | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index 2eee2fa59..b1d9850ef 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -173,6 +173,7 @@ export const typeDocUtils = { docsInfo.sections, sectionName, docsInfo.id, + isClassOrObjectLiteral, ); docSection.functions.push(func); } @@ -331,7 +332,7 @@ export const typeDocUtils = { 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 callPath = typeDocUtils._getCallPath(sectionName, isStatic, isConstructor, entity.name); const property = { name: entity.name, type: typeDocUtils._convertType(entity.type, sections, sectionName, docId), @@ -367,7 +368,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 callPath = typeDocUtils._getCallPath(sectionName, isStatic, isConstructor, entity.name); const method = { isConstructor, isStatic, @@ -385,28 +386,16 @@ export const typeDocUtils = { }; return method; }, - _getCallPath( - sectionName: string, - sections: SectionsMap, - isStatic: boolean, - isConstructor: boolean, - docId: string, - entityName: string, - ) { + _getCallPath(sectionName: string, isStatic: boolean, isConstructor: boolean, 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}.`; + const prefix = isStatic ? sectionName : `${sectionName[0].toLowerCase()}${sectionName.slice(1)}`; + callPath = `${prefix}.`; } return callPath; }, @@ -415,6 +404,7 @@ export const typeDocUtils = { sections: SectionsMap, sectionName: string, docId: string, + isObjectLiteral: boolean, ): TypescriptFunction { const signature = entity.signatures[0]; const source = entity.sources[0]; @@ -428,10 +418,17 @@ export const typeDocUtils = { ? undefined : typeDocUtils._convertTypeParameter(signature.typeParameter[0], sections, sectionName, docId); + let callPath = ''; + if (isObjectLiteral) { + const isConstructor = false; + const isStatic = false; + callPath = typeDocUtils._getCallPath(sectionName, isStatic, isConstructor, entity.name); + } const func = { name: signature.name, comment: hasComment ? signature.comment.shortText : undefined, returnComment: hasComment && signature.comment.returns ? signature.comment.returns : undefined, + callPath, source: { fileName: source.fileName, line: source.line, |