From 3e91773cd94162fca1855638a76d7bd2f510558a Mon Sep 17 00:00:00 2001
From: Fabio Berger <me@fabioberger.com>
Date: Thu, 21 Dec 2017 17:28:06 +0100
Subject: Add sectionName prefix to all anchor links in order to fix method
 name collisions between sections

---
 .../ts/pages/documentation/method_signature.tsx       | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

(limited to 'packages/website/ts/pages/documentation/method_signature.tsx')

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}
                 />
-- 
cgit v1.2.3


From d725de72861c6a6218c7f4822a339175a2da7403 Mon Sep 17 00:00:00 2001
From: Fabio Berger <me@fabioberger.com>
Date: Thu, 21 Dec 2017 17:28:20 +0100
Subject: Create types sectionName constant

---
 packages/website/ts/pages/documentation/method_signature.tsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'packages/website/ts/pages/documentation/method_signature.tsx')

diff --git a/packages/website/ts/pages/documentation/method_signature.tsx b/packages/website/ts/pages/documentation/method_signature.tsx
index 14b91ab5d..366d4c13e 100644
--- a/packages/website/ts/pages/documentation/method_signature.tsx
+++ b/packages/website/ts/pages/documentation/method_signature.tsx
@@ -3,6 +3,7 @@ import * as React from 'react';
 import {DocsInfo} from 'ts/pages/documentation/docs_info';
 import {Type} from 'ts/pages/documentation/type';
 import {Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod} from 'ts/types';
+import {constants} from 'ts/utils/constants';
 
 interface MethodSignatureProps {
     method: TypescriptMethod|SolidityMethod;
@@ -19,7 +20,7 @@ const defaultProps = {
 };
 
 export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSignatureProps) => {
-    const sectionName = 'types';
+    const sectionName = constants.TYPES_SECTION_NAME;
     const parameters = renderParameters(
         props.method, props.docsInfo, sectionName, props.typeDefinitionByName,
     );
-- 
cgit v1.2.3

