aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-07 22:19:59 +0800
committerFabio Berger <me@fabioberger.com>2018-03-07 22:19:59 +0800
commit9aec1feae30870b3e6c8a778051877c83aacbe58 (patch)
treee49064325db9c51cc82acc5e177866ad806f7862 /packages
parent8517de128b591c67f059d6c47722dfa81eeb9828 (diff)
downloaddexon-0x-contracts-9aec1feae30870b3e6c8a778051877c83aacbe58.tar
dexon-0x-contracts-9aec1feae30870b3e6c8a778051877c83aacbe58.tar.gz
dexon-0x-contracts-9aec1feae30870b3e6c8a778051877c83aacbe58.tar.bz2
dexon-0x-contracts-9aec1feae30870b3e6c8a778051877c83aacbe58.tar.lz
dexon-0x-contracts-9aec1feae30870b3e6c8a778051877c83aacbe58.tar.xz
dexon-0x-contracts-9aec1feae30870b3e6c8a778051877c83aacbe58.tar.zst
dexon-0x-contracts-9aec1feae30870b3e6c8a778051877c83aacbe58.zip
Move remaining type configs to topLevel DocsInfoConfigs
Diffstat (limited to 'packages')
-rw-r--r--packages/react-docs/example/ts/docs.tsx32
-rw-r--r--packages/react-docs/src/ts/components/type.tsx32
-rw-r--r--packages/react-docs/src/ts/docs_info.ts7
-rw-r--r--packages/react-docs/src/ts/types.ts10
-rw-r--r--packages/react-docs/src/ts/utils/constants.ts6
-rw-r--r--packages/website/ts/containers/connect_documentation.ts52
-rw-r--r--packages/website/ts/containers/zero_ex_js_documentation.ts146
-rw-r--r--packages/website/ts/utils/constants.ts6
8 files changed, 176 insertions, 115 deletions
diff --git a/packages/react-docs/example/ts/docs.tsx b/packages/react-docs/example/ts/docs.tsx
index c4b165c13..f1c4a31bd 100644
--- a/packages/react-docs/example/ts/docs.tsx
+++ b/packages/react-docs/example/ts/docs.tsx
@@ -32,9 +32,6 @@ const docsInfoConfig: DocsInfoConfig = {
sectionNameToMarkdown: {
[docSections.introduction]: IntroMarkdown,
},
- // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
- // currently no way to extract the re-exported types from index.ts via TypeDoc :(
- publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'],
sectionNameToModulePath: {
[docSections.web3Wrapper]: ['"web3-wrapper/src/index"'],
[docSections.types]: ['"types/src/index"'],
@@ -42,6 +39,35 @@ const docsInfoConfig: DocsInfoConfig = {
menuSubsectionToVersionWhenIntroduced: {},
sections: docSections,
visibleConstructors: [docSections.web3Wrapper],
+ typeConfigs: {
+ // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
+ // currently no way to extract the re-exported types from index.ts via TypeDoc :(
+ publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'],
+ typeNameToExternalLink: {
+ Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
+ Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L123',
+ BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
+ DecodedLogEntryEvent: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
+ LogEntryEvent: 'http://mikemcl.github.io/bignumber.js',
+ CallData: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L348',
+ BlockWithoutTransactionData:
+ 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L314',
+ LogEntry: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L366',
+ FilterObject: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L109',
+ ['Web3.BlockParam']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L278',
+ ['Web3.ContractAbi']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L47',
+ },
+ typeNameToPrefix: {
+ Provider: 'Web3',
+ CallData: 'Web3',
+ BlockWithoutTransactionData: 'Web3',
+ LogEntry: 'Web3',
+ FilterObject: 'Web3',
+ },
+ typeNameToDocSection: {
+ Web3Wrapper: docSections.web3Wrapper,
+ },
+ },
};
const docsInfo = new DocsInfo(docsInfoConfig);
diff --git a/packages/react-docs/src/ts/components/type.tsx b/packages/react-docs/src/ts/components/type.tsx
index f3efbc8dd..56425a5df 100644
--- a/packages/react-docs/src/ts/components/type.tsx
+++ b/packages/react-docs/src/ts/components/type.tsx
@@ -11,21 +11,6 @@ import { utils } from '../utils/utils';
import { TypeDefinition } from './type_definition';
-// Some types reference other libraries. For these types, we want to link the user to the relevant documentation.
-const typeToUrl: { [typeName: string]: string } = {
- Web3: constants.URL_WEB3_DOCS,
- Provider: constants.URL_WEB3_PROVIDER_DOCS,
- BigNumber: constants.URL_BIGNUMBERJS_GITHUB,
- DecodedLogEntryEvent: constants.URL_WEB3_DECODED_LOG_ENTRY_EVENT,
- LogEntryEvent: constants.URL_WEB3_LOG_ENTRY_EVENT,
-};
-
-const typePrefix: { [typeName: string]: string } = {
- Provider: 'Web3',
- DecodedLogEntryEvent: 'Web3',
- LogEntryEvent: 'Web3',
-};
-
const typeToSection: { [typeName: string]: string } = {
ExchangeWrapper: 'exchange',
TokenWrapper: 'token',
@@ -149,9 +134,20 @@ export function Type(props: TypeProps): any {
return [prev, ', ', curr];
});
- const typeNameUrlIfExists = typeToUrl[typeName as string];
- const typePrefixIfExists = typePrefix[typeName as string];
- const sectionNameIfExists = typeToSection[typeName as string];
+ let typeNameUrlIfExists;
+ let typePrefixIfExists;
+ let sectionNameIfExists;
+ if (!_.isUndefined(props.docsInfo.typeConfigs)) {
+ typeNameUrlIfExists = !_.isUndefined(props.docsInfo.typeConfigs.typeNameToExternalLink)
+ ? props.docsInfo.typeConfigs.typeNameToExternalLink[typeName as string]
+ : undefined;
+ typePrefixIfExists = !_.isUndefined(props.docsInfo.typeConfigs.typeNameToPrefix)
+ ? props.docsInfo.typeConfigs.typeNameToPrefix[typeName as string]
+ : undefined;
+ sectionNameIfExists = !_.isUndefined(props.docsInfo.typeConfigs.typeNameToDocSection)
+ ? props.docsInfo.typeConfigs.typeNameToDocSection[typeName as string]
+ : undefined;
+ }
if (!_.isUndefined(typeNameUrlIfExists)) {
typeName = (
<a
diff --git a/packages/react-docs/src/ts/docs_info.ts b/packages/react-docs/src/ts/docs_info.ts
index 84d41f58d..68bddef06 100644
--- a/packages/react-docs/src/ts/docs_info.ts
+++ b/packages/react-docs/src/ts/docs_info.ts
@@ -6,6 +6,7 @@ import {
ContractsByVersionByNetworkId,
DocAgnosticFormat,
DocsInfoConfig,
+ DocsInfoTypeConfigs,
DocsMenu,
DoxityDocObj,
SectionsMap,
@@ -24,6 +25,7 @@ export class DocsInfo {
public sections: SectionsMap;
public sectionNameToMarkdown: { [sectionName: string]: string };
public contractsByVersionByNetworkId?: ContractsByVersionByNetworkId;
+ public typeConfigs: DocsInfoTypeConfigs;
private _docsInfo: DocsInfoConfig;
constructor(config: DocsInfoConfig) {
this.id = config.id;
@@ -33,13 +35,14 @@ export class DocsInfo {
this.sections = config.sections;
this.sectionNameToMarkdown = config.sectionNameToMarkdown;
this.contractsByVersionByNetworkId = config.contractsByVersionByNetworkId;
+ this.typeConfigs = config.typeConfigs;
this._docsInfo = config;
}
public isPublicType(typeName: string): boolean {
- if (_.isUndefined(this._docsInfo.publicTypes)) {
+ if (_.isUndefined(this._docsInfo.typeConfigs.publicTypes)) {
return false;
}
- const isPublic = _.includes(this._docsInfo.publicTypes, typeName);
+ const isPublic = _.includes(this._docsInfo.typeConfigs.publicTypes, typeName);
return isPublic;
}
public getModulePathsIfExists(sectionName: string): string[] {
diff --git a/packages/react-docs/src/ts/types.ts b/packages/react-docs/src/ts/types.ts
index cb211e887..d192af313 100644
--- a/packages/react-docs/src/ts/types.ts
+++ b/packages/react-docs/src/ts/types.ts
@@ -7,11 +7,17 @@ export interface DocsInfoConfig {
sections: SectionsMap;
sectionNameToMarkdown: { [sectionName: string]: string };
visibleConstructors: string[];
- subPackageName?: string;
- publicTypes?: string[];
sectionNameToModulePath?: { [sectionName: string]: string[] };
menuSubsectionToVersionWhenIntroduced?: { [sectionName: string]: string };
contractsByVersionByNetworkId?: ContractsByVersionByNetworkId;
+ typeConfigs?: DocsInfoTypeConfigs;
+}
+
+export interface DocsInfoTypeConfigs {
+ typeNameToExternalLink?: { [typeName: string]: string };
+ publicTypes?: string[];
+ typeNameToPrefix?: { [typeName: string]: string };
+ typeNameToDocSection?: { [typeName: string]: string };
}
export interface DocsMenu {
diff --git a/packages/react-docs/src/ts/utils/constants.ts b/packages/react-docs/src/ts/utils/constants.ts
index 6692ce7e4..28079e6c3 100644
--- a/packages/react-docs/src/ts/utils/constants.ts
+++ b/packages/react-docs/src/ts/utils/constants.ts
@@ -1,9 +1,3 @@
export const constants = {
TYPES_SECTION_NAME: 'types',
- URL_WEB3_DOCS: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
- URL_WEB3_DECODED_LOG_ENTRY_EVENT:
- 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L123',
- URL_WEB3_LOG_ENTRY_EVENT: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
- URL_WEB3_PROVIDER_DOCS: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
- URL_BIGNUMBERJS_GITHUB: 'http://mikemcl.github.io/bignumber.js',
};
diff --git a/packages/website/ts/containers/connect_documentation.ts b/packages/website/ts/containers/connect_documentation.ts
index 33e12f5d0..bd6821d19 100644
--- a/packages/website/ts/containers/connect_documentation.ts
+++ b/packages/website/ts/containers/connect_documentation.ts
@@ -40,29 +40,6 @@ const docsInfoConfig: DocsInfoConfig = {
[connectDocSections.introduction]: IntroMarkdown,
[connectDocSections.installation]: InstallationMarkdown,
},
- // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
- // currently no way to extract the re-exported types from index.ts via TypeDoc :(
- publicTypes: [
- 'Client',
- 'FeesRequest',
- 'FeesResponse',
- 'OrderbookChannel',
- 'OrderbookChannelHandler',
- 'OrderbookChannelSubscriptionOpts',
- 'OrderbookRequest',
- 'OrderbookResponse',
- 'OrdersRequest',
- 'OrdersRequestOpts',
- 'PagedRequestOpts',
- 'TokenPairsItem',
- 'TokenPairsRequest',
- 'TokenPairsRequestOpts',
- 'TokenTradeInfo',
- 'WebSocketOrderbookChannelConfig',
- 'Order',
- 'SignedOrder',
- 'ECSignature',
- ],
sectionNameToModulePath: {
[connectDocSections.httpClient]: ['"src/http_client"'],
[connectDocSections.webSocketOrderbookChannel]: ['"src/ws_orderbook_channel"'],
@@ -71,6 +48,35 @@ const docsInfoConfig: DocsInfoConfig = {
menuSubsectionToVersionWhenIntroduced: {},
sections: connectDocSections,
visibleConstructors: [connectDocSections.httpClient, connectDocSections.webSocketOrderbookChannel],
+ typeConfigs: {
+ typeNameToExternalLink: {
+ Provider: constants.URL_WEB3_PROVIDER_DOCS,
+ BigNumber: constants.URL_BIGNUMBERJS_GITHUB,
+ },
+ // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
+ // currently no way to extract the re-exported types from index.ts via TypeDoc :(
+ publicTypes: [
+ 'Client',
+ 'FeesRequest',
+ 'FeesResponse',
+ 'OrderbookChannel',
+ 'OrderbookChannelHandler',
+ 'OrderbookChannelSubscriptionOpts',
+ 'OrderbookRequest',
+ 'OrderbookResponse',
+ 'OrdersRequest',
+ 'OrdersRequestOpts',
+ 'PagedRequestOpts',
+ 'TokenPairsItem',
+ 'TokenPairsRequest',
+ 'TokenPairsRequestOpts',
+ 'TokenTradeInfo',
+ 'WebSocketOrderbookChannelConfig',
+ 'Order',
+ 'SignedOrder',
+ 'ECSignature',
+ ],
+ },
};
const docsInfo = new DocsInfo(docsInfoConfig);
diff --git a/packages/website/ts/containers/zero_ex_js_documentation.ts b/packages/website/ts/containers/zero_ex_js_documentation.ts
index aaf17533c..21e2f780d 100644
--- a/packages/website/ts/containers/zero_ex_js_documentation.ts
+++ b/packages/website/ts/containers/zero_ex_js_documentation.ts
@@ -63,67 +63,6 @@ const docsInfoConfig: DocsInfoConfig = {
[zeroExJsDocSections.errors]: ErrorsMarkdown,
[zeroExJsDocSections.versioning]: versioningMarkdown,
},
- // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
- // currently no way to extract the re-exported types from index.ts via TypeDoc :( Make sure to only
- // ADD types here, DO NOT REMOVE types since they might still be needed for older supported versions
- publicTypes: [
- 'Order',
- 'SignedOrder',
- 'ECSignature',
- 'ZeroExError',
- 'EventCallback',
- 'EventCallbackAsync',
- 'EventCallbackSync',
- 'ExchangeContractErrs',
- 'ContractEvent',
- 'Token',
- 'ExchangeEvents',
- 'IndexedFilterValues',
- 'SubscriptionOpts',
- 'BlockRange',
- 'BlockParam',
- 'OrderFillOrKillRequest',
- 'OrderCancellationRequest',
- 'OrderFillRequest',
- 'ContractEventEmitter',
- 'Web3Provider',
- 'ContractEventArgs',
- 'LogCancelArgs',
- 'LogFillArgs',
- 'LogErrorContractEventArgs',
- 'LogFillContractEventArgs',
- 'LogCancelContractEventArgs',
- 'EtherTokenContractEventArgs',
- 'WithdrawalContractEventArgs',
- 'DepositContractEventArgs',
- 'TokenEvents',
- 'ExchangeContractEventArgs',
- 'TransferContractEventArgs',
- 'ApprovalContractEventArgs',
- 'TokenContractEventArgs',
- 'ZeroExConfig',
- 'TransactionReceipt',
- 'TransactionReceiptWithDecodedLogs',
- 'LogWithDecodedArgs',
- 'EtherTokenEvents',
- 'BlockParamLiteral',
- 'DecodedLogArgs',
- 'MethodOpts',
- 'ValidateOrderFillableOpts',
- 'OrderTransactionOpts',
- 'TransactionOpts',
- 'ContractEventArg',
- 'LogEvent',
- 'LogEntry',
- 'DecodedLogEvent',
- 'EventWatcherCallback',
- 'OnOrderStateChangeCallback',
- 'OrderStateValid',
- 'OrderStateInvalid',
- 'OrderState',
- 'OrderStateWatcherConfig',
- 'FilterObject',
- ],
sectionNameToModulePath: {
[zeroExJsDocSections.zeroEx]: ['"0x.js/src/0x"', '"src/0x"'],
[zeroExJsDocSections.exchange]: [
@@ -160,6 +99,91 @@ const docsInfoConfig: DocsInfoConfig = {
},
sections: zeroExJsDocSections,
visibleConstructors: [zeroExJsDocSections.zeroEx],
+ typeConfigs: {
+ // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
+ // currently no way to extract the re-exported types from index.ts via TypeDoc :( Make sure to only
+ // ADD types here, DO NOT REMOVE types since they might still be needed for older supported versions
+ publicTypes: [
+ 'Order',
+ 'SignedOrder',
+ 'ECSignature',
+ 'ZeroExError',
+ 'EventCallback',
+ 'EventCallbackAsync',
+ 'EventCallbackSync',
+ 'ExchangeContractErrs',
+ 'ContractEvent',
+ 'Token',
+ 'ExchangeEvents',
+ 'IndexedFilterValues',
+ 'SubscriptionOpts',
+ 'BlockRange',
+ 'BlockParam',
+ 'OrderFillOrKillRequest',
+ 'OrderCancellationRequest',
+ 'OrderFillRequest',
+ 'ContractEventEmitter',
+ 'Web3Provider',
+ 'ContractEventArgs',
+ 'LogCancelArgs',
+ 'LogFillArgs',
+ 'LogErrorContractEventArgs',
+ 'LogFillContractEventArgs',
+ 'LogCancelContractEventArgs',
+ 'EtherTokenContractEventArgs',
+ 'WithdrawalContractEventArgs',
+ 'DepositContractEventArgs',
+ 'TokenEvents',
+ 'ExchangeContractEventArgs',
+ 'TransferContractEventArgs',
+ 'ApprovalContractEventArgs',
+ 'TokenContractEventArgs',
+ 'ZeroExConfig',
+ 'TransactionReceipt',
+ 'TransactionReceiptWithDecodedLogs',
+ 'LogWithDecodedArgs',
+ 'EtherTokenEvents',
+ 'BlockParamLiteral',
+ 'DecodedLogArgs',
+ 'MethodOpts',
+ 'ValidateOrderFillableOpts',
+ 'OrderTransactionOpts',
+ 'TransactionOpts',
+ 'ContractEventArg',
+ 'LogEvent',
+ 'LogEntry',
+ 'DecodedLogEvent',
+ 'EventWatcherCallback',
+ 'OnOrderStateChangeCallback',
+ 'OrderStateValid',
+ 'OrderStateInvalid',
+ 'OrderState',
+ 'OrderStateWatcherConfig',
+ 'FilterObject',
+ ],
+ typeNameToPrefix: {
+ Provider: 'Web3',
+ DecodedLogEntryEvent: 'Web3',
+ LogEntryEvent: 'Web3',
+ CallData: 'Web3',
+ },
+ typeNameToExternalLink: {
+ Web3: constants.URL_WEB3_DOCS,
+ Provider: constants.URL_WEB3_PROVIDER_DOCS,
+ BigNumber: constants.URL_BIGNUMBERJS_GITHUB,
+ DecodedLogEntryEvent: constants.URL_WEB3_DECODED_LOG_ENTRY_EVENT,
+ LogEntryEvent: constants.URL_WEB3_LOG_ENTRY_EVENT,
+ },
+ typeNameToDocSection: {
+ ExchangeWrapper: 'exchange',
+ TokenWrapper: 'token',
+ TokenRegistryWrapper: 'tokenRegistry',
+ EtherTokenWrapper: 'etherToken',
+ ProxyWrapper: 'proxy',
+ TokenTransferProxyWrapper: 'proxy',
+ OrderStateWatcher: 'orderWatcher',
+ },
+ },
};
const docsInfo = new DocsInfo(docsInfoConfig);
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index 745af6cf5..71fe08abe 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -73,4 +73,10 @@ export const constants = {
URL_TWITTER: 'https://twitter.com/0xproject',
URL_WETH_IO: 'https://weth.io/',
URL_ZEROEX_CHAT: 'https://chat.0xproject.com',
+ URL_WEB3_DOCS: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
+ URL_WEB3_DECODED_LOG_ENTRY_EVENT:
+ 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L123',
+ URL_WEB3_LOG_ENTRY_EVENT: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
+ URL_WEB3_PROVIDER_DOCS: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
+ URL_BIGNUMBERJS_GITHUB: 'http://mikemcl.github.io/bignumber.js',
};