diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-06-07 02:38:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-07 02:38:43 +0800 |
commit | b1e8545981de55088abcdfa6273a3cc7bc338e77 (patch) | |
tree | 04f95ff2c9005b683a82a9a63eddef156b9d3eab | |
parent | 49049b8c126c779d68934eaceb6835ebf3a24a49 (diff) | |
parent | 625f40cfa6fdccd82392c02c1d785fac37d966eb (diff) | |
download | dexon-0x-contracts-b1e8545981de55088abcdfa6273a3cc7bc338e77.tar.gz dexon-0x-contracts-b1e8545981de55088abcdfa6273a3cc7bc338e77.tar.zst dexon-0x-contracts-b1e8545981de55088abcdfa6273a3cc7bc338e77.zip |
Merge pull request #653 from 0xProject/feature/ethereum-types-docs
Add a documentation page for ethereum-types package
-rw-r--r-- | packages/ethereum-types/package.json | 13 | ||||
-rw-r--r-- | packages/ethereum-types/src/monorepo_scripts/stage_docs.ts | 8 | ||||
-rw-r--r-- | packages/website/md/docs/ethereum_types/installation.md | 11 | ||||
-rw-r--r-- | packages/website/md/docs/ethereum_types/introduction.md | 1 | ||||
-rw-r--r-- | packages/website/translations/chinese.json | 1 | ||||
-rw-r--r-- | packages/website/translations/english.json | 1 | ||||
-rw-r--r-- | packages/website/translations/korean.json | 1 | ||||
-rw-r--r-- | packages/website/translations/russian.json | 1 | ||||
-rw-r--r-- | packages/website/translations/spanish.json | 1 | ||||
-rw-r--r-- | packages/website/ts/components/top_bar/top_bar.tsx | 17 | ||||
-rw-r--r-- | packages/website/ts/containers/ethereum_types_documentation.ts | 124 | ||||
-rw-r--r-- | packages/website/ts/index.tsx | 7 | ||||
-rw-r--r-- | packages/website/ts/pages/documentation/doc_page.tsx | 1 | ||||
-rw-r--r-- | packages/website/ts/types.ts | 3 | ||||
-rw-r--r-- | packages/website/ts/utils/doc_utils.ts | 2 |
15 files changed, 190 insertions, 2 deletions
diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json index 61ae58a37..68755c206 100644 --- a/packages/ethereum-types/package.json +++ b/packages/ethereum-types/package.json @@ -12,7 +12,18 @@ "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", "clean": "shx rm -rf lib scripts", "lint": "tslint --project .", - "manual:postpublish": "yarn build; node ./scripts/postpublish.js" + "manual:postpublish": "yarn build; node ./scripts/postpublish.js", + "docs:stage": "node scripts/stage_docs.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": { + "docPublishConfigs": { + "s3BucketPath": "s3://doc-jsons/ethereum-types/", + "s3StagingBucketPath": "s3://staging-doc-jsons/ethereum-types/" + } + } }, "license": "Apache-2.0", "repository": { diff --git a/packages/ethereum-types/src/monorepo_scripts/stage_docs.ts b/packages/ethereum-types/src/monorepo_scripts/stage_docs.ts new file mode 100644 index 000000000..e732ac8eb --- /dev/null +++ b/packages/ethereum-types/src/monorepo_scripts/stage_docs.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/ethereum_types/installation.md b/packages/website/md/docs/ethereum_types/installation.md new file mode 100644 index 000000000..5371cfa47 --- /dev/null +++ b/packages/website/md/docs/ethereum_types/installation.md @@ -0,0 +1,11 @@ +**Install** + +```bash +yarn add ethereum-types +``` + +**Import** + +```typescript +import { Provider } from 'ethereum-types'; +``` diff --git a/packages/website/md/docs/ethereum_types/introduction.md b/packages/website/md/docs/ethereum_types/introduction.md new file mode 100644 index 000000000..43484cdd1 --- /dev/null +++ b/packages/website/md/docs/ethereum_types/introduction.md @@ -0,0 +1 @@ +Welcome to the [ethereum-types](https://github.com/0xProject/0x-monorepo/packages/ethereum-types) documentation! This package provides ethereum specific (but not library-specific) types that are meant to be shared between other ethereum packages. diff --git a/packages/website/translations/chinese.json b/packages/website/translations/chinese.json index 966457a93..3e9f21370 100644 --- a/packages/website/translations/chinese.json +++ b/packages/website/translations/chinese.json @@ -59,6 +59,7 @@ "SOL_COMPILER": "Solidity Compiler", "JSON_SCHEMAS": "JSON Schemas", "SOL_COV": "Solidity Coverage", + "ETHEREUM_TYPES": "Ethereum Types", "SUBPROVIDERS": "Subproviders", "BLOG": "博客", "FORUM": "论坛", diff --git a/packages/website/translations/english.json b/packages/website/translations/english.json index f3acea3be..04fb0507a 100644 --- a/packages/website/translations/english.json +++ b/packages/website/translations/english.json @@ -60,6 +60,7 @@ "SOL_COMPILER": "Solidity Compiler", "JSON_SCHEMAS": "JSON Schemas", "SOL_COV": "Solidity Coverage", + "ETHEREUM_TYPES": "Ethereum Types", "SUBPROVIDERS": "Subproviders", "BLOG": "blog", "FORUM": "forum", diff --git a/packages/website/translations/korean.json b/packages/website/translations/korean.json index 7414207f7..c38de6677 100644 --- a/packages/website/translations/korean.json +++ b/packages/website/translations/korean.json @@ -59,6 +59,7 @@ "SOL_COMPILER": "Solidity Compiler", "JSON_SCHEMAS": "JSON Schemas", "SOL_COV": "Solidity Coverage", + "ETHEREUM_TYPES": "Ethereum Types", "SUBPROVIDERS": "Subproviders", "BLOG": "블로그", "FORUM": "포럼", diff --git a/packages/website/translations/russian.json b/packages/website/translations/russian.json index 75ab02a27..a7e06d646 100644 --- a/packages/website/translations/russian.json +++ b/packages/website/translations/russian.json @@ -59,6 +59,7 @@ "SOL_COMPILER": "Solidity Compiler", "JSON_SCHEMAS": "JSON Schemas", "SOL_COV": "Solidity Coverage", + "ETHEREUM_TYPES": "Ethereum Types", "SUBPROVIDERS": "Subproviders", "BLOG": "Блог", "FORUM": "Форум", diff --git a/packages/website/translations/spanish.json b/packages/website/translations/spanish.json index 8f537ea40..5a8920f61 100644 --- a/packages/website/translations/spanish.json +++ b/packages/website/translations/spanish.json @@ -60,6 +60,7 @@ "SOL_COMPILER": "Solidity Compiler", "JSON_SCHEMAS": "JSON Schemas", "SOL_COV": "Solidity Coverage", + "ETHEREUM_TYPES": "Ethereum Types", "SUBPROVIDERS": "Subproviders", "BLOG": "blog", "FORUM": "foro", diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 606fd845a..81ab2c06c 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -165,6 +165,12 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { primaryText={this.props.translate.get(Key.SolCov, Deco.CapWords)} /> </Link>, + <Link key="subMenuItem-ethereum-types" to={WebsitePaths.EthereumTypes} className="text-decoration-none"> + <MenuItem + style={{ fontSize: styles.menuItem.fontSize }} + primaryText={this.props.translate.get(Key.EthereumTypes, Deco.CapWords)} + /> + </Link>, <a key="subMenuItem-whitePaper" target="_blank" @@ -379,6 +385,14 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { </MenuItem> </Link> )} + {!this._isViewingEthereumTypesDocs() && ( + <Link to={WebsitePaths.EthereumTypes} className="text-decoration-none"> + <MenuItem className="py2"> + {this.props.translate.get(Key.EthereumTypes, Deco.Cap)}{' '} + {this.props.translate.get(Key.Docs, Deco.Cap)} + </MenuItem> + </Link> + )} {!this._isViewingPortal() && ( <Link to={`${WebsitePaths.Portal}`} className="text-decoration-none"> <MenuItem className="py2"> @@ -507,6 +521,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { private _isViewingSubprovidersDocs(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.Subproviders); } + private _isViewingEthereumTypesDocs(): boolean { + return _.includes(this.props.location.pathname, WebsitePaths.EthereumTypes); + } private _isViewingWiki(): boolean { return _.includes(this.props.location.pathname, WebsitePaths.Wiki); } diff --git a/packages/website/ts/containers/ethereum_types_documentation.ts b/packages/website/ts/containers/ethereum_types_documentation.ts new file mode 100644 index 000000000..28d3d92dc --- /dev/null +++ b/packages/website/ts/containers/ethereum_types_documentation.ts @@ -0,0 +1,124 @@ +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/ethereum_types/introduction'); +const InstallationMarkdown = require('md/docs/ethereum_types/installation'); +/* tslint:enable:no-var-requires */ + +const docSections = { + introduction: 'introduction', + installation: 'installation', + types: docConstants.TYPES_SECTION_NAME, +}; + +const docsInfoConfig: DocsInfoConfig = { + id: DocPackages.EthereumTypes, + type: SupportedDocJson.TypeDoc, + displayName: 'Ethereum Types', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/ethereum-types', + menu: { + introduction: [docSections.introduction], + install: [docSections.installation], + types: [docSections.types], + }, + sectionNameToMarkdown: { + [docSections.introduction]: IntroMarkdown, + [docSections.installation]: InstallationMarkdown, + }, + sectionNameToModulePath: { + [docSections.types]: ['"index"'], + }, + visibleConstructors: [], + menuSubsectionToVersionWhenIntroduced: {}, + sections: docSections, + 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: [ + 'Provider', + 'JSONRPCErrorCallback', + 'Provider', + 'ContractAbi', + 'AbiDefinition', + 'FunctionAbi', + 'ConstructorStateMutability', + 'StateMutability', + 'MethodAbi', + 'ConstructorAbi', + 'FallbackAbi', + 'EventParameter', + 'EventAbi', + 'DataItem', + 'OpCode', + // 'StructLog', // TODO: This type breaks the docs so we don't render it for now + 'TransactionTrace', + 'Unit', + 'JSONRPCRequestPayload', + 'JSONRPCResponsePayload', + 'BlockWithoutTransactionData', + 'BlockWithTransactionData', + 'Transaction', + 'TxData', + 'CallData', + 'FilterObject', + 'LogTopic', + 'DecodedLogEntry', + 'DecodedLogEntryEvent', + 'LogEntryEvent', + 'LogEntry', + 'TxDataPayable', + 'TransactionReceipt', + 'AbiType', + 'ContractEventArg', + 'DecodedLogArgs', + 'LogWithDecodedArgs', + 'RawLog', + 'BlockParamLiteral', + 'BlockParam', + 'RawLogEntry', + 'SolidityTypes', + 'TransactionReceiptWithDecodedLogs', + ], + typeNameToExternalLink: { + BigNumber: constants.URL_BIGNUMBERJS_GITHUB, + }, + }, +}; +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<State>): ConnectedDispatch => ({ + dispatcher: new Dispatcher(dispatch), +}); + +export const Documentation: React.ComponentClass<DocPageProps> = connect(mapStateToProps, mapDispatchToProps)( + DocPageComponent, +); diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index a6bfe7dd2..719604c02 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -69,6 +69,9 @@ const LazySubprovidersDocumentation = createLazyComponent('Documentation', async const LazyOrderUtilsDocumentation = createLazyComponent('Documentation', async () => System.import<any>(/* webpackChunkName: "orderUtilsDocs" */ 'ts/containers/order_utils_documentation'), ); +const LazyEthereumTypesDocumentation = createLazyComponent('Documentation', async () => + System.import<any>(/* webpackChunkName: "ethereumTypesDocs" */ 'ts/containers/ethereum_types_documentation'), +); analytics.init(); // tslint:disable-next-line:no-floating-promises @@ -116,6 +119,10 @@ render( path={`${WebsitePaths.SmartContracts}/:version?`} component={LazySmartContractsDocumentation} /> + <Route + path={`${WebsitePaths.EthereumTypes}/:version?`} + component={LazyEthereumTypesDocumentation} + /> {/* Legacy endpoints */} <Route diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx index 17efc56ed..c25577628 100644 --- a/packages/website/ts/pages/documentation/doc_page.tsx +++ b/packages/website/ts/pages/documentation/doc_page.tsx @@ -35,6 +35,7 @@ const docIdToSubpackageName: { [id: string]: string } = { [DocPackages.SolCov]: 'sol-cov', [DocPackages.Subproviders]: 'subproviders', [DocPackages.OrderUtils]: 'order-utils', + [DocPackages.EthereumTypes]: 'ethereum-types', }; export interface DocPageProps { diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 9567e129b..6bc928048 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -370,6 +370,7 @@ export enum WebsitePaths { SolCov = '/docs/sol-cov', Subproviders = '/docs/subproviders', OrderUtils = '/docs/order-utils', + EthereumTypes = '/docs/ethereum-types', Jobs = '/jobs', } @@ -383,6 +384,7 @@ export enum DocPackages { SolCov = 'SOL_COV', Subproviders = 'SUBPROVIDERS', OrderUtils = 'ORDER_UTILS', + EthereumTypes = 'ETHEREUM_TYPES', } export enum Key { @@ -434,6 +436,7 @@ export enum Key { SolCompiler = 'SOL_COMPILER', JsonSchemas = 'JSON_SCHEMAS', SolCov = 'SOL_COV', + EthereumTypes = 'ETHEREUM_TYPES', Subproviders = 'SUBPROVIDERS', Blog = 'BLOG', Forum = 'FORUM', diff --git a/packages/website/ts/utils/doc_utils.ts b/packages/website/ts/utils/doc_utils.ts index 2a599bcbe..4db7235da 100644 --- a/packages/website/ts/utils/doc_utils.ts +++ b/packages/website/ts/utils/doc_utils.ts @@ -8,7 +8,7 @@ import convert = require('xml-js'); export const docUtils = { async getVersionToFilePathAsync(s3DocJsonRoot: string, folderName: string): Promise<VersionToFilePath> { - const versionFilePaths = await this.getVersionFileNamesAsync(s3DocJsonRoot, folderName); + const versionFilePaths = await docUtils.getVersionFileNamesAsync(s3DocJsonRoot, folderName); const versionToFilePath: VersionToFilePath = {}; _.each(versionFilePaths, filePath => { const [version] = findVersions(filePath); |