diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-07-21 07:15:04 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-07-21 07:15:04 +0800 |
commit | 6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8 (patch) | |
tree | 7b6a6eb86d6a0463221a502fb886bae6ff5a243c /packages/react-docs | |
parent | 938aabde3db0044c658e86765e1bbdbdce4e4a17 (diff) | |
parent | e54501522dcf93521c8ff7dfe5b216cffeaa1b29 (diff) | |
download | dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.gz dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.bz2 dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.lz dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.xz dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.zst dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.zip |
Merge branch 'v2-prototype' into feature/website/jobs-page-part2
* v2-prototype: (103 commits)
Add changelog entry for @0xproject/utils
Add AbortController polyfill to fetchAsync in utils
Increase node heap size for webpack command
Add missing timestamp to CHANGELOG entries
Upgrade some @0xproject packages to 1.0.0 in website
Hard code fillOrder selector into abiEncodeFillOrder
Returns byte array instead of memory range for encoding fillOrder calldata
Created LibAbiEncoder with `fillOrderNoThrow`
Add missing dep in migrations
Fix the abi-gen entry point
Fix linter error
Remove the postinstall hook
Update website package.json with original imports
@0xproject/sra-report@1.0.0
Change all package to depend on the new @0xproject/connect@1.0.0
@0xproject/connect@1.0.0
Use old assert version in @0xproject/connect
FIx a typo
Remove rc versions from unmigrated packages
0x.js@1.0.0-rc.2
...
Diffstat (limited to 'packages/react-docs')
-rw-r--r-- | packages/react-docs/CHANGELOG.json | 18 | ||||
-rw-r--r-- | packages/react-docs/package.json | 15 | ||||
-rw-r--r-- | packages/react-docs/src/components/documentation.tsx | 16 | ||||
-rw-r--r-- | packages/react-docs/src/docs_info.ts | 5 | ||||
-rw-r--r-- | packages/react-docs/src/types.ts | 6 |
5 files changed, 49 insertions, 11 deletions
diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json index d794e159b..1bb2da328 100644 --- a/packages/react-docs/CHANGELOG.json +++ b/packages/react-docs/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "timestamp": 1532043000, + "version": "1.0.0", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "0.0.17", + "changes": [ + { + "note": "Nest MD files under versions so that you can update them for future versions", + "pr": 844 + } + ] + }, + { "timestamp": 1531919263, "version": "0.0.16", "changes": [ diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index 023c63db2..c3853e6ba 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-docs", - "version": "0.0.16", + "version": "1.0.0", "engines": { "node": ">=6.12" }, @@ -25,9 +25,9 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^0.4.6", - "@0xproject/monorepo-scripts": "^0.2.2", - "@0xproject/tslint-config": "^0.4.21", + "@0xproject/dev-utils": "^1.0.0", + "@0xproject/monorepo-scripts": "^1.0.0", + "@0xproject/tslint-config": "^1.0.0", "@types/compare-versions": "^3.0.0", "copyfiles": "^1.2.0", "make-promises-safe": "^1.1.0", @@ -36,8 +36,8 @@ "typescript": "2.7.1" }, "dependencies": { - "@0xproject/react-shared": "^0.2.3", - "@0xproject/utils": "^0.7.3", + "@0xproject/react-shared": "^1.0.0", + "@0xproject/utils": "^1.0.0", "@types/lodash": "4.14.104", "@types/material-ui": "0.18.0", "@types/node": "^8.0.53", @@ -52,7 +52,8 @@ "react-dom": "15.6.1", "react-markdown": "^3.2.2", "react-scroll": "^1.5.2", - "react-tooltip": "^3.2.7" + "react-tooltip": "^3.2.7", + "semver": "5.5.0" }, "publishConfig": { "access": "public" diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index a4e6f4f6e..ff33220d2 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -12,6 +12,7 @@ import { import * as _ from 'lodash'; import CircularProgress from 'material-ui/CircularProgress'; import * as React from 'react'; +import * as semver from 'semver'; import { DocsInfo } from '../docs_info'; import { @@ -180,7 +181,20 @@ export class Documentation extends React.Component<DocumentationProps, Documenta return renderedSections; } private _renderSection(typeDefinitionByName: TypeDefinitionByName, sectionName: string): React.ReactNode { - const markdownFileIfExists = this.props.docsInfo.sectionNameToMarkdown[sectionName]; + const markdownVersions = _.keys(this.props.docsInfo.sectionNameToMarkdownByVersion); + const eligibleVersions = _.filter(markdownVersions, mdVersion => { + return semver.lte(mdVersion, this.props.selectedVersion); + }); + if (_.isEmpty(eligibleVersions)) { + throw new Error( + `No eligible markdown sections found for ${this.props.docsInfo.displayName} version ${ + this.props.selectedVersion + }.`, + ); + } + const sortedEligibleVersions = eligibleVersions.sort(semver.rcompare.bind(semver)); + const closestVersion = sortedEligibleVersions[0]; + const markdownFileIfExists = this.props.docsInfo.sectionNameToMarkdownByVersion[closestVersion][sectionName]; if (!_.isUndefined(markdownFileIfExists)) { return ( <MarkdownSection diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts index 5d46dbda6..b37942da6 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -9,6 +9,7 @@ import { DocsInfoTypeConfigs, DocsMenu, DoxityDocObj, + SectionNameToMarkdownByVersion, SectionsMap, SupportedDocJson, TypeDefinitionByName, @@ -24,7 +25,7 @@ export class DocsInfo { public packageUrl: string; public menu: DocsMenu; public sections: SectionsMap; - public sectionNameToMarkdown: { [sectionName: string]: string }; + public sectionNameToMarkdownByVersion: SectionNameToMarkdownByVersion; public contractsByVersionByNetworkId?: ContractsByVersionByNetworkId; public typeConfigs: DocsInfoTypeConfigs; private readonly _docsInfo: DocsInfoConfig; @@ -34,7 +35,7 @@ export class DocsInfo { this.displayName = config.displayName; this.packageUrl = config.packageUrl; this.sections = config.sections; - this.sectionNameToMarkdown = config.sectionNameToMarkdown; + this.sectionNameToMarkdownByVersion = config.sectionNameToMarkdownByVersion; this.contractsByVersionByNetworkId = config.contractsByVersionByNetworkId; this.typeConfigs = config.typeConfigs; this._docsInfo = config; diff --git a/packages/react-docs/src/types.ts b/packages/react-docs/src/types.ts index f4e61edc9..cbc774c2e 100644 --- a/packages/react-docs/src/types.ts +++ b/packages/react-docs/src/types.ts @@ -1,3 +1,7 @@ +export interface SectionNameToMarkdownByVersion { + [version: string]: { [sectionName: string]: string }; +} + export interface DocsInfoConfig { id: string; type: SupportedDocJson; @@ -5,7 +9,7 @@ export interface DocsInfoConfig { packageUrl: string; menu: DocsMenu; sections: SectionsMap; - sectionNameToMarkdown: { [sectionName: string]: string }; + sectionNameToMarkdownByVersion: SectionNameToMarkdownByVersion; visibleConstructors: string[]; sectionNameToModulePath?: { [sectionName: string]: string[] }; menuSubsectionToVersionWhenIntroduced?: { [sectionName: string]: string }; |