From 5468358f2142549c68ffae0085ce7d31ea271ea4 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sun, 18 Mar 2018 19:04:16 +0100 Subject: Add Subprovider docs to website --- packages/subproviders/package.json | 16 ++- .../subproviders/src/monorepo_scripts/stagedocs.ts | 8 ++ .../website/md/docs/subproviders/installation.md | 15 +++ .../website/md/docs/subproviders/introduction.md | 1 + packages/website/translations/chinese.json | 3 +- packages/website/translations/english.json | 3 +- packages/website/translations/korean.json | 3 +- packages/website/translations/russian.json | 3 +- packages/website/translations/spanish.json | 3 +- packages/website/ts/components/sidebar_header.tsx | 1 + packages/website/ts/components/top_bar/top_bar.tsx | 33 +++-- .../ts/containers/subproviders_documentation.ts | 137 +++++++++++++++++++++ packages/website/ts/index.tsx | 7 ++ .../website/ts/pages/documentation/doc_page.tsx | 2 + packages/website/ts/types.ts | 3 + 15 files changed, 225 insertions(+), 13 deletions(-) create mode 100644 packages/subproviders/src/monorepo_scripts/stagedocs.ts create mode 100644 packages/website/md/docs/subproviders/installation.md create mode 100644 packages/website/md/docs/subproviders/introduction.md create mode 100644 packages/website/ts/containers/subproviders_documentation.ts (limited to 'packages') diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 58b518079..f6869c5c0 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -17,7 +17,20 @@ "test:circleci": "npm run test:unit:coverage", "test:all": "run-s test:unit test:integration", "test:unit": "run-s clean build run_mocha_unit", - "test:integration": "run-s clean build run_mocha_integration" + "test:integration": "run-s clean build run_mocha_integration", + "docs:stage": "yarn build && node ./scripts/stagedocs.js", + "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", + "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" + }, + "config": { + "postpublish": { + "assets": [], + "docPublishConfigs": { + "extraFileIncludes": ["../types/src/index.ts"], + "s3BucketPath": "s3://doc-jsons/subproviders/", + "s3StagingBucketPath": "s3://staging-doc-jsons/subproviders/" + } + } }, "dependencies": { "@0xproject/assert": "^0.2.0", @@ -57,6 +70,7 @@ "tslint": "5.8.0", "types-bn": "^0.0.1", "types-ethereumjs-util": "0xProject/types-ethereumjs-util", + "typedoc": "0xProject/typedoc", "typescript": "2.7.1", "webpack": "^3.1.0" }, diff --git a/packages/subproviders/src/monorepo_scripts/stagedocs.ts b/packages/subproviders/src/monorepo_scripts/stagedocs.ts new file mode 100644 index 000000000..e732ac8eb --- /dev/null +++ b/packages/subproviders/src/monorepo_scripts/stagedocs.ts @@ -0,0 +1,8 @@ +import { postpublishUtils } from '@0xproject/monorepo-scripts'; + +import * as packageJSON from '../package.json'; +import * as tsConfigJSON from '../tsconfig.json'; + +const cwd = `${__dirname}/..`; +// tslint:disable-next-line:no-floating-promises +postpublishUtils.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/website/md/docs/subproviders/installation.md b/packages/website/md/docs/subproviders/installation.md new file mode 100644 index 000000000..a049ff0ec --- /dev/null +++ b/packages/website/md/docs/subproviders/installation.md @@ -0,0 +1,15 @@ +```bash +npm install @0xproject/subproviders --save +``` + +**Import** + +```typescript +import { LedgerSubprovider } from '@0xproject/subproviders'; +``` + +or + +```javascript +var LedgerSubprovider = require('@0xproject/subproviders').LedgerSubprovider; +``` diff --git a/packages/website/md/docs/subproviders/introduction.md b/packages/website/md/docs/subproviders/introduction.md new file mode 100644 index 000000000..835201064 --- /dev/null +++ b/packages/website/md/docs/subproviders/introduction.md @@ -0,0 +1 @@ +Welcome to the [Subproviders](https://github.com/0xProject/0x-monorepo/tree/development/packages/subproviders) documentation! Subproviders is a package containing useful [subproviders](https://0xproject.com/wiki#Web3-Provider-Explained) that can be used with the [Web3 Provider Engine](https://github.com/MetaMask/provider-engine) library. diff --git a/packages/website/translations/chinese.json b/packages/website/translations/chinese.json index a46d12747..f610bf56c 100644 --- a/packages/website/translations/chinese.json +++ b/packages/website/translations/chinese.json @@ -58,7 +58,8 @@ "CONTACT": "联系方式", "DEPLOYER": "Deployer", "JSON_SCHEMAS": "JSON Schemas", - "SOL_COV": "Solidty Coverage", + "SOL_COV": "Solidity Coverage", + "SUBPROVIDERS": "Subproviders", "BLOG": "博客", "FORUM": "论坛", "CONNECT": "0x 连接", diff --git a/packages/website/translations/english.json b/packages/website/translations/english.json index 3b9818909..122d445cb 100644 --- a/packages/website/translations/english.json +++ b/packages/website/translations/english.json @@ -59,7 +59,8 @@ "CONTACT": "contact", "DEPLOYER": "Deployer", "JSON_SCHEMAS": "JSON Schemas", - "SOL_COV": "Solidty Coverage", + "SOL_COV": "Solidity Coverage", + "SUBPROVIDERS": "Subproviders", "BLOG": "blog", "FORUM": "forum", "CONNECT": "0x Connect", diff --git a/packages/website/translations/korean.json b/packages/website/translations/korean.json index 6bc78cd4f..dd5f19b16 100644 --- a/packages/website/translations/korean.json +++ b/packages/website/translations/korean.json @@ -58,7 +58,8 @@ "CONTACT": "문의", "DEPLOYER": "Deployer", "JSON_SCHEMAS": "JSON Schemas", - "SOL_COV": "Solidty Coverage", + "SOL_COV": "Solidity Coverage", + "SUBPROVIDERS": "Subproviders", "BLOG": "블로그", "FORUM": "포럼", "CONNECT": "0x Connect", diff --git a/packages/website/translations/russian.json b/packages/website/translations/russian.json index 68ebed30b..5a8e2c539 100644 --- a/packages/website/translations/russian.json +++ b/packages/website/translations/russian.json @@ -58,7 +58,8 @@ "CONTACT": "Связаться с нами", "DEPLOYER": "Deployer", "JSON_SCHEMAS": "JSON Schemas", - "SOL_COV": "Solidty Coverage", + "SOL_COV": "Solidity Coverage", + "SUBPROVIDERS": "Subproviders", "BLOG": "Блог", "FORUM": "Форум", "CONNECT": "0x Connect", diff --git a/packages/website/translations/spanish.json b/packages/website/translations/spanish.json index cd508f00a..dd34e805c 100644 --- a/packages/website/translations/spanish.json +++ b/packages/website/translations/spanish.json @@ -59,7 +59,8 @@ "CONTACT": "contacto", "DEPLOYER": "Deployer", "JSON_SCHEMAS": "JSON Schemas", - "SOL_COV": "Solidty Coverage", + "SOL_COV": "Solidity Coverage", + "SUBPROVIDERS": "Subproviders", "BLOG": "blog", "FORUM": "foro", "CONNECT": "0x Connect", diff --git a/packages/website/ts/components/sidebar_header.tsx b/packages/website/ts/components/sidebar_header.tsx index 6fae03691..556243430 100644 --- a/packages/website/ts/components/sidebar_header.tsx +++ b/packages/website/ts/components/sidebar_header.tsx @@ -10,6 +10,7 @@ const titleToIcon: { [title: string]: string } = { Deployer: 'zeroExJs.png', 'Sol-cov': 'zeroExJs.png', 'JSON Schemas': 'zeroExJs.png', + Subproviders: 'zeroExJs.png', '0x Connect': 'connect.png', '0x Smart Contracts': 'contracts.png', Wiki: 'wiki.png', diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 66efe0d24..3a6ceed34 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -120,22 +120,28 @@ export class TopBar extends React.Component { primaryText={this.props.translate.get(Key.StandardRelayerApi, Deco.CapWords)} /> , - + , - + , - + + , + + , @@ -333,6 +339,14 @@ export class TopBar extends React.Component { )} + {!this._isViewingSubprovidersDocs() && ( + + + {this.props.translate.get(Key.Subproviders, Deco.Cap)}{' '} + {this.props.translate.get(Key.Docs, Deco.Cap)} + + + )} {!this._isViewingPortal() && ( @@ -366,6 +380,7 @@ export class TopBar extends React.Component { !this._isViewingDeployerDocs() && !this._isViewingJsonSchemasDocs() && !this._isViewingSolCovDocs() && + !this._isViewingSubprovidersDocs() && !this._isViewingConnectDocs()) || _.isUndefined(this.props.menu) ) { @@ -466,6 +481,9 @@ export class TopBar extends React.Component { private _isViewingSolCovDocs() { return _.includes(this.props.location.pathname, WebsitePaths.SolCov); } + private _isViewingSubprovidersDocs() { + return _.includes(this.props.location.pathname, WebsitePaths.Subproviders); + } private _isViewingWiki() { return _.includes(this.props.location.pathname, WebsitePaths.Wiki); } @@ -479,7 +497,8 @@ export class TopBar extends React.Component { this._isViewingDeployerDocs() || this._isViewingJsonSchemasDocs() || this._isViewingSolCovDocs() || + this._isViewingSubprovidersDocs() || this._isViewingConnectDocs() ); } -} +} // tslint:disable:max-file-line-count diff --git a/packages/website/ts/containers/subproviders_documentation.ts b/packages/website/ts/containers/subproviders_documentation.ts new file mode 100644 index 000000000..34a3d7da2 --- /dev/null +++ b/packages/website/ts/containers/subproviders_documentation.ts @@ -0,0 +1,137 @@ +import { constants as docConstants, DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0xproject/react-docs'; +import * as _ from 'lodash'; +import * as React from 'react'; +import { connect } from 'react-redux'; +import { Dispatch } from 'redux'; +import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; +import { Dispatcher } from 'ts/redux/dispatcher'; +import { State } from 'ts/redux/reducer'; +import { DocPackages, Environments, WebsitePaths } from 'ts/types'; +import { configs } from 'ts/utils/configs'; +import { constants } from 'ts/utils/constants'; +import { Translate } from 'ts/utils/translate'; + +/* tslint:disable:no-var-requires */ +const IntroMarkdown = require('md/docs/subproviders/introduction'); +const InstallationMarkdown = require('md/docs/subproviders/installation'); +/* tslint:enable:no-var-requires */ + +const docSections = { + introduction: 'introduction', + installation: 'installation', + subprovider: 'subprovider', + ledgerSubprovider: 'ledgerSubprovider', + factoryMethods: 'factory-methods', + emptyWalletSubprovider: 'emptyWalletSubprovider', + fakeGasEstimateSubprovider: 'fakeGasEstimateSubprovider', + injectedWeb3Subprovider: 'injectedWeb3Subprovider', + redundantRPCSubprovider: 'redundantRPCSubprovider', + ganacheSubprovider: 'ganacheSubprovider', + nonceTrackerSubprovider: 'nonceTrackerSubprovider', + types: docConstants.TYPES_SECTION_NAME, +}; + +const docsInfoConfig: DocsInfoConfig = { + id: DocPackages.Subproviders, + type: SupportedDocJson.TypeDoc, + displayName: 'Subproviders', + packageUrl: 'https://github.com/0xProject/0x-monorepo', + menu: { + introduction: [docSections.introduction], + install: [docSections.installation], + subprovider: [docSections.subprovider], + ['ledger-subprovider']: [docSections.ledgerSubprovider], + ['factory-methods']: [docSections.factoryMethods], + ['emptyWallet-subprovider']: [docSections.emptyWalletSubprovider], + ['fakeGasEstimate-subprovider']: [docSections.fakeGasEstimateSubprovider], + ['injectedWeb3-subprovider']: [docSections.injectedWeb3Subprovider], + ['redundantRPC-subprovider']: [docSections.redundantRPCSubprovider], + ['ganache-subprovider']: [docSections.ganacheSubprovider], + ['nonceTracker-subprovider']: [docSections.nonceTrackerSubprovider], + types: [docSections.types], + }, + sectionNameToMarkdown: { + [docSections.introduction]: IntroMarkdown, + [docSections.installation]: InstallationMarkdown, + }, + sectionNameToModulePath: { + [docSections.subprovider]: ['"subproviders/src/subproviders/subprovider"'], + [docSections.ledgerSubprovider]: ['"subproviders/src/subproviders/ledger"'], + [docSections.factoryMethods]: ['"subproviders/src/index"'], + [docSections.emptyWalletSubprovider]: ['"subproviders/src/subproviders/empty_wallet_subprovider"'], + [docSections.fakeGasEstimateSubprovider]: ['"subproviders/src/subproviders/fake_gas_estimate_subprovider"'], + [docSections.injectedWeb3Subprovider]: ['"subproviders/src/subproviders/injected_web3"'], + [docSections.redundantRPCSubprovider]: ['"subproviders/src/subproviders/redundant_rpc"'], + [docSections.ganacheSubprovider]: ['"subproviders/src/subproviders/ganache"'], + [docSections.nonceTrackerSubprovider]: ['"subproviders/src/subproviders/nonce_tracker"'], + [docSections.types]: ['"deployer/src/utils/types"', '"types/src/index"', '"subproviders/src/types"'], + }, + menuSubsectionToVersionWhenIntroduced: {}, + sections: docSections, + visibleConstructors: [ + docSections.subprovider, + docSections.ledgerSubprovider, + docSections.emptyWalletSubprovider, + docSections.fakeGasEstimateSubprovider, + docSections.injectedWeb3Subprovider, + docSections.redundantRPCSubprovider, + docSections.ganacheSubprovider, + docSections.nonceTrackerSubprovider, + ], + 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: [ + 'Callback', + 'NextCallback', + 'ErrorCallback', + 'ECSignature', + 'JSONRPCRequestPayloadWithMethod', + 'JSONRPCResponsePayload', + 'AccountFetchingConfigs', + 'LedgerEthereumClientFactoryAsync', + 'PartialTxParams', + 'LedgerEthereumClient', + 'LedgerSubproviderConfigs', + ], + typeNameToExternalLink: { + Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API', + BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127', + JSONRPCRequestPayload: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L137', + JSONRPCResponsePayload: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L144', + Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150', + }, + typeNameToPrefix: { + JSONRPCRequestPayload: 'Web3', + JSONRPCResponsePayload: 'Web3', + Provider: 'Web3', + }, + }, +}; +const docsInfo = new DocsInfo(docsInfoConfig); + +interface ConnectedState { + docsVersion: string; + availableDocVersions: string[]; + docsInfo: DocsInfo; + translate: Translate; +} + +interface ConnectedDispatch { + dispatcher: Dispatcher; +} + +const mapStateToProps = (state: State, ownProps: DocPageProps): ConnectedState => ({ + docsVersion: state.docsVersion, + availableDocVersions: state.availableDocVersions, + translate: state.translate, + docsInfo, +}); + +const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ + dispatcher: new Dispatcher(dispatch), +}); + +export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( + DocPageComponent, +); diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index 1241c222b..0d33e389f 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -57,6 +57,9 @@ const LazyJSONSchemasDocumentation = createLazyComponent('Documentation', async const LazySolCovDocumentation = createLazyComponent('Documentation', async () => System.import(/* webpackChunkName: "connectDocs" */ 'ts/containers/sol_cov_documentation'), ); +const LazySubprovidersDocumentation = createLazyComponent('Documentation', async () => + System.import(/* webpackChunkName: "connectDocs" */ 'ts/containers/subproviders_documentation'), +); analytics.init(); // tslint:disable-next-line:no-floating-promises @@ -83,6 +86,10 @@ render( path={`${WebsitePaths.JSONSchemas}/:version?`} component={LazyJSONSchemasDocumentation} /> +