From c1d17c83f8ee246c60b277c9c76b4eb9db1dba05 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sun, 18 Mar 2018 16:10:02 +0100 Subject: Add sol-cov docs to website --- packages/website/ts/components/sidebar_header.tsx | 1 + packages/website/ts/components/top_bar/top_bar.tsx | 19 +++++ .../website/ts/containers/sol_cov_documentation.ts | 89 ++++++++++++++++++++++ packages/website/ts/index.tsx | 4 + .../website/ts/pages/documentation/doc_page.tsx | 2 + packages/website/ts/types.ts | 3 + 6 files changed, 118 insertions(+) create mode 100644 packages/website/ts/containers/sol_cov_documentation.ts (limited to 'packages/website/ts') diff --git a/packages/website/ts/components/sidebar_header.tsx b/packages/website/ts/components/sidebar_header.tsx index 6216d2146..6fae03691 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', + 'Sol-cov': 'zeroExJs.png', 'JSON Schemas': 'zeroExJs.png', '0x Connect': 'connect.png', '0x Smart Contracts': 'contracts.png', diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 9474311b4..fd33e8605 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -157,6 +157,12 @@ export class TopBar extends React.Component { primaryText={this.props.translate.get(Key.JsonSchemas, Deco.CapWords)} /> , + + + , ]; const bottomBorderStyle = this._shouldDisplayBottomBar() ? styles.bottomBar : {}; const fullWidthClasses = isFullWidthPage ? 'pr4' : ''; @@ -319,6 +325,14 @@ export class TopBar extends React.Component { )} + {!this._isViewingSolCovDocs() && ( + + + {this.props.translate.get(Key.SolCov, Deco.Cap)}{' '} + {this.props.translate.get(Key.Docs, Deco.Cap)} + + + )} {!this._isViewingPortal() && ( @@ -351,6 +365,7 @@ export class TopBar extends React.Component { !this._isViewingWeb3WrapperDocs() && !this._isViewingDeployerDocs() && !this._isViewingJsonSchemasDocs() && + !this._isViewingSolCovDocs() && !this._isViewingConnectDocs()) || _.isUndefined(this.props.menu) ) { @@ -448,6 +463,9 @@ export class TopBar extends React.Component { private _isViewingJsonSchemasDocs() { return _.includes(this.props.location.pathname, WebsitePaths.JSONSchemas); } + private _isViewingSolCovDocs() { + return _.includes(this.props.location.pathname, WebsitePaths.SolCov); + } private _isViewingWiki() { return _.includes(this.props.location.pathname, WebsitePaths.Wiki); } @@ -460,6 +478,7 @@ export class TopBar extends React.Component { this._isViewingWeb3WrapperDocs() || this._isViewingDeployerDocs() || this._isViewingJsonSchemasDocs() || + this._isViewingSolCovDocs() || this._isViewingConnectDocs() ); } diff --git a/packages/website/ts/containers/sol_cov_documentation.ts b/packages/website/ts/containers/sol_cov_documentation.ts new file mode 100644 index 000000000..2b901ec6f --- /dev/null +++ b/packages/website/ts/containers/sol_cov_documentation.ts @@ -0,0 +1,89 @@ +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/sol_cov/introduction'); +const InstallationMarkdown = require('md/docs/sol_cov/installation'); +const UsageMarkdown = require('md/docs/sol_cov/usage'); +/* tslint:enable:no-var-requires */ + +const docSections = { + introduction: 'introduction', + installation: 'installation', + usage: 'usage', + coverageSubprovider: 'coverageSubprovider', + types: docConstants.TYPES_SECTION_NAME, +}; + +const docsInfoConfig: DocsInfoConfig = { + id: DocPackages.SolCov, + type: SupportedDocJson.TypeDoc, + displayName: 'Sol-cov', + packageUrl: 'https://github.com/0xProject/0x-monorepo', + menu: { + introduction: [docSections.introduction], + install: [docSections.installation], + usage: [docSections.usage], + coverageSubprovider: [docSections.coverageSubprovider], + types: [docSections.types], + }, + sectionNameToMarkdown: { + [docSections.introduction]: IntroMarkdown, + [docSections.installation]: InstallationMarkdown, + [docSections.usage]: UsageMarkdown, + }, + sectionNameToModulePath: { + [docSections.coverageSubprovider]: ['"sol-cov/src/coverage_subprovider"'], + [docSections.types]: ['"subproviders/src/types"'], + }, + menuSubsectionToVersionWhenIntroduced: {}, + sections: docSections, + visibleConstructors: [docSections.coverageSubprovider], + 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: ['NextCallback', 'OnNextCompleted', 'ErrorCallback'], + typeNameToExternalLink: {}, + typeNameToPrefix: { + JSONRPCRequestPayload: 'Web3', + }, + typeNameToDocSection: {}, + }, +}; +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 b5166ebca..1241c222b 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -54,6 +54,9 @@ const LazyDeployerDocumentation = createLazyComponent('Documentation', async () const LazyJSONSchemasDocumentation = createLazyComponent('Documentation', async () => System.import(/* webpackChunkName: "connectDocs" */ 'ts/containers/json_schemas_documentation'), ); +const LazySolCovDocumentation = createLazyComponent('Documentation', async () => + System.import(/* webpackChunkName: "connectDocs" */ 'ts/containers/sol_cov_documentation'), +); analytics.init(); // tslint:disable-next-line:no-floating-promises @@ -75,6 +78,7 @@ render( +