From 249bf0163d8ee71b7329fd58b72e554c0324279c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 3 Apr 2018 16:19:38 +0300 Subject: Move our contract templates to accept Provider instead of Web3Wrapper --- packages/react-docs/src/globals.d.ts | 8 -------- 1 file changed, 8 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/globals.d.ts b/packages/react-docs/src/globals.d.ts index c7cd53854..94e63a32d 100644 --- a/packages/react-docs/src/globals.d.ts +++ b/packages/react-docs/src/globals.d.ts @@ -1,11 +1,3 @@ -declare module 'react-tooltip'; - -// compare-version declarations -declare function compareVersions(firstVersion: string, secondVersion: string): number; -declare module 'compare-versions' { - export = compareVersions; -} - declare module '*.json' { const json: any; /* tslint:disable */ -- cgit v1.2.3 From 7d9c6eafbfd8434c92737a0e9edf8e610984ac90 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 11 Apr 2018 16:53:13 +0900 Subject: Add support for nested methods within type declarations. Make sure they render without a callPath. --- packages/react-docs/src/components/interface.tsx | 3 +-- packages/react-docs/src/components/type.tsx | 1 - packages/react-docs/src/utils/typedoc_utils.ts | 10 +++++++++- 3 files changed, 10 insertions(+), 4 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 541e164e3..bdfdf47c4 100644 --- a/packages/react-docs/src/components/interface.tsx +++ b/packages/react-docs/src/components/interface.tsx @@ -19,7 +19,7 @@ export function Interface(props: InterfaceProps) { return ( {property.name}:{' '} - {property.type.typeDocType !== TypeDocTypes.Reflection ? ( + {property.type && property.type.typeDocType !== TypeDocTypes.Reflection ? ( ) : ( { - const childTypeIfExists = !_.isUndefined(child.type) + let childTypeIfExists = !_.isUndefined(child.type) ? typeDocUtils._convertType(child.type, sections, sectionName, docId) : undefined; + if (child.kindString === KindString.Method) { + childTypeIfExists = { + name: child.name, + typeDocType: TypeDocTypes.Reflection, + method: this._convertMethod(child, isConstructor, sections, sectionName, docId), + }; + } const c: CustomTypeChild = { name: child.name, type: childTypeIfExists, -- cgit v1.2.3 From 1e13e927d022ff9b5eb4297430e13c2a79fa4508 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 11 Apr 2018 17:36:01 +0900 Subject: Add missing space in property declaration --- 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 14fe175cf..800892dc8 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -337,7 +337,7 @@ export class Documentation extends React.Component - {property.name}: + {property.name}:{' '} {property.source && ( -- cgit v1.2.3 From bce97c2543d8f1f4fef3e65086d25ed37977b361 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 11 Apr 2018 17:39:30 +0900 Subject: Add support for displaying default param values --- packages/react-docs/src/components/signature.tsx | 2 ++ packages/react-docs/src/types.ts | 1 + packages/react-docs/src/utils/typedoc_utils.ts | 1 + 3 files changed, 4 insertions(+) (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 83fb1e246..1d3c90261 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -91,6 +91,7 @@ function renderParameters( ) { const params = _.map(parameters, (p: Parameter) => { const isOptional = p.isOptional; + const hasDefaultValue = !_.isUndefined(p.defaultValue); const type = ( {p.name} {isOptional && '?'}: {type} + {hasDefaultValue && ` = ${p.defaultValue}`} ); }); diff --git a/packages/react-docs/src/types.ts b/packages/react-docs/src/types.ts index 2a300c164..3b4a57ad5 100644 --- a/packages/react-docs/src/types.ts +++ b/packages/react-docs/src/types.ts @@ -140,6 +140,7 @@ export interface Parameter { comment: string; isOptional: boolean; type: Type; + defaultValue?: string; } export interface TypeParameter { diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index e9035def0..9c89b135a 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -395,6 +395,7 @@ export const typeDocUtils = { name: entity.name, comment, isOptional, + defaultValue: entity.defaultValue, type, }; return parameter; -- cgit v1.2.3 From ea6706a2afd0870518bb5f211bb49a5b79407291 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 18 Apr 2018 15:28:36 +0900 Subject: Improve rendering of type definition comments --- .../react-docs/src/components/type_definition.tsx | 40 +++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (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 7a1c86da5..6d24145a1 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -122,7 +122,9 @@ export class TypeDefinition extends React.Component
- {customType.comment && } + {customType.comment && ( + + )}
); @@ -132,4 +134,40 @@ export class TypeDefinition extends React.Component { + if (i === 0 || i === segments.length - 1) { + return; + } + const words = s.split(' '); + const property = words[words.length - 1]; + words[words.length - 1] = `\n\n${property}`; + segments[i] = words.join(' '); + }); + const final = segments.join(PROPERTY_DESCRIPTION_DIVIDER); + return final; + } } -- cgit v1.2.3 From 4ea222bbffd7a378712320a2f366d5bbee5920af Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 18 Apr 2018 17:55:16 +0900 Subject: Bold property names --- packages/react-docs/src/components/type_definition.tsx | 7 +++++-- 1 file changed, 5 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 6d24145a1..605b58fbd 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -159,12 +159,15 @@ export class TypeDefinition extends React.Component { - if (i === 0 || i === segments.length - 1) { + if (i === 0) { + segments[i] = `**${s}**`; + return; + } else if (i === segments.length - 1) { return; } const words = s.split(' '); const property = words[words.length - 1]; - words[words.length - 1] = `\n\n${property}`; + words[words.length - 1] = `\n\n**${property}**`; segments[i] = words.join(' '); }); const final = segments.join(PROPERTY_DESCRIPTION_DIVIDER); -- cgit v1.2.3 From 0499541e114e6dd36565428f4f914e0dbdece2b8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Apr 2018 16:36:35 +0200 Subject: Move order utils to @0xproject/order-utils --- packages/react-docs/src/types.ts | 1 + packages/react-docs/src/utils/typedoc_utils.ts | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/types.ts b/packages/react-docs/src/types.ts index 3b4a57ad5..f4e61edc9 100644 --- a/packages/react-docs/src/types.ts +++ b/packages/react-docs/src/types.ts @@ -94,6 +94,7 @@ export enum KindString { Method = 'Method', Interface = 'Interface', TypeAlias = 'Type alias', + ObjectLiteral = 'Object literal', Variable = 'Variable', Function = 'Function', Enumeration = 'Enumeration', diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index 9c89b135a..0c7803a04 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -93,10 +93,16 @@ export const typeDocUtils = { throw new Error('`react-docs` only supports projects with 1 exported class per file'); } const isClassExport = packageDefinitionWithMergedChildren.children[0].kindString === KindString.Class; + const isObjectLiteralExport = + packageDefinitionWithMergedChildren.children[0].kindString === KindString.ObjectLiteral; if (isClassExport) { entities = packageDefinitionWithMergedChildren.children[0].children; const commentObj = packageDefinitionWithMergedChildren.children[0].comment; packageComment = !_.isUndefined(commentObj) ? commentObj.shortText : packageComment; + } else if (isObjectLiteralExport) { + entities = packageDefinitionWithMergedChildren.children[0].children; + const commentObj = packageDefinitionWithMergedChildren.children[0].comment; + packageComment = !_.isUndefined(commentObj) ? commentObj.shortText : packageComment; } else { entities = packageDefinitionWithMergedChildren.children; } -- cgit v1.2.3 From 1a36459ab84d538eef18b6c009fdec4d09cb3aef Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 22:41:39 +0200 Subject: Fix property name --- 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 800892dc8..0a525f702 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -91,7 +91,7 @@ export class Documentation extends React.Component Date: Fri, 11 May 2018 17:38:51 +0200 Subject: Add missing type definitions --- packages/react-docs/src/components/badge.tsx | 4 ++-- packages/react-docs/src/components/custom_enum.tsx | 4 ++-- packages/react-docs/src/components/documentation.tsx | 18 +++++++++--------- packages/react-docs/src/components/enum.tsx | 4 ++-- .../react-docs/src/components/event_definition.tsx | 6 +++--- packages/react-docs/src/components/interface.tsx | 4 ++-- packages/react-docs/src/components/signature.tsx | 4 ++-- packages/react-docs/src/components/signature_block.tsx | 8 ++++---- packages/react-docs/src/components/source_link.tsx | 4 ++-- packages/react-docs/src/components/type_definition.tsx | 8 ++++---- packages/react-docs/src/docs_info.ts | 5 +++-- packages/react-docs/src/utils/doxity_utils.ts | 4 ++-- packages/react-docs/src/utils/typedoc_utils.ts | 2 +- packages/react-docs/src/utils/utils.ts | 2 +- 14 files changed, 39 insertions(+), 38 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/badge.tsx b/packages/react-docs/src/components/badge.tsx index b342f2dca..0137b153b 100644 --- a/packages/react-docs/src/components/badge.tsx +++ b/packages/react-docs/src/components/badge.tsx @@ -31,7 +31,7 @@ export class Badge extends React.Component { isHovering: false, }; } - public render() { + public render(): React.ReactNode { const badgeStyle = { ...styles.badge, backgroundColor: this.props.backgroundColor, @@ -48,7 +48,7 @@ export class Badge extends React.Component { ); } - private _setHoverState(isHovering: boolean) { + private _setHoverState(isHovering: boolean): void { this.setState({ isHovering, }); diff --git a/packages/react-docs/src/components/custom_enum.tsx b/packages/react-docs/src/components/custom_enum.tsx index 1fe55eedc..797372f35 100644 --- a/packages/react-docs/src/components/custom_enum.tsx +++ b/packages/react-docs/src/components/custom_enum.tsx @@ -14,7 +14,7 @@ export interface CustomEnumProps { // This component renders custom string enums that was a work-around for versions of // TypeScript <2.4.0 that did not support them natively. We keep it around to support // older versions of 0x.js <0.9.0 -export function CustomEnum(props: CustomEnumProps) { +export const CustomEnum = (props: CustomEnumProps) => { const type = props.type; if (!_.startsWith(type.defaultValue, STRING_ENUM_CODE_PREFIX)) { logUtils.log('We do not yet support `Variable` types that are not strEnums'); @@ -31,4 +31,4 @@ export function CustomEnum(props: CustomEnumProps) { {`}`} ); -} +}; diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 0a525f702..25687db67 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -71,19 +71,19 @@ export class Documentation extends React.Component ); } - private _renderLoading(mainContainersStyles: React.CSSProperties) { + private _renderLoading(mainContainersStyles: React.CSSProperties): React.ReactNode { return (
); } - private _renderNetworkBadgesIfExists(sectionName: string) { + private _renderNetworkBadgesIfExists(sectionName: string): React.ReactNode { if (this.props.docsInfo.type !== SupportedDocJson.Doxity) { return null; } @@ -368,17 +368,17 @@ export class Documentation extends React.Component ); } - private _onSidebarHover(event: React.FormEvent) { + private _onSidebarHover(event: React.FormEvent): void { this.setState({ isHoveringSidebar: true, }); } - private _onSidebarHoverOff() { + private _onSidebarHoverOff(): void { this.setState({ isHoveringSidebar: false, }); } - private _onHashChanged(event: any) { + private _onHashChanged(event: any): void { const hash = window.location.hash.slice(1); sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID); } diff --git a/packages/react-docs/src/components/enum.tsx b/packages/react-docs/src/components/enum.tsx index 37f82f26e..536385d90 100644 --- a/packages/react-docs/src/components/enum.tsx +++ b/packages/react-docs/src/components/enum.tsx @@ -7,7 +7,7 @@ export interface EnumProps { values: EnumValue[]; } -export function Enum(props: EnumProps) { +export const Enum = (props: EnumProps) => { const values = _.map(props.values, (value, i) => { const defaultValueIfAny = !_.isUndefined(value.defaultValue) ? ` = ${value.defaultValue}` : ''; return `\n\t${value.name}${defaultValueIfAny},`; @@ -20,4 +20,4 @@ export function Enum(props: EnumProps) { {`}`} ); -} +}; diff --git a/packages/react-docs/src/components/event_definition.tsx b/packages/react-docs/src/components/event_definition.tsx index 67729ac87..b4dc729a9 100644 --- a/packages/react-docs/src/components/event_definition.tsx +++ b/packages/react-docs/src/components/event_definition.tsx @@ -24,7 +24,7 @@ export class EventDefinition extends React.Component ); } - private _renderEventCode() { + private _renderEventCode(): React.ReactNode { const indexed = indexed; const eventArgs = _.map(this.props.event.eventArgs, (eventArg: EventArg) => { const type = ( @@ -76,7 +76,7 @@ export class EventDefinition extends React.Component ); } - private _setAnchorVisibility(shouldShowAnchor: boolean) { + private _setAnchorVisibility(shouldShowAnchor: boolean): void { this.setState({ shouldShowAnchor, }); diff --git a/packages/react-docs/src/components/interface.tsx b/packages/react-docs/src/components/interface.tsx index bdfdf47c4..a881c7fec 100644 --- a/packages/react-docs/src/components/interface.tsx +++ b/packages/react-docs/src/components/interface.tsx @@ -13,7 +13,7 @@ export interface InterfaceProps { docsInfo: DocsInfo; } -export function Interface(props: InterfaceProps) { +export const Interface = (props: InterfaceProps) => { const type = props.type; const properties = _.map(type.children, property => { return ( @@ -63,4 +63,4 @@ export function Interface(props: InterfaceProps) { {`}`} ); -} +}; diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index 1d3c90261..c4a6394fa 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -88,7 +88,7 @@ function renderParameters( docsInfo: DocsInfo, sectionName: string, typeDefinitionByName?: TypeDefinitionByName, -) { +): React.ReactNode[] { const params = _.map(parameters, (p: Parameter) => { const isOptional = p.isOptional; const hasDefaultValue = !_.isUndefined(p.defaultValue); @@ -116,7 +116,7 @@ function renderTypeParameter( docsInfo: DocsInfo, sectionName: string, typeDefinitionByName?: TypeDefinitionByName, -) { +): React.ReactNode { const typeParam = ( {`<${typeParameter.name} extends `} diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index 6475d3995..9e5198e16 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -42,7 +42,7 @@ export class SignatureBlock extends React.Component ); } - private _renderChip(text: string) { + private _renderChip(text: string): React.ReactNode { return (
{text}
); } - private _renderParameterDescriptions(parameters: Parameter[]) { + private _renderParameterDescriptions(parameters: Parameter[]): React.ReactNode { const descriptions = _.map(parameters, parameter => { const isOptional = parameter.isOptional; return ( @@ -146,7 +146,7 @@ export class SignatureBlock extends React.Component { const src = props.source; const sourceCodeUrl = `${props.sourceUrl}/${src.fileName}#L${src.line}`; return ( @@ -20,4 +20,4 @@ export function SourceLink(props: SourceLinkProps) {
); -} +}; diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx index 605b58fbd..a8e601ac2 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -3,7 +3,7 @@ import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { CustomType, CustomTypeChild, KindString, TypeDocTypes } from '../types'; +import { CustomType, CustomTypeChild, EnumValue, KindString, TypeDocTypes } from '../types'; import { constants } from '../utils/constants'; import { utils } from '../utils/utils'; @@ -35,7 +35,7 @@ export class TypeDefinition extends React.Component ); } - private _setAnchorVisibility(shouldShowAnchor: boolean) { + private _setAnchorVisibility(shouldShowAnchor: boolean): void { this.setState({ shouldShowAnchor, }); @@ -150,7 +150,7 @@ export class TypeDefinition extends React.Component Date: Wed, 16 May 2018 14:59:10 +0200 Subject: Fix TSLint rules --- 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 e9c84b7c9..6f4f39f00 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -64,8 +64,8 @@ export class DocsInfo { finalMenu.contracts = _.filter(finalMenu.contracts, (contractName: string) => { const versionIntroducedIfExists = this._docsInfo.menuSubsectionToVersionWhenIntroduced[contractName]; if (!_.isUndefined(versionIntroducedIfExists)) { - const existsInSelectedVersion = compareVersions(selectedVersion, versionIntroducedIfExists) >= 0; - return existsInSelectedVersion; + const doesExistInSelectedVersion = compareVersions(selectedVersion, versionIntroducedIfExists) >= 0; + return doesExistInSelectedVersion; } else { return true; } -- cgit v1.2.3 From 9778695b4ad1fd999eb79b01c768a2f2b9938917 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 4 Jun 2018 19:48:21 -0700 Subject: Try enabling no-unused-variable... --- packages/react-docs/src/components/badge.tsx | 1 - packages/react-docs/src/components/comment.tsx | 1 - packages/react-docs/src/components/custom_enum.tsx | 1 - packages/react-docs/src/components/documentation.tsx | 4 ---- packages/react-docs/src/components/signature.tsx | 1 - packages/react-docs/src/components/source_link.tsx | 1 - packages/react-docs/src/components/type.tsx | 11 ----------- packages/react-docs/src/components/type_definition.tsx | 2 +- 8 files changed, 1 insertion(+), 21 deletions(-) (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/badge.tsx b/packages/react-docs/src/components/badge.tsx index 0137b153b..d34f8a0fc 100644 --- a/packages/react-docs/src/components/badge.tsx +++ b/packages/react-docs/src/components/badge.tsx @@ -1,5 +1,4 @@ import { Styles } from '@0xproject/react-shared'; -import * as _ from 'lodash'; import * as React from 'react'; const styles: Styles = { diff --git a/packages/react-docs/src/components/comment.tsx b/packages/react-docs/src/components/comment.tsx index 0d63d4d31..c3687c510 100644 --- a/packages/react-docs/src/components/comment.tsx +++ b/packages/react-docs/src/components/comment.tsx @@ -1,5 +1,4 @@ import { MarkdownCodeBlock } from '@0xproject/react-shared'; -import * as _ from 'lodash'; import * as React from 'react'; import * as ReactMarkdown from 'react-markdown'; diff --git a/packages/react-docs/src/components/custom_enum.tsx b/packages/react-docs/src/components/custom_enum.tsx index 797372f35..c4252d9e2 100644 --- a/packages/react-docs/src/components/custom_enum.tsx +++ b/packages/react-docs/src/components/custom_enum.tsx @@ -3,7 +3,6 @@ import * as _ from 'lodash'; import * as React from 'react'; import { CustomType } from '../types'; -import { utils } from '../utils/utils'; const STRING_ENUM_CODE_PREFIX = ' strEnum('; diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 25687db67..2b021f04c 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -3,7 +3,6 @@ import { constants as sharedConstants, EtherscanLinkSuffixes, MarkdownSection, - MenuSubsectionsBySection, NestedSidebarMenu, Networks, SectionHeader, @@ -13,13 +12,11 @@ import { import * as _ from 'lodash'; import CircularProgress from 'material-ui/CircularProgress'; import * as React from 'react'; -import { scroller } from 'react-scroll'; import { DocsInfo } from '../docs_info'; import { AddressByContractName, DocAgnosticFormat, - DoxityDocObj, Event, Property, SolidityMethod, @@ -29,7 +26,6 @@ import { TypescriptMethod, } from '../types'; import { constants } from '../utils/constants'; -import { utils } from '../utils/utils'; import { Badge } from './badge'; import { Comment } from './comment'; diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index c4a6394fa..77e9cc909 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -1,6 +1,5 @@ import * as _ from 'lodash'; import * as React from 'react'; -import * as ReactDOM from 'react-dom'; import { DocsInfo } from '../docs_info'; import { Parameter, Type as TypeDef, TypeDefinitionByName, TypeParameter } from '../types'; diff --git a/packages/react-docs/src/components/source_link.tsx b/packages/react-docs/src/components/source_link.tsx index 58a9ba6a7..c60435ea6 100644 --- a/packages/react-docs/src/components/source_link.tsx +++ b/packages/react-docs/src/components/source_link.tsx @@ -1,5 +1,4 @@ import { colors } from '@0xproject/react-shared'; -import * as _ from 'lodash'; import * as React from 'react'; import { Source } from '../types'; diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index 2b7b49672..caf0796ee 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -6,22 +6,11 @@ import * as ReactTooltip from 'react-tooltip'; import { DocsInfo } from '../docs_info'; import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types'; -import { constants } from '../utils/constants'; import { utils } from '../utils/utils'; import { Signature } from './signature'; import { TypeDefinition } from './type_definition'; -const typeToSection: { [typeName: string]: string } = { - ExchangeWrapper: 'exchange', - TokenWrapper: 'token', - TokenRegistryWrapper: 'tokenRegistry', - EtherTokenWrapper: 'etherToken', - ProxyWrapper: 'proxy', - TokenTransferProxyWrapper: 'proxy', - OrderStateWatcher: 'orderWatcher', -}; - export interface TypeProps { type: TypeDef; docsInfo: DocsInfo; diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx index a8e601ac2..fdaad556b 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -3,7 +3,7 @@ import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { CustomType, CustomTypeChild, EnumValue, KindString, TypeDocTypes } from '../types'; +import { CustomType, CustomTypeChild, KindString, TypeDocTypes } from '../types'; import { constants } from '../utils/constants'; import { utils } from '../utils/utils'; -- cgit v1.2.3 From cf8fdd3a701f21bfc3b2ec8397fa65948f5cdc78 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 6 Jun 2018 16:26:04 +0200 Subject: Move spawnSwitchErr to @0xproject/utils --- packages/react-docs/src/components/custom_enum.tsx | 1 - packages/react-docs/src/components/documentation.tsx | 1 - packages/react-docs/src/components/type.tsx | 4 ++-- packages/react-docs/src/components/type_definition.tsx | 4 ++-- packages/react-docs/src/utils/typedoc_utils.ts | 4 ++-- packages/react-docs/src/utils/utils.ts | 5 ----- 6 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 packages/react-docs/src/utils/utils.ts (limited to 'packages/react-docs/src') diff --git a/packages/react-docs/src/components/custom_enum.tsx b/packages/react-docs/src/components/custom_enum.tsx index 797372f35..c4252d9e2 100644 --- a/packages/react-docs/src/components/custom_enum.tsx +++ b/packages/react-docs/src/components/custom_enum.tsx @@ -3,7 +3,6 @@ import * as _ from 'lodash'; import * as React from 'react'; import { CustomType } from '../types'; -import { utils } from '../utils/utils'; const STRING_ENUM_CODE_PREFIX = ' strEnum('; diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 25687db67..f34d9f1fb 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -29,7 +29,6 @@ import { TypescriptMethod, } from '../types'; import { constants } from '../utils/constants'; -import { utils } from '../utils/utils'; import { Badge } from './badge'; import { Comment } from './comment'; diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index 2b7b49672..007d7da3e 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -1,4 +1,5 @@ import { colors, constants as sharedConstants, utils as sharedUtils } from '@0xproject/react-shared'; +import { errorUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { Link as ScrollLink } from 'react-scroll'; @@ -7,7 +8,6 @@ import * as ReactTooltip from 'react-tooltip'; import { DocsInfo } from '../docs_info'; import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types'; import { constants } from '../utils/constants'; -import { utils } from '../utils/utils'; import { Signature } from './signature'; import { TypeDefinition } from './type_definition'; @@ -140,7 +140,7 @@ export function Type(props: TypeProps): any { break; default: - throw utils.spawnSwitchErr('type.typeDocType', type.typeDocType); + throw errorUtils.spawnSwitchErr('type.typeDocType', type.typeDocType); } // HACK: Normalize BigNumber to simply BigNumber. For some reason the type // name is unpredictably one or the other. diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx index a8e601ac2..f11b8f973 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -1,11 +1,11 @@ import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared'; +import { errorUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; import { CustomType, CustomTypeChild, EnumValue, KindString, TypeDocTypes } from '../types'; import { constants } from '../utils/constants'; -import { utils } from '../utils/utils'; import { Comment } from './comment'; import { CustomEnum } from './custom_enum'; @@ -96,7 +96,7 @@ export class TypeDefinition extends React.Component Date: Mon, 11 Jun 2018 23:42:30 +0200 Subject: Fix no-unused-variable tslint rule to include parameters and fix issues --- packages/react-docs/src/components/documentation.tsx | 6 +++--- packages/react-docs/src/components/enum.tsx | 2 +- 2 files changed, 4 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 2b021f04c..a4e6f4f6e 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -73,7 +73,7 @@ export class Documentation extends React.Component ); } - private _onSidebarHover(event: React.FormEvent): void { + private _onSidebarHover(_event: React.FormEvent): void { this.setState({ isHoveringSidebar: true, }); @@ -374,7 +374,7 @@ export class Documentation extends React.Component { - const values = _.map(props.values, (value, i) => { + const values = _.map(props.values, value => { const defaultValueIfAny = !_.isUndefined(value.defaultValue) ? ` = ${value.defaultValue}` : ''; return `\n\t${value.name}${defaultValueIfAny},`; }); -- cgit v1.2.3 From 324b1079e7eb29829bf06ff65299acdc58abf308 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 9 Jul 2018 19:05:38 +0200 Subject: Add ability to nest doc ref markdown under specific versions --- packages/react-docs/src/components/documentation.tsx | 10 +++++++++- packages/react-docs/src/docs_info.ts | 4 ++-- packages/react-docs/src/types.ts | 6 +++++- 3 files changed, 16 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 a4e6f4f6e..7030001e8 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -12,6 +12,7 @@ import { import * as _ from 'lodash'; import CircularProgress from 'material-ui/CircularProgress'; import * as React from 'react'; +import * as semver from 'semver'; import { DocsInfo } from '../docs_info'; import { @@ -180,7 +181,14 @@ export class Documentation extends React.Component { + return semver.lte(mdVersion, this.props.selectedVersion); + }); + const sortedEligibleVersions = eligibleVersions.sort(semver.rcompare.bind(semver)); + const closestVersion = sortedEligibleVersions[0]; + const markdownFileIfExists = this.props.docsInfo.sectionNameToMarkdownByVersion[closestVersion][sectionName]; if (!_.isUndefined(markdownFileIfExists)) { return ( Date: Mon, 9 Jul 2018 19:53:54 +0200 Subject: Remove comment and add assertion --- packages/react-docs/src/components/documentation.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 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 7030001e8..ff33220d2 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -182,10 +182,16 @@ export class Documentation extends React.Component { return semver.lte(mdVersion, this.props.selectedVersion); }); + if (_.isEmpty(eligibleVersions)) { + throw new Error( + `No eligible markdown sections found for ${this.props.docsInfo.displayName} version ${ + this.props.selectedVersion + }.`, + ); + } const sortedEligibleVersions = eligibleVersions.sort(semver.rcompare.bind(semver)); const closestVersion = sortedEligibleVersions[0]; const markdownFileIfExists = this.props.docsInfo.sectionNameToMarkdownByVersion[closestVersion][sectionName]; -- cgit v1.2.3 From 1aaf633df883f62fad890b2d87a2dc89067821c5 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 9 Jul 2018 19:59:26 +0200 Subject: Add missing import --- packages/react-docs/src/docs_info.ts | 1 + 1 file changed, 1 insertion(+) (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 e9f3c13fe..810674d51 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -9,6 +9,7 @@ import { DocsInfoTypeConfigs, DocsMenu, DoxityDocObj, + SectionNameToMarkdownByVersion, SectionsMap, SupportedDocJson, TypeDefinitionByName, -- cgit v1.2.3 From bf8ac3b9e6ee59f267f7850418febfe84dedceb8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 17 Jul 2018 12:59:02 +0200 Subject: Fix tslint issues --- packages/react-docs/src/docs_info.ts | 2 +- packages/react-docs/src/utils/doxity_utils.ts | 22 +++++++++++----------- packages/react-docs/src/utils/typedoc_utils.ts | 2 +- 3 files changed, 13 insertions(+), 13 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 6f4f39f00..5d46dbda6 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -27,7 +27,7 @@ export class DocsInfo { public sectionNameToMarkdown: { [sectionName: string]: string }; public contractsByVersionByNetworkId?: ContractsByVersionByNetworkId; public typeConfigs: DocsInfoTypeConfigs; - private _docsInfo: DocsInfoConfig; + private readonly _docsInfo: DocsInfoConfig; constructor(config: DocsInfoConfig) { this.id = config.id; this.type = config.type; diff --git a/packages/react-docs/src/utils/doxity_utils.ts b/packages/react-docs/src/utils/doxity_utils.ts index 374ee07dd..6815daa0c 100644 --- a/packages/react-docs/src/utils/doxity_utils.ts +++ b/packages/react-docs/src/utils/doxity_utils.ts @@ -31,8 +31,8 @@ export const doxityUtils = { comment: doxityConstructor.details, returnComment: doxityConstructor.return, callPath: '', - parameters: this._convertParameters(doxityConstructor.inputs), - returnType: this._convertType(doxityContractObj.name), + parameters: doxityUtils._convertParameters(doxityConstructor.inputs), + returnType: doxityUtils._convertType(doxityContractObj.name), }; constructors.push(constructor); } @@ -40,7 +40,7 @@ export const doxityUtils = { const doxityMethods: DoxityAbiDoc[] = _.filter( doxityContractObj.abiDocs, (abiDoc: DoxityAbiDoc) => { - return this._isMethod(abiDoc); + return doxityUtils._isMethod(abiDoc); }, ); const methods: SolidityMethod[] = _.map( @@ -52,10 +52,10 @@ export const doxityUtils = { // no-op. It's already undefined } else if (outputs.length === 1) { const outputsType = outputs[0].type; - returnTypeIfExists = this._convertType(outputsType); + returnTypeIfExists = doxityUtils._convertType(outputsType); } else { const outputsType = `[${_.map(outputs, output => output.type).join(', ')}]`; - returnTypeIfExists = this._convertType(outputsType); + returnTypeIfExists = doxityUtils._convertType(outputsType); } // For ZRXToken, we want to convert it to zrxToken, rather then simply zRXToken const callPath = @@ -70,7 +70,7 @@ export const doxityUtils = { comment: doxityMethod.details, returnComment: doxityMethod.return, callPath, - parameters: this._convertParameters(doxityMethod.inputs), + parameters: doxityUtils._convertParameters(doxityMethod.inputs), returnType: returnTypeIfExists, }; return method; @@ -80,7 +80,7 @@ export const doxityUtils = { const doxityProperties: DoxityAbiDoc[] = _.filter( doxityContractObj.abiDocs, (abiDoc: DoxityAbiDoc) => { - return this._isProperty(abiDoc); + return doxityUtils._isProperty(abiDoc); }, ); const properties = _.map(doxityProperties, (doxityProperty: DoxityAbiDoc) => { @@ -92,7 +92,7 @@ export const doxityUtils = { } const property = { name: doxityProperty.name, - type: this._convertType(typeName), + type: doxityUtils._convertType(typeName), comment: doxityProperty.details, }; return property; @@ -105,7 +105,7 @@ export const doxityUtils = { const events = _.map(doxityEvents, doxityEvent => { const event = { name: doxityEvent.name, - eventArgs: this._convertEventArgs(doxityEvent.inputs), + eventArgs: doxityUtils._convertEventArgs(doxityEvent.inputs), }; return event; }); @@ -129,7 +129,7 @@ export const doxityUtils = { name: input.name, comment: input.description, isOptional: false, - type: this._convertType(input.type), + type: doxityUtils._convertType(input.type), }; return parameter; }); @@ -167,7 +167,7 @@ export const doxityUtils = { const eventArg = { isIndexed: input.indexed, name: input.name, - type: this._convertType(input.type), + type: doxityUtils._convertType(input.type), }; return eventArg; }); diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index 5633d9040..a6d938e94 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -235,7 +235,7 @@ export const typeDocUtils = { childTypeIfExists = { name: child.name, typeDocType: TypeDocTypes.Reflection, - method: this._convertMethod(child, isConstructor, sections, sectionName, docId), + method: typeDocUtils._convertMethod(child, isConstructor, sections, sectionName, docId), }; } const c: CustomTypeChild = { -- cgit v1.2.3