diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-20 00:15:35 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-20 00:15:35 +0800 |
commit | f2c49e8b37141f26fafa4517ea7c6ca1804f82a0 (patch) | |
tree | ed900809fe57b0ef58ca37dd0a06340b2d6b4333 /packages/react-docs/src/components/documentation.tsx | |
parent | 34df5af2955079dadd7d63c67a3f93cc82adbff3 (diff) | |
parent | 9b6476a6b7db8db7b0fc6bbf9306c01566fb47a9 (diff) | |
download | dexon-sol-tools-f2c49e8b37141f26fafa4517ea7c6ca1804f82a0.tar dexon-sol-tools-f2c49e8b37141f26fafa4517ea7c6ca1804f82a0.tar.gz dexon-sol-tools-f2c49e8b37141f26fafa4517ea7c6ca1804f82a0.tar.bz2 dexon-sol-tools-f2c49e8b37141f26fafa4517ea7c6ca1804f82a0.tar.lz dexon-sol-tools-f2c49e8b37141f26fafa4517ea7c6ca1804f82a0.tar.xz dexon-sol-tools-f2c49e8b37141f26fafa4517ea7c6ca1804f82a0.tar.zst dexon-sol-tools-f2c49e8b37141f26fafa4517ea7c6ca1804f82a0.zip |
Merge branch 'v2-prototype' into doc-changes
* v2-prototype:
Add missing import
Remove comment and add assertion
Add ability to nest doc ref markdown under specific versions
Diffstat (limited to 'packages/react-docs/src/components/documentation.tsx')
-rw-r--r-- | packages/react-docs/src/components/documentation.tsx | 16 |
1 files changed, 15 insertions, 1 deletions
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 |