aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-18 21:54:12 +0800
committerFabio Berger <me@fabioberger.com>2018-03-18 21:54:12 +0800
commitc7302c46e57c4646dbbd0004e09e987b720b5815 (patch)
treec29821584c6aa25b47b426f2fc7196e43ae6449f
parent4948551703fb3cb9f8470d9f4a61a9a5473e5afa (diff)
downloaddexon-sol-tools-c7302c46e57c4646dbbd0004e09e987b720b5815.tar
dexon-sol-tools-c7302c46e57c4646dbbd0004e09e987b720b5815.tar.gz
dexon-sol-tools-c7302c46e57c4646dbbd0004e09e987b720b5815.tar.bz2
dexon-sol-tools-c7302c46e57c4646dbbd0004e09e987b720b5815.tar.lz
dexon-sol-tools-c7302c46e57c4646dbbd0004e09e987b720b5815.tar.xz
dexon-sol-tools-c7302c46e57c4646dbbd0004e09e987b720b5815.tar.zst
dexon-sol-tools-c7302c46e57c4646dbbd0004e09e987b720b5815.zip
Add JSON Schemas docs to website
-rw-r--r--packages/json-schemas/package.json15
-rw-r--r--packages/json-schemas/src/monorepo_scripts/stagedocs.ts8
-rw-r--r--packages/website/md/docs/json_schemas/installation.md17
-rw-r--r--packages/website/md/docs/json_schemas/introduction.md3
-rw-r--r--packages/website/md/docs/json_schemas/schemas.md28
-rw-r--r--packages/website/translations/chinese.json1
-rw-r--r--packages/website/translations/english.json1
-rw-r--r--packages/website/translations/korean.json1
-rw-r--r--packages/website/translations/russian.json1
-rw-r--r--packages/website/translations/spanish.json1
-rw-r--r--packages/website/ts/components/sidebar_header.tsx1
-rw-r--r--packages/website/ts/components/top_bar/top_bar.tsx19
-rw-r--r--packages/website/ts/containers/json_schemas_documentation.ts85
-rw-r--r--packages/website/ts/index.tsx7
-rw-r--r--packages/website/ts/pages/documentation/doc_page.tsx4
-rw-r--r--packages/website/ts/types.ts3
16 files changed, 193 insertions, 2 deletions
diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json
index 84ed0c209..a63d435ab 100644
--- a/packages/json-schemas/package.json
+++ b/packages/json-schemas/package.json
@@ -13,7 +13,19 @@
"test:circleci": "yarn test:coverage",
"run_mocha": "mocha lib/test/**/*_test.js",
"clean": "shx rm -rf _bundles lib test_temp scripts",
- "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts"
+ "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
+ "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/json-schemas/",
+ "s3StagingBucketPath": "s3://staging-doc-jsons/json-schemas/"
+ }
+ }
},
"repository": {
"type": "git",
@@ -46,6 +58,7 @@
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
+ "typedoc": "0xProject/typedoc",
"typescript": "2.7.1"
},
"publishConfig": {
diff --git a/packages/json-schemas/src/monorepo_scripts/stagedocs.ts b/packages/json-schemas/src/monorepo_scripts/stagedocs.ts
new file mode 100644
index 000000000..e732ac8eb
--- /dev/null
+++ b/packages/json-schemas/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/json_schemas/installation.md b/packages/website/md/docs/json_schemas/installation.md
new file mode 100644
index 000000000..53886b6b3
--- /dev/null
+++ b/packages/website/md/docs/json_schemas/installation.md
@@ -0,0 +1,17 @@
+**Install**
+
+```bash
+npm install @0xproject/json-schemas --save
+```
+
+**Import**
+
+```javascript
+import { schemas } from '@0xproject/json-schemas';
+```
+
+or
+
+```javascript
+var schemas = require('@0xproject/json-schemas').schemas;
+```
diff --git a/packages/website/md/docs/json_schemas/introduction.md b/packages/website/md/docs/json_schemas/introduction.md
new file mode 100644
index 000000000..a27f4b521
--- /dev/null
+++ b/packages/website/md/docs/json_schemas/introduction.md
@@ -0,0 +1,3 @@
+Welcome to the [@0xproject/json-schemas](https://github.com/0xProject/0x-monorepo/tree/development/packages/json-schemas) documentation! This package provides JSON schemas for validating 0x Protocol & Standard Relayer API data structures. It provides both the raw JSON schemas and a schema validator class to interact with them from a JS project.
+
+If you are not using a Javascript-based language for your project, you can copy-paste the JSON schemas within this package and use them together with a [JSON Schema](http://json-schema.org/) implementation in your [language of choice](http://json-schema.org/implementations.html) (e.g Python, Haskell, Go, C, C++, Rust, Ruby, Scala, etc...).
diff --git a/packages/website/md/docs/json_schemas/schemas.md b/packages/website/md/docs/json_schemas/schemas.md
new file mode 100644
index 000000000..fcf5d8df6
--- /dev/null
+++ b/packages/website/md/docs/json_schemas/schemas.md
@@ -0,0 +1,28 @@
+0x Protocol Schemas
+
+* [Basic types](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/basic_type_schemas.ts) (e.g Ethereum address, number)
+* [ECSignature](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/ec_signature_schema.ts)
+* [Order/SignedOrder](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_schemas.ts)
+* [OrderHash](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_hash_schema.ts)
+
+0x.js Schemas
+
+* [BlockRange](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/block_range_schema.ts)
+* [IndexFilter Values](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/index_filter_values_schema.ts)
+* [OrderFillRequests](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_fill_requests_schema.ts)
+* [OrderCancellationRequests](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_cancel_schema.ts)
+* [OrderFillOrKillRequests](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts)
+* [SignedOrders](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/signed_orders_schema.ts)
+* [Token](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/token_schema.ts)
+* [TxData](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/tx_data_schema.ts)
+
+Standard Relayer API Schemas
+
+* [Error response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_error_response_schema.ts)
+* [Fees payload](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts)
+* [Fees response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts)
+* [Orderbook channel subscribe](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts)
+* [Orderbook channel snapshot](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts)
+* [Orderbook channel update](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts)
+* [Orderbook response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts)
+* [Token pairs response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts)
diff --git a/packages/website/translations/chinese.json b/packages/website/translations/chinese.json
index f230754ec..4b7b3f642 100644
--- a/packages/website/translations/chinese.json
+++ b/packages/website/translations/chinese.json
@@ -57,6 +57,7 @@
"CAREERS": "人才招聘",
"CONTACT": "联系方式",
"DEPLOYER": "Deployer",
+ "JSON_SCHEMAS": "JSON Schemas",
"BLOG": "博客",
"FORUM": "论坛",
"CONNECT": "0x 连接",
diff --git a/packages/website/translations/english.json b/packages/website/translations/english.json
index 13d2c1842..52bf0ac9d 100644
--- a/packages/website/translations/english.json
+++ b/packages/website/translations/english.json
@@ -58,6 +58,7 @@
"CAREERS": "careers",
"CONTACT": "contact",
"DEPLOYER": "Deployer",
+ "JSON_SCHEMAS": "JSON Schemas",
"BLOG": "blog",
"FORUM": "forum",
"CONNECT": "0x Connect",
diff --git a/packages/website/translations/korean.json b/packages/website/translations/korean.json
index 2d32e5c81..66e4db965 100644
--- a/packages/website/translations/korean.json
+++ b/packages/website/translations/korean.json
@@ -57,6 +57,7 @@
"CAREERS": "채용",
"CONTACT": "문의",
"DEPLOYER": "Deployer",
+ "JSON_SCHEMAS": "JSON Schemas",
"BLOG": "블로그",
"FORUM": "포럼",
"CONNECT": "0x Connect",
diff --git a/packages/website/translations/russian.json b/packages/website/translations/russian.json
index 9991bb4bc..09da6015a 100644
--- a/packages/website/translations/russian.json
+++ b/packages/website/translations/russian.json
@@ -57,6 +57,7 @@
"CAREERS": "Карьера",
"CONTACT": "Связаться с нами",
"DEPLOYER": "Deployer",
+ "JSON_SCHEMAS": "JSON Schemas",
"BLOG": "Блог",
"FORUM": "Форум",
"CONNECT": "0x Connect",
diff --git a/packages/website/translations/spanish.json b/packages/website/translations/spanish.json
index 121115260..236bda339 100644
--- a/packages/website/translations/spanish.json
+++ b/packages/website/translations/spanish.json
@@ -58,6 +58,7 @@
"CAREERS": "empleo",
"CONTACT": "contacto",
"DEPLOYER": "Deployer",
+ "JSON_SCHEMAS": "JSON Schemas",
"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 33c5ac857..6216d2146 100644
--- a/packages/website/ts/components/sidebar_header.tsx
+++ b/packages/website/ts/components/sidebar_header.tsx
@@ -8,6 +8,7 @@ const titleToIcon: { [title: string]: string } = {
'0x.js': 'zeroExJs.png',
Web3Wrapper: 'zeroExJs.png',
Deployer: 'zeroExJs.png',
+ 'JSON Schemas': '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 9cde5bf3f..9474311b4 100644
--- a/packages/website/ts/components/top_bar/top_bar.tsx
+++ b/packages/website/ts/components/top_bar/top_bar.tsx
@@ -151,6 +151,12 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
primaryText={this.props.translate.get(Key.Deployer, Deco.CapWords)}
/>
</Link>,
+ <Link key="subMenuItem-jsonSchema" to={WebsitePaths.JSONSchemas} className="text-decoration-none">
+ <MenuItem
+ style={{ fontSize: styles.menuItem.fontSize }}
+ primaryText={this.props.translate.get(Key.JsonSchemas, Deco.CapWords)}
+ />
+ </Link>,
];
const bottomBorderStyle = this._shouldDisplayBottomBar() ? styles.bottomBar : {};
const fullWidthClasses = isFullWidthPage ? 'pr4' : '';
@@ -305,6 +311,14 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</MenuItem>
</Link>
)}
+ {!this._isViewingJsonSchemasDocs() && (
+ <Link to={WebsitePaths.JSONSchemas} className="text-decoration-none">
+ <MenuItem className="py2">
+ {this.props.translate.get(Key.JsonSchemas, 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">
@@ -336,6 +350,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
!this._isViewingSmartContractsDocs() &&
!this._isViewingWeb3WrapperDocs() &&
!this._isViewingDeployerDocs() &&
+ !this._isViewingJsonSchemasDocs() &&
!this._isViewingConnectDocs()) ||
_.isUndefined(this.props.menu)
) {
@@ -430,6 +445,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
private _isViewingDeployerDocs() {
return _.includes(this.props.location.pathname, WebsitePaths.Deployer);
}
+ private _isViewingJsonSchemasDocs() {
+ return _.includes(this.props.location.pathname, WebsitePaths.JSONSchemas);
+ }
private _isViewingWiki() {
return _.includes(this.props.location.pathname, WebsitePaths.Wiki);
}
@@ -441,6 +459,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
this._isViewingSmartContractsDocs() ||
this._isViewingWeb3WrapperDocs() ||
this._isViewingDeployerDocs() ||
+ this._isViewingJsonSchemasDocs() ||
this._isViewingConnectDocs()
);
}
diff --git a/packages/website/ts/containers/json_schemas_documentation.ts b/packages/website/ts/containers/json_schemas_documentation.ts
new file mode 100644
index 000000000..42e441212
--- /dev/null
+++ b/packages/website/ts/containers/json_schemas_documentation.ts
@@ -0,0 +1,85 @@
+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/json_schemas/introduction');
+const InstallationMarkdown = require('md/docs/json_schemas/installation');
+const SchemasMarkdown = require('md/docs/json_schemas/schemas');
+/* tslint:enable:no-var-requires */
+
+const docSections = {
+ introduction: 'introduction',
+ installation: 'installation',
+ schemaValidator: 'schemaValidator',
+ schemas: 'schemas',
+};
+
+const docsInfoConfig: DocsInfoConfig = {
+ id: DocPackages.JSONSchemas,
+ type: SupportedDocJson.TypeDoc,
+ displayName: 'JSON Schemas',
+ packageUrl: 'https://github.com/0xProject/0x-monorepo',
+ menu: {
+ introduction: [docSections.introduction],
+ install: [docSections.installation],
+ schemaValidator: [docSections.schemaValidator],
+ schemas: [docSections.schemas],
+ },
+ sectionNameToMarkdown: {
+ [docSections.introduction]: IntroMarkdown,
+ [docSections.installation]: InstallationMarkdown,
+ [docSections.schemas]: SchemasMarkdown,
+ },
+ sectionNameToModulePath: {
+ [docSections.schemaValidator]: ['"json-schemas/src/schema_validator"'],
+ },
+ menuSubsectionToVersionWhenIntroduced: {},
+ sections: docSections,
+ visibleConstructors: [docSections.schemaValidator],
+ 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: [],
+ typeNameToExternalLink: {
+ Schema:
+ 'https://github.com/tdegrunt/jsonschema/blob/5c2edd4baba149964aec0f23c87ad12c25a50dfb/lib/index.d.ts#L49',
+ },
+ },
+};
+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 cc09f2df3..b5166ebca 100644
--- a/packages/website/ts/index.tsx
+++ b/packages/website/ts/index.tsx
@@ -51,6 +51,9 @@ const LazyWeb3WrapperDocumentation = createLazyComponent('Documentation', async
const LazyDeployerDocumentation = createLazyComponent('Documentation', async () =>
System.import<any>(/* webpackChunkName: "connectDocs" */ 'ts/containers/deployer_documentation'),
);
+const LazyJSONSchemasDocumentation = createLazyComponent('Documentation', async () =>
+ System.import<any>(/* webpackChunkName: "connectDocs" */ 'ts/containers/json_schemas_documentation'),
+);
analytics.init();
// tslint:disable-next-line:no-floating-promises
@@ -73,6 +76,10 @@ render(
<Route path={`${WebsitePaths.Connect}/:version?`} component={LazyConnectDocumentation} />
<Route path={`${WebsitePaths.Deployer}/:version?`} component={LazyDeployerDocumentation} />
<Route
+ path={`${WebsitePaths.JSONSchemas}/:version?`}
+ component={LazyJSONSchemasDocumentation}
+ />
+ <Route
path={`${WebsitePaths.Web3Wrapper}/:version?`}
component={LazyWeb3WrapperDocumentation}
/>
diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx
index 5f09ec9ef..55dbe12af 100644
--- a/packages/website/ts/pages/documentation/doc_page.tsx
+++ b/packages/website/ts/pages/documentation/doc_page.tsx
@@ -17,13 +17,14 @@ import { utils } from 'ts/utils/utils';
const ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH = '0.32.4';
-const isDevelopment = configs.ENVIRONMENT !== Environments.DEVELOPMENT;
+const isDevelopment = configs.ENVIRONMENT === Environments.DEVELOPMENT;
const docIdToS3FolderName: { [id: string]: string } = {
[DocPackages.ZeroExJs]: '0xjs',
[DocPackages.SmartContracts]: 'smart-contracts',
[DocPackages.Connect]: 'connect',
[DocPackages.Web3Wrapper]: 'web3-wrapper',
[DocPackages.Deployer]: 'deployer',
+ [DocPackages.JSONSchemas]: 'json-schemas',
};
const docIdToSubpackageName: { [id: string]: string } = {
@@ -32,6 +33,7 @@ const docIdToSubpackageName: { [id: string]: string } = {
[DocPackages.SmartContracts]: 'contracts',
[DocPackages.Web3Wrapper]: 'web3-wrapper',
[DocPackages.Deployer]: 'deployer',
+ [DocPackages.JSONSchemas]: 'json-schemas',
};
export interface DocPageProps {
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index 4a3426b56..b36d389e0 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -357,6 +357,7 @@ export enum WebsitePaths {
Connect = '/docs/connect',
Web3Wrapper = '/docs/web3_wrapper',
Deployer = '/docs/deployer',
+ JSONSchemas = '/docs/json-schemas',
}
export enum DocPackages {
@@ -365,6 +366,7 @@ export enum DocPackages {
SmartContracts = 'SMART_CONTRACTS',
Web3Wrapper = 'WEB3_WRAPPER',
Deployer = 'DEPLOYER',
+ JSONSchemas = 'JSON_SCHEMAS',
}
export interface TimestampMsRange {
@@ -447,6 +449,7 @@ export enum Key {
Careers = 'CAREERS',
Contact = 'CONTACT',
Deployer = 'DEPLOYER',
+ JsonSchemas = 'JSON_SCHEMAS',
Blog = 'BLOG',
Forum = 'FORUM',
Connect = 'CONNECT',