Add ability to nest doc ref markdown under specific versions
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
[
|
||||
{
|
||||
"version": "0.0.15",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Nest MD files under versions so that you can update them for future versions"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.0.14",
|
||||
|
@@ -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"
|
||||
|
@@ -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,14 @@ 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);
|
||||
// Get version LTE to selectedVersion
|
||||
const eligibleVersions = _.filter(markdownVersions, mdVersion => {
|
||||
return semver.lte(mdVersion, 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
|
||||
|
@@ -24,7 +24,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 _docsInfo: DocsInfoConfig;
|
||||
@@ -34,7 +34,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;
|
||||
|
@@ -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 };
|
||||
|
Reference in New Issue
Block a user