aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/containers
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-29 05:11:04 +0800
committerFabio Berger <me@fabioberger.com>2017-11-29 05:11:04 +0800
commit72a00ac2df47ff793d74c2a82c7f403f501e784a (patch)
tree082d38d2ed5a36ec4b8f7e0bd156841ca86cf005 /packages/website/ts/containers
parentfcddd503b76283266946dc1f04b299d0606c90bb (diff)
downloaddexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.gz
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.bz2
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.lz
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.xz
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.zst
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.zip
Refactor the topLevel documentation react components for 0x.js and Smart contracts into a single component
Diffstat (limited to 'packages/website/ts/containers')
-rw-r--r--packages/website/ts/containers/smart_contracts_documentation.tsx56
-rw-r--r--packages/website/ts/containers/zero_ex_js_documentation.tsx146
2 files changed, 190 insertions, 12 deletions
diff --git a/packages/website/ts/containers/smart_contracts_documentation.tsx b/packages/website/ts/containers/smart_contracts_documentation.tsx
index ccf3c4a65..4623c976b 100644
--- a/packages/website/ts/containers/smart_contracts_documentation.tsx
+++ b/packages/website/ts/containers/smart_contracts_documentation.tsx
@@ -2,12 +2,54 @@ import * as _ from 'lodash';
import * as React from 'react';
import {connect} from 'react-redux';
import {Dispatch, Store as ReduxStore} from 'redux';
+import {DocsInfo} from 'ts/pages/documentation/docs_info';
import {
- SmartContractsDocumentation as SmartContractsDocumentationComponent,
- SmartContractsDocumentationAllProps,
-} from 'ts/pages/documentation/smart_contracts_documentation';
+ Documentation as DocumentationComponent,
+ DocumentationAllProps,
+} from 'ts/pages/documentation/documentation';
import {Dispatcher} from 'ts/redux/dispatcher';
import {State} from 'ts/redux/reducer';
+import {DocsInfoConfig, WebsitePaths} from 'ts/types';
+import {constants} from 'ts/utils/constants';
+import {doxityUtils} from 'ts/utils/doxity_utils';
+
+/* tslint:disable:no-var-requires */
+const IntroMarkdown = require('md/docs/smart_contracts/introduction');
+/* tslint:enable:no-var-requires */
+
+const sections = constants.smartContractDocSections;
+
+const docsInfoConfig: DocsInfoConfig = {
+ packageName: '0x Smart Contracts',
+ packageUrl: 'https://github.com/0xProject/contracts',
+ websitePath: WebsitePaths.SmartContracts,
+ docsJsonRoot: 'https://s3.amazonaws.com/smart-contracts-docs-json',
+ menu: {
+ introduction: [
+ sections.Introduction,
+ ],
+ contracts: [
+ sections.Exchange,
+ sections.TokenRegistry,
+ sections.ZRXToken,
+ sections.EtherToken,
+ sections.TokenTransferProxy,
+ ],
+ },
+ sectionNameToMarkdown: {
+ [sections.Introduction]: IntroMarkdown,
+ },
+ sections,
+ visibleConstructors: [
+ sections.Exchange,
+ sections.TokenRegistry,
+ sections.ZRXToken,
+ sections.EtherToken,
+ sections.TokenTransferProxy,
+ ],
+ convertToDocAgnosticFormatFn: doxityUtils.convertToDocAgnosticFormat.bind(doxityUtils),
+};
+const docsInfo = new DocsInfo(docsInfoConfig);
interface ConnectedState {
docsVersion: string;
@@ -16,16 +58,18 @@ interface ConnectedState {
interface ConnectedDispatch {
dispatcher: Dispatcher;
+ docsInfo: DocsInfo;
}
-const mapStateToProps = (state: State, ownProps: SmartContractsDocumentationAllProps): ConnectedState => ({
+const mapStateToProps = (state: State, ownProps: DocumentationAllProps): ConnectedState => ({
docsVersion: state.docsVersion,
availableDocVersions: state.availableDocVersions,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
dispatcher: new Dispatcher(dispatch),
+ docsInfo,
});
-export const SmartContractsDocumentation: React.ComponentClass<SmartContractsDocumentationAllProps> =
- connect(mapStateToProps, mapDispatchToProps)(SmartContractsDocumentationComponent);
+export const Documentation: React.ComponentClass<DocumentationAllProps> =
+ connect(mapStateToProps, mapDispatchToProps)(DocumentationComponent);
diff --git a/packages/website/ts/containers/zero_ex_js_documentation.tsx b/packages/website/ts/containers/zero_ex_js_documentation.tsx
index ecf0451c0..cfb5c00b5 100644
--- a/packages/website/ts/containers/zero_ex_js_documentation.tsx
+++ b/packages/website/ts/containers/zero_ex_js_documentation.tsx
@@ -4,30 +4,164 @@ import * as React from 'react';
import {connect} from 'react-redux';
import {Dispatch, Store as ReduxStore} from 'redux';
import {Blockchain} from 'ts/blockchain';
+import {DocsInfo} from 'ts/pages/documentation/docs_info';
import {
- ZeroExJSDocumentation as ZeroExJSDocumentationComponent,
- ZeroExJSDocumentationAllProps,
-} from 'ts/pages/documentation/zero_ex_js_documentation';
+ Documentation as DocumentationComponent,
+ DocumentationAllProps,
+} from 'ts/pages/documentation/documentation';
import {Dispatcher} from 'ts/redux/dispatcher';
import {State} from 'ts/redux/reducer';
+import {DocsInfoConfig, WebsitePaths} from 'ts/types';
+import {typeDocUtils} from 'ts/utils/typedoc_utils';
+
+/* tslint:disable:no-var-requires */
+const IntroMarkdown = require('md/docs/0xjs/introduction');
+const InstallationMarkdown = require('md/docs/0xjs/installation');
+const AsyncMarkdown = require('md/docs/0xjs/async');
+const ErrorsMarkdown = require('md/docs/0xjs/errors');
+const versioningMarkdown = require('md/docs/0xjs/versioning');
+/* tslint:enable:no-var-requires */
+
+const zeroExJsDocSections = {
+ introduction: 'introduction',
+ installation: 'installation',
+ testrpc: 'testrpc',
+ async: 'async',
+ errors: 'errors',
+ versioning: 'versioning',
+ zeroEx: 'zeroEx',
+ exchange: 'exchange',
+ token: 'token',
+ tokenRegistry: 'tokenRegistry',
+ etherToken: 'etherToken',
+ proxy: 'proxy',
+ types: 'types',
+};
+
+const docsInfoConfig: DocsInfoConfig = {
+ packageName: '0x.js',
+ packageUrl: 'https://github.com/0xProject/0x.js',
+ websitePath: WebsitePaths.ZeroExJs,
+ docsJsonRoot: 'https://s3.amazonaws.com/0xjs-docs-jsons',
+ menu: {
+ introduction: [
+ zeroExJsDocSections.introduction,
+ ],
+ install: [
+ zeroExJsDocSections.installation,
+ ],
+ topics: [
+ zeroExJsDocSections.async,
+ zeroExJsDocSections.errors,
+ zeroExJsDocSections.versioning,
+ ],
+ zeroEx: [
+ zeroExJsDocSections.zeroEx,
+ ],
+ contracts: [
+ zeroExJsDocSections.exchange,
+ zeroExJsDocSections.token,
+ zeroExJsDocSections.tokenRegistry,
+ zeroExJsDocSections.etherToken,
+ zeroExJsDocSections.proxy,
+ ],
+ types: [
+ zeroExJsDocSections.types,
+ ],
+ },
+ sectionNameToMarkdown: {
+ [zeroExJsDocSections.introduction]: IntroMarkdown,
+ [zeroExJsDocSections.installation]: InstallationMarkdown,
+ [zeroExJsDocSections.async]: AsyncMarkdown,
+ [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 :(
+ publicTypes: [
+ 'Order',
+ 'SignedOrder',
+ 'ECSignature',
+ 'ZeroExError',
+ 'EventCallback',
+ 'EventCallbackAsync',
+ 'EventCallbackSync',
+ 'ExchangeContractErrs',
+ 'ContractEvent',
+ 'Token',
+ 'ExchangeEvents',
+ 'IndexedFilterValues',
+ 'SubscriptionOpts',
+ 'BlockParam',
+ 'OrderFillOrKillRequest',
+ 'OrderCancellationRequest',
+ 'OrderFillRequest',
+ 'ContractEventEmitter',
+ 'Web3Provider',
+ 'ContractEventArgs',
+ 'LogCancelArgs',
+ 'LogFillArgs',
+ 'LogErrorContractEventArgs',
+ 'LogFillContractEventArgs',
+ 'LogCancelContractEventArgs',
+ 'TokenEvents',
+ 'ExchangeContractEventArgs',
+ 'TransferContractEventArgs',
+ 'ApprovalContractEventArgs',
+ 'TokenContractEventArgs',
+ 'ZeroExConfig',
+ 'TransactionReceiptWithDecodedLogs',
+ 'LogWithDecodedArgs',
+ 'DecodedLogArgs',
+ 'MethodOpts',
+ 'ValidateOrderFillableOpts',
+ 'OrderTransactionOpts',
+ 'ContractEventArg',
+ 'LogEvent',
+ 'LogEntry',
+ 'DecodedLogEvent',
+ ],
+ sectionNameToModulePath: {
+ [zeroExJsDocSections.zeroEx]: ['"src/0x"'],
+ [zeroExJsDocSections.exchange]: ['"src/contract_wrappers/exchange_wrapper"'],
+ [zeroExJsDocSections.tokenRegistry]: ['"src/contract_wrappers/token_registry_wrapper"'],
+ [zeroExJsDocSections.token]: ['"src/contract_wrappers/token_wrapper"'],
+ [zeroExJsDocSections.etherToken]: ['"src/contract_wrappers/ether_token_wrapper"'],
+ [zeroExJsDocSections.proxy]: [
+ '"src/contract_wrappers/proxy_wrapper"',
+ '"src/contract_wrappers/token_transfer_proxy_wrapper"',
+ ],
+ [zeroExJsDocSections.types]: ['"src/types"'],
+ },
+ menuSubsectionToVersionWhenIntroduced: {
+ [zeroExJsDocSections.etherToken]: '0.7.1',
+ [zeroExJsDocSections.proxy]: '0.8.0',
+ },
+ sections: zeroExJsDocSections,
+ visibleConstructors: [zeroExJsDocSections.zeroEx],
+ convertToDocAgnosticFormatFn: typeDocUtils.convertToDocAgnosticFormat.bind(typeDocUtils),
+};
+const docsInfo = new DocsInfo(docsInfoConfig);
interface ConnectedState {
docsVersion: string;
availableDocVersions: string[];
+ docsInfo: DocsInfo;
}
interface ConnectedDispatch {
dispatcher: Dispatcher;
}
-const mapStateToProps = (state: State, ownProps: ZeroExJSDocumentationAllProps): ConnectedState => ({
+const mapStateToProps = (state: State, ownProps: DocumentationAllProps): ConnectedState => ({
docsVersion: state.docsVersion,
availableDocVersions: state.availableDocVersions,
+ docsInfo,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
dispatcher: new Dispatcher(dispatch),
});
-export const ZeroExJSDocumentation: React.ComponentClass<ZeroExJSDocumentationAllProps> =
- connect(mapStateToProps, mapDispatchToProps)(ZeroExJSDocumentationComponent);
+export const Documentation: React.ComponentClass<DocumentationAllProps> =
+ connect(mapStateToProps, mapDispatchToProps)(DocumentationComponent);