Add support for intersection types in docs

This commit is contained in:
Brandon Millman 2018-02-14 10:16:00 -08:00
parent 3510985cf4
commit 2897b72967
3 changed files with 25 additions and 2 deletions

View File

@ -6,7 +6,8 @@ import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Documentation as DocumentationComponent, DocumentationAllProps } from 'ts/pages/documentation/documentation'; import { Documentation as DocumentationComponent, DocumentationAllProps } from 'ts/pages/documentation/documentation';
import { Dispatcher } from 'ts/redux/dispatcher'; import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer'; import { State } from 'ts/redux/reducer';
import { DocsInfoConfig, WebsitePaths } from 'ts/types'; import { DocsInfoConfig, Environments, WebsitePaths } from 'ts/types';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { typeDocUtils } from 'ts/utils/typedoc_utils'; import { typeDocUtils } from 'ts/utils/typedoc_utils';
@ -23,12 +24,16 @@ const connectDocSections = {
types: constants.TYPES_SECTION_NAME, types: constants.TYPES_SECTION_NAME,
}; };
const s3BucketName =
configs.ENVIRONMENT === Environments.DEVELOPMENT ? 'staging-connect-docs-jsons' : 'connect-docs-jsons';
const docsJsonRoot = `https://s3.amazonaws.com/${s3BucketName}`;
const docsInfoConfig: DocsInfoConfig = { const docsInfoConfig: DocsInfoConfig = {
displayName: '0x Connect', displayName: '0x Connect',
subPackageName: 'connect', subPackageName: 'connect',
packageUrl: 'https://github.com/0xProject/0x.js', packageUrl: 'https://github.com/0xProject/0x.js',
websitePath: WebsitePaths.Connect, websitePath: WebsitePaths.Connect,
docsJsonRoot: 'https://s3.amazonaws.com/connect-docs-jsons', docsJsonRoot,
menu: { menu: {
introduction: [connectDocSections.introduction], introduction: [connectDocSections.introduction],
install: [connectDocSections.installation], install: [connectDocSections.installation],

View File

@ -118,6 +118,23 @@ export function Type(props: TypeProps): any {
typeName = type.name; typeName = type.name;
break; break;
case TypeDocTypes.Intersection:
const intersectionsTypes = _.map(type.types, t => {
return (
<Type
key={`type-${t.name}-${t.value}-${t.typeDocType}`}
type={t}
sectionName={props.sectionName}
typeDefinitionByName={props.typeDefinitionByName}
docsInfo={props.docsInfo}
/>
);
});
typeName = _.reduce(intersectionsTypes, (prev: React.ReactNode, curr: React.ReactNode) => {
return [prev, '&', curr];
});
break;
default: default:
throw utils.spawnSwitchErr('type.typeDocType', type.typeDocType); throw utils.spawnSwitchErr('type.typeDocType', type.typeDocType);
} }

View File

@ -324,6 +324,7 @@ export enum TypeDocTypes {
Reflection = 'reflection', Reflection = 'reflection',
Union = 'union', Union = 'union',
TypeParameter = 'typeParameter', TypeParameter = 'typeParameter',
Intersection = 'intersection',
Unknown = 'unknown', Unknown = 'unknown',
} }