aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/containers/smart_contracts_documentation.tsx
blob: ea2b19b8c918e8701a402ed9a1e21bee2e76dd82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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 {
    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 = {
    displayName: '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;
    availableDocVersions: string[];
}

interface ConnectedDispatch {
    dispatcher: Dispatcher;
    docsInfo: DocsInfo;
}

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 Documentation: React.ComponentClass<DocumentationAllProps> =
  connect(mapStateToProps, mapDispatchToProps)(DocumentationComponent);