From 6182d2c7f60967a978f2b885e63fab067794b452 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 6 Aug 2018 15:28:21 -0400 Subject: Pass in typeDefinitionByName so that type declarations also link to inner-types and show the popover --- packages/react-docs/src/components/documentation.tsx | 13 +++++++++++-- packages/react-docs/src/components/interface.tsx | 19 ++++++++++++++++--- packages/react-docs/src/components/property_block.tsx | 10 ++++++++-- packages/react-docs/src/components/type.tsx | 8 +++++++- .../react-docs/src/components/type_definition.tsx | 12 ++++++++++-- 5 files changed, 52 insertions(+), 10 deletions(-) (limited to 'packages/react-docs/src/components') diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index d9a7dcd59..1c32b2e16 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -225,12 +225,16 @@ export class Documentation extends React.Component ); }); const sortedProperties = _.sortBy(docSection.properties, 'name'); - const propertyDefs = _.map(sortedProperties, this._renderProperty.bind(this, sectionName)); + const propertyDefs = _.map( + sortedProperties, + this._renderProperty.bind(this, sectionName, typeDefinitionByName), + ); const sortedMethods = _.sortBy(docSection.methods, 'name'); const methodDefs = _.map(sortedMethods, method => { @@ -349,7 +353,11 @@ export class Documentation extends React.Component{constructorDefs}; } - private _renderProperty(sectionName: string, property: Property): React.ReactNode { + private _renderProperty( + sectionName: string, + typeDefinitionByName: TypeDefinitionByName, + property: Property, + ): React.ReactNode { return ( ); } diff --git a/packages/react-docs/src/components/interface.tsx b/packages/react-docs/src/components/interface.tsx index 915b4bbc6..eaf57ce93 100644 --- a/packages/react-docs/src/components/interface.tsx +++ b/packages/react-docs/src/components/interface.tsx @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { CustomType } from '../types'; +import { CustomType, TypeDefinitionByName } from '../types'; import { Signature } from './signature'; import { Type } from './type'; @@ -11,6 +11,7 @@ export interface InterfaceProps { type: CustomType; sectionName: string; docsInfo: DocsInfo; + typeDefinitionByName: TypeDefinitionByName; } export const Interface = (props: InterfaceProps) => { @@ -29,9 +30,15 @@ export const Interface = (props: InterfaceProps) => { shouldHideMethodName={true} shouldUseArrowSyntax={true} docsInfo={props.docsInfo} + typeDefinitionByName={props.typeDefinitionByName} /> ) : ( - + )}, ); @@ -41,7 +48,13 @@ export const Interface = (props: InterfaceProps) => { const is = type.indexSignature; const param = ( - {is.keyName}: + {is.keyName}:{' '} + ); properties.push( diff --git a/packages/react-docs/src/components/property_block.tsx b/packages/react-docs/src/components/property_block.tsx index ea80ba7b7..6e5c451be 100644 --- a/packages/react-docs/src/components/property_block.tsx +++ b/packages/react-docs/src/components/property_block.tsx @@ -2,7 +2,7 @@ import { AnchorTitle, HeaderSizes } from '@0xproject/react-shared'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { Property } from '../types'; +import { Property, TypeDefinitionByName } from '../types'; import { constants } from '../utils/constants'; import { Comment } from './comment'; @@ -15,6 +15,7 @@ export interface PropertyBlockProps { docsInfo: DocsInfo; sourceUrl: string; selectedVersion: string; + typeDefinitionByName: TypeDefinitionByName; } export interface PropertyBlockState { @@ -50,7 +51,12 @@ export class PropertyBlock extends React.Component {(property as any).callPath} {property.name}:{' '} - + {property.source && ( {is.keyName}:{' '} - + ); typeName = ( @@ -222,6 +227,7 @@ export function Type(props: TypeProps): any { customType={typeDefinition} shouldAddId={false} docsInfo={props.docsInfo} + typeDefinitionByName={props.typeDefinitionByName} /> diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx index 26fbbf75c..775d9890f 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -4,7 +4,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, KindString, TypeDocTypes, TypeDefinitionByName } from '../types'; import { constants } from '../utils/constants'; import { Comment } from './comment'; @@ -19,6 +19,7 @@ export interface TypeDefinitionProps { customType: CustomType; shouldAddId?: boolean; docsInfo: DocsInfo; + typeDefinitionByName?: TypeDefinitionByName; } export interface TypeDefinitionState { @@ -44,7 +45,12 @@ export class TypeDefinition extends React.Component + ); break; @@ -74,6 +80,7 @@ export class TypeDefinition extends React.Component ) : ( )} -- cgit v1.2.3