diff options
author | Fabio Berger <me@fabioberger.com> | 2017-12-22 00:28:06 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-12-22 00:28:06 +0800 |
commit | 3e91773cd94162fca1855638a76d7bd2f510558a (patch) | |
tree | f8dc443b35a6c306d917c17a63724522d4ccd8a1 /packages/website/ts/pages/documentation/method_signature.tsx | |
parent | 66cf60f9cb62828e67135835e13b12d8099a66b4 (diff) | |
download | dexon-0x-contracts-3e91773cd94162fca1855638a76d7bd2f510558a.tar.gz dexon-0x-contracts-3e91773cd94162fca1855638a76d7bd2f510558a.tar.zst dexon-0x-contracts-3e91773cd94162fca1855638a76d7bd2f510558a.zip |
Add sectionName prefix to all anchor links in order to fix method name collisions between sections
Diffstat (limited to 'packages/website/ts/pages/documentation/method_signature.tsx')
-rw-r--r-- | packages/website/ts/pages/documentation/method_signature.tsx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/packages/website/ts/pages/documentation/method_signature.tsx b/packages/website/ts/pages/documentation/method_signature.tsx index df3b61814..14b91ab5d 100644 --- a/packages/website/ts/pages/documentation/method_signature.tsx +++ b/packages/website/ts/pages/documentation/method_signature.tsx @@ -6,6 +6,7 @@ import {Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod} from interface MethodSignatureProps { method: TypescriptMethod|SolidityMethod; + sectionName: string; shouldHideMethodName?: boolean; shouldUseArrowSyntax?: boolean; typeDefinitionByName?: TypeDefinitionByName; @@ -18,14 +19,19 @@ const defaultProps = { }; export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSignatureProps) => { - const parameters = renderParameters(props.method, props.docsInfo, props.typeDefinitionByName); + const sectionName = 'types'; + const parameters = renderParameters( + props.method, props.docsInfo, sectionName, props.typeDefinitionByName, + ); const paramString = _.reduce(parameters, (prev: React.ReactNode, curr: React.ReactNode) => { return [prev, ', ', curr]; }); const methodName = props.shouldHideMethodName ? '' : props.method.name; const typeParameterIfExists = _.isUndefined((props.method as TypescriptMethod).typeParameter) ? undefined : - renderTypeParameter(props.method, props.docsInfo, props.typeDefinitionByName); + renderTypeParameter( + props.method, props.docsInfo, sectionName, props.typeDefinitionByName, + ); return ( <span> {props.method.callPath}{methodName}{typeParameterIfExists}({paramString}) @@ -34,6 +40,7 @@ export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSi {props.method.returnType && <Type type={props.method.returnType} + sectionName={sectionName} typeDefinitionByName={props.typeDefinitionByName} docsInfo={props.docsInfo} /> @@ -45,7 +52,8 @@ export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSi MethodSignature.defaultProps = defaultProps; function renderParameters( - method: TypescriptMethod|SolidityMethod, docsInfo: DocsInfo, typeDefinitionByName?: TypeDefinitionByName, + method: TypescriptMethod|SolidityMethod, docsInfo: DocsInfo, + sectionName: string, typeDefinitionByName?: TypeDefinitionByName, ) { const parameters = method.parameters; const params = _.map(parameters, (p: Parameter) => { @@ -53,6 +61,7 @@ function renderParameters( const type = ( <Type type={p.type} + sectionName={sectionName} typeDefinitionByName={typeDefinitionByName} docsInfo={docsInfo} /> @@ -67,7 +76,8 @@ function renderParameters( } function renderTypeParameter( - method: TypescriptMethod, docsInfo: DocsInfo, typeDefinitionByName?: TypeDefinitionByName, + method: TypescriptMethod, docsInfo: DocsInfo, + sectionName: string, typeDefinitionByName?: TypeDefinitionByName, ) { const typeParameter = method.typeParameter; const typeParam = ( @@ -75,6 +85,7 @@ function renderTypeParameter( {`<${typeParameter.name} extends `} <Type type={typeParameter.type} + sectionName={sectionName} typeDefinitionByName={typeDefinitionByName} docsInfo={docsInfo} /> |