aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-08-02 02:48:19 +0800
committerFabio Berger <me@fabioberger.com>2018-08-02 02:48:19 +0800
commite5b93d1f0292cb6cc38d3f92d623b27cba6ac233 (patch)
tree08581c03706d9c7b79e75870ec9e7aea073c7189
parent32e1c2ac970069f5251bd3cd7a31072f0547cf2c (diff)
downloaddexon-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
-rw-r--r--packages/react-docs/src/components/property_block.tsx2
-rw-r--r--packages/react-docs/src/types.ts1
-rw-r--r--packages/react-docs/src/utils/typedoc_utils.ts39
3 files changed, 25 insertions, 17 deletions
diff --git a/packages/react-docs/src/components/property_block.tsx b/packages/react-docs/src/components/property_block.tsx
index 466082a91..074c59c5f 100644
--- a/packages/react-docs/src/components/property_block.tsx
+++ b/packages/react-docs/src/components/property_block.tsx
@@ -48,7 +48,7 @@ export class PropertyBlock extends React.Component<PropertyBlockProps, PropertyB
/>
</div>
<code className={`hljs ${constants.TYPE_TO_SYNTAX[this.props.docsInfo.type]}`}>
- {property.name}:{' '}
+ {(property as any).callPath}{property.name}:{' '}
<Type type={property.type} sectionName={sectionName} docsInfo={this.props.docsInfo} />
</code>
{property.source && (
diff --git a/packages/react-docs/src/types.ts b/packages/react-docs/src/types.ts
index 83ad157d1..ca869df1c 100644
--- a/packages/react-docs/src/types.ts
+++ b/packages/react-docs/src/types.ts
@@ -202,6 +202,7 @@ export interface Property {
type: Type;
source?: Source;
comment?: string;
+ callPath?: string;
}
export interface BaseMethod {
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,