From c0498944c38e827dc69f369dd1427df43b23c9a9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 18:40:38 +0100 Subject: Add more robust key --- packages/react-docs/src/components/documentation.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 3cd14923c..55aa1587e 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -10,6 +10,7 @@ import { utils as sharedUtils, } from '@0xproject/react-shared'; import { + CustomType, DocAgnosticFormat, Event, ExternalExportToLink, @@ -218,11 +219,11 @@ export class Documentation extends React.Component { + const typeDefs = _.map(sortedTypes, (customType: CustomType, i: number) => { return ( Date: Thu, 27 Sep 2018 18:51:30 +0100 Subject: Add typeSectionName to docsInfo so we don't use hard-coded "Types" --- packages/react-docs/src/components/documentation.tsx | 2 +- packages/react-docs/src/docs_info.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 55aa1587e..f1cb32b68 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -266,7 +266,7 @@ export class Documentation extends React.Component
- +
{this._renderNetworkBadgesIfExists(sectionName)}
diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts index 6355a2f88..bf6aa07a7 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -18,6 +18,7 @@ export class DocsInfo { public packageName: string; public packageUrl: string; public menu: DocsMenu; + public typeSectionName: string; public sections: SectionsMap; public sectionNameToMarkdownByVersion: SectionNameToMarkdownByVersion; public contractsByVersionByNetworkId?: ContractsByVersionByNetworkId; @@ -28,6 +29,7 @@ export class DocsInfo { this.displayName = config.displayName; this.packageName = config.packageName; this.packageUrl = config.packageUrl; + this.typeSectionName = config.type === SupportedDocJson.SolDoc ? 'structs' : 'types'; this.sections = config.markdownSections; this.sectionNameToMarkdownByVersion = config.sectionNameToMarkdownByVersion; this.contractsByVersionByNetworkId = config.contractsByVersionByNetworkId; @@ -53,7 +55,7 @@ export class DocsInfo { _.isEmpty(docSection.properties) && _.isEmpty(docSection.events); - if (!_.isUndefined(this.sections.types) && sectionName === this.sections.types) { + if (sectionName === this.typeSectionName) { const sortedTypesNames = _.sortBy(docSection.types, 'name'); const typeNames = _.map(sortedTypesNames, t => t.name); menuSubsectionsBySection[sectionName] = typeNames; @@ -86,8 +88,8 @@ export class DocsInfo { return {}; } - const typeDocSection = docAgnosticFormat[this.sections.types]; - const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name') as any; + const section = docAgnosticFormat[this.sections.types]; + const typeDefinitionByName = _.keyBy(section.types, 'name') as any; return typeDefinitionByName; } } -- cgit From 63ffdb3895caa641881eecf21563a667f6d8b605 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 18:52:51 +0100 Subject: Improve key --- packages/react-docs/src/components/interface.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/interface.tsx b/packages/react-docs/src/components/interface.tsx index 9f0800d71..cad7d6c46 100644 --- a/packages/react-docs/src/components/interface.tsx +++ b/packages/react-docs/src/components/interface.tsx @@ -20,9 +20,9 @@ export interface InterfaceProps { export const Interface: React.SFC = (props: InterfaceProps): any => { const type = props.type; - const properties = _.map(type.children, property => { + const properties = _.map(type.children, (property, i) => { return ( - + {property.name}:{' '} {property.type && !_.isUndefined(property.type.method) ? ( Date: Thu, 27 Sep 2018 18:55:01 +0100 Subject: Render fallback functions better --- packages/react-docs/src/components/signature.tsx | 4 +++- packages/react-docs/src/components/signature_block.tsx | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index a690a1f03..aa174042c 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -19,12 +19,14 @@ export interface SignatureProps { callPath?: string; docsInfo: DocsInfo; isInPopover: boolean; + isFallback?: boolean; } const defaultProps = { shouldHideMethodName: false, shouldUseArrowSyntax: false, callPath: '', + isFallback: false, }; export const Signature: React.SFC = (props: SignatureProps) => { @@ -75,7 +77,7 @@ export const Signature: React.SFC = (props: SignatureProps) => { return ( {props.callPath} - {methodName} + {props.isFallback ? '' : methodName} {typeParameterIfExists}({hasMoreThenTwoParams &&
} {paramStringArray}) {props.returnType && ( diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index 1ea0ea28c..fc4db10ad 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -50,6 +50,7 @@ export class SignatureBlock extends React.Component @@ -84,6 +86,7 @@ export class SignatureBlock extends React.Component {(method as TypescriptMethod).source && ( @@ -114,9 +117,9 @@ export class SignatureBlock extends React.Component ); } - private _renderChip(text: string): React.ReactNode { + private _renderChip(text: string, backgroundColor: string = colors.lightBlueA700): React.ReactNode { return ( -
+
{text}
); -- cgit From a6672e0190573c65f2c36e303d49f0389f5a9a26 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 19:43:10 +0100 Subject: Don't render colon for auto-generated getters --- packages/react-docs/src/components/signature.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index aa174042c..266bfe3dd 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -118,9 +118,14 @@ function renderParameters( /> ); return ( - + + {!_.isEmpty(p.name) && ( + {p.name} - {isOptional && '?'}: {type} + {isOptional && '?'}:{' '} + + )} + {type} {hasDefaultValue && ` = ${p.defaultValue}`} ); -- cgit From cfddea931dedb77a88507517957e19350e9348b8 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 19:49:07 +0100 Subject: Make sure basic solidity types are colored orange --- packages/react-docs/src/components/type.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index 156a3496d..b7a94483e 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -13,6 +13,7 @@ import { Signature } from './signature'; import { TypeDefinition } from './type_definition'; const basicJsTypes = ['string', 'number', 'undefined', 'null', 'boolean']; +const basicSolidityTypes = ['bytes', 'bytes4', 'uint256', 'address']; const defaultProps = {}; @@ -80,7 +81,7 @@ export const Type: React.SFC = (props: TypeProps): any => { case TypeDocTypes.Array: typeName = type.elementType.name; - if (_.includes(basicJsTypes, typeName)) { + if (_.includes(basicJsTypes, typeName) || _.includes(basicSolidityTypes, typeName)) { typeNameColor = colors.orange; } break; -- cgit From ac04dbf7e4f04ae4e0a6e9cce5232339597493ed Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 19:50:02 +0100 Subject: Re-use interface component for rendering structs but label it differently --- packages/react-docs/src/components/type_definition.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx index 09cb3ff74..9a3e50a1b 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -5,7 +5,7 @@ import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { KindString } from '../types'; +import { KindString, SupportedDocJson } from '../types'; import { constants } from '../utils/constants'; import { Comment } from './comment'; @@ -46,7 +46,7 @@ export class TypeDefinition extends React.Component Date: Thu, 27 Sep 2018 23:00:01 +0100 Subject: Improve keys --- packages/react-docs/src/components/signature.tsx | 6 ++++-- packages/react-docs/src/components/signature_block.tsx | 6 +++--- packages/react-docs/src/components/type.tsx | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index 266bfe3dd..1f3dd0ee8 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -36,6 +36,7 @@ export const Signature: React.SFC = (props: SignatureProps) => { props.docsInfo, sectionName, props.isInPopover, + props.name, props.typeDefinitionByName, ); const paramStringArray: any[] = []; @@ -103,9 +104,10 @@ function renderParameters( docsInfo: DocsInfo, sectionName: string, isInPopover: boolean, + name: string, typeDefinitionByName?: TypeDefinitionByName, ): React.ReactNode[] { - const params = _.map(parameters, (p: Parameter) => { + const params = _.map(parameters, (p: Parameter, i: number) => { const isOptional = p.isOptional; const hasDefaultValue = !_.isUndefined(p.defaultValue); const type = ( @@ -121,7 +123,7 @@ function renderParameters( {!_.isEmpty(p.name) && ( - {p.name} + {p.name} {isOptional && '?'}:{' '} )} diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index fc4db10ad..1e3de3e58 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -124,12 +124,12 @@ export class SignatureBlock extends React.Component ); } - private _renderParameterDescriptions(parameters: Parameter[]): React.ReactNode { - const descriptions = _.map(parameters, parameter => { + private _renderParameterDescriptions(parameters: Parameter[], name: string): React.ReactNode { + const descriptions = _.map(parameters, (parameter: Parameter, i: number) => { const isOptional = parameter.isOptional; return (
diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index b7a94483e..8ff2fa3cc 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -169,10 +169,10 @@ export const Type: React.SFC = (props: TypeProps): any => { break; case TypeDocTypes.Tuple: - const tupleTypes = _.map(type.tupleElements, t => { + const tupleTypes = _.map(type.tupleElements, (t, i) => { return ( = (props: TypeProps): any => { const id = Math.random().toString(); const typeDefinitionAnchorId = isExportedClassReference ? props.type.name - : `${constants.TYPES_SECTION_NAME}-${typeName}`; + : `${props.docsInfo.typeSectionName}-${typeName}`; typeName = ( Date: Thu, 27 Sep 2018 23:00:25 +0100 Subject: Only show arguments if the params are named (i.e not generated getters) --- packages/react-docs/src/components/signature_block.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index 1e3de3e58..cad72daf4 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -32,7 +32,6 @@ export interface SignatureBlockState { const styles: Styles = { chip: { fontSize: 13, - backgroundColor: colors.lightBlueA700, color: colors.white, height: 11, borderRadius: 14, @@ -51,6 +50,7 @@ export class SignatureBlock extends React.Component !_.isEmpty(p.name))); return (
} {method.parameters && - !_.isEmpty(method.parameters) && ( + !_.isEmpty(method.parameters) && + onlyHasNamedParameters && (

ARGUMENTS

- {this._renderParameterDescriptions(method.parameters)} + {this._renderParameterDescriptions(method.parameters, method.name)}
)} {method.returnComment && ( -- cgit From 37ab789e841013a556c88418ddd1d5ae38f2b521 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 23:14:34 +0100 Subject: Remove excessive type --- packages/react-docs/src/components/documentation.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index f1cb32b68..f7feb7717 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -10,7 +10,6 @@ import { utils as sharedUtils, } from '@0xproject/react-shared'; import { - CustomType, DocAgnosticFormat, Event, ExternalExportToLink, @@ -219,7 +218,7 @@ export class Documentation extends React.Component { + const typeDefs = _.map(sortedTypes, (customType, i) => { return ( Date: Thu, 27 Sep 2018 23:30:11 +0100 Subject: Fix linter --- packages/react-docs/src/components/signature_block.tsx | 4 ++-- packages/react-docs/src/components/type.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index cad72daf4..5ec82983a 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -50,7 +50,7 @@ export class SignatureBlock extends React.Component !_.isEmpty(p.name))); + const hasExclusivelyNamedParams = !_.isUndefined(_.find(method.parameters, p => !_.isEmpty(p.name))); return (
} {method.parameters && !_.isEmpty(method.parameters) && - onlyHasNamedParameters && ( + hasExclusivelyNamedParams && (

ARGUMENTS diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index 8ff2fa3cc..028376ba9 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -7,7 +7,6 @@ import { Link as ScrollLink } from 'react-scroll'; import * as ReactTooltip from 'react-tooltip'; import { DocsInfo } from '../docs_info'; -import { constants } from '../utils/constants'; import { Signature } from './signature'; import { TypeDefinition } from './type_definition'; -- cgit From 8531f52456169d6b2103757e8e511710c58a54d0 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 23:32:29 +0100 Subject: Switch over remaining usage of `sections.types` for `typeSectionName` --- packages/react-docs/src/docs_info.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts index bf6aa07a7..092a8c266 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -84,11 +84,11 @@ export class DocsInfo { return menuSubsectionsBySection; } public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): { [name: string]: TypeDefinitionByName } { - if (_.isUndefined(this.sections.types)) { + if (_.isUndefined(docAgnosticFormat[this.typeSectionName])) { return {}; } - const section = docAgnosticFormat[this.sections.types]; + const section = docAgnosticFormat[this.typeSectionName]; const typeDefinitionByName = _.keyBy(section.types, 'name') as any; return typeDefinitionByName; } -- cgit From 545472a38fabfd8a18cb03a23ae02f99917f0f4c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 28 Sep 2018 10:50:55 +0100 Subject: Fix section headers --- packages/react-docs/src/components/documentation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index f7feb7717..df727ad9c 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -265,7 +265,7 @@ export class Documentation extends React.Component
- +
{this._renderNetworkBadgesIfExists(sectionName)}
-- cgit From 398b2926366bfabc4decca48dd24c85c466c48ed Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 28 Sep 2018 11:04:51 +0100 Subject: Add more basic types --- packages/react-docs/src/components/type.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index 028376ba9..5c018f5dd 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -12,7 +12,7 @@ import { Signature } from './signature'; import { TypeDefinition } from './type_definition'; const basicJsTypes = ['string', 'number', 'undefined', 'null', 'boolean']; -const basicSolidityTypes = ['bytes', 'bytes4', 'uint256', 'address']; +const basicSolidityTypes = ['bytes', 'bytes4', 'bytes32', 'uint8', 'uint256', 'address']; const defaultProps = {}; -- cgit From 005a2e12bac3e0ca8762f627ec5e9df6d2991d6e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 28 Sep 2018 11:33:30 +0100 Subject: Fix badge alignment --- packages/react-docs/src/components/documentation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index df727ad9c..a23111297 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -353,7 +353,7 @@ export class Documentation extends React.Component -- cgit