aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-docs/src/docs_info.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-10-12 21:54:44 +0800
committerFabio Berger <me@fabioberger.com>2018-10-12 21:54:44 +0800
commitde20ef1a49966153f25236ee68b186cd49f8dc20 (patch)
tree6313477ff212da20b9d4dbcb27fb39a2dd4ff0d1 /packages/react-docs/src/docs_info.ts
parentdcdc411ab73c860d58a47a9b721d8047e68ce738 (diff)
downloaddexon-sol-tools-de20ef1a49966153f25236ee68b186cd49f8dc20.tar
dexon-sol-tools-de20ef1a49966153f25236ee68b186cd49f8dc20.tar.gz
dexon-sol-tools-de20ef1a49966153f25236ee68b186cd49f8dc20.tar.bz2
dexon-sol-tools-de20ef1a49966153f25236ee68b186cd49f8dc20.tar.lz
dexon-sol-tools-de20ef1a49966153f25236ee68b186cd49f8dc20.tar.xz
dexon-sol-tools-de20ef1a49966153f25236ee68b186cd49f8dc20.tar.zst
dexon-sol-tools-de20ef1a49966153f25236ee68b186cd49f8dc20.zip
Refactor Home so that Dev section chrome is reusable across pages
Diffstat (limited to 'packages/react-docs/src/docs_info.ts')
-rw-r--r--packages/react-docs/src/docs_info.ts59
1 files changed, 28 insertions, 31 deletions
diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts
index 549106c77..d75a1676c 100644
--- a/packages/react-docs/src/docs_info.ts
+++ b/packages/react-docs/src/docs_info.ts
@@ -17,7 +17,7 @@ export class DocsInfo {
public displayName: string;
public packageName: string;
public packageUrl: string;
- public menu: DocsMenu;
+ public markdownMenu: DocsMenu;
public typeSectionName: string;
public sections: SectionsMap;
public sectionNameToMarkdownByVersion: SectionNameToMarkdownByVersion;
@@ -25,7 +25,7 @@ export class DocsInfo {
constructor(config: DocsInfoConfig) {
this.id = config.id;
this.type = config.type;
- this.menu = config.markdownMenu;
+ this.markdownMenu = config.markdownMenu;
this.displayName = config.displayName;
this.packageName = config.packageName;
this.packageUrl = config.packageUrl;
@@ -34,10 +34,31 @@ export class DocsInfo {
this.sectionNameToMarkdownByVersion = config.sectionNameToMarkdownByVersion;
this.contractsByVersionByNetworkId = config.contractsByVersionByNetworkId;
}
- public getSubsectionNameToLinks(docAgnosticFormat?: DocAgnosticFormat): ObjectMap<ALink[]> {
- const subsectionNameToLinks: ObjectMap<ALink[]> = {};
+ public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): { [name: string]: TypeDefinitionByName } {
+ if (_.isUndefined(docAgnosticFormat[this.typeSectionName])) {
+ return {};
+ }
+
+ const section = docAgnosticFormat[this.typeSectionName];
+ const typeDefinitionByName = _.keyBy(section.types, 'name') as any;
+ return typeDefinitionByName;
+ }
+ public getSectionNameToLinks(docAgnosticFormat: DocAgnosticFormat): ObjectMap<ALink[]> {
+ const sectionNameToLinks: ObjectMap<ALink[]> = {};
+ _.each(this.markdownMenu, (linkTitles, sectionName) => {
+ sectionNameToLinks[sectionName] = [];
+ _.each(linkTitles, linkTitle => {
+ const to = sharedUtils.getIdFromName(linkTitle);
+ const links = sectionNameToLinks[sectionName];
+ links.push({
+ title: linkTitle,
+ to,
+ });
+ });
+ });
+
if (_.isUndefined(docAgnosticFormat)) {
- return subsectionNameToLinks;
+ return sectionNameToLinks;
}
const docSections = _.keys(this.sections);
@@ -64,7 +85,7 @@ export class DocsInfo {
title: typeName,
};
});
- subsectionNameToLinks[sectionName] = typeLinks;
+ sectionNameToLinks[sectionName] = typeLinks;
} else if (isExportedFunctionSection) {
// Noop so that we don't have the method listed underneath itself.
} else {
@@ -88,33 +109,9 @@ export class DocsInfo {
};
});
- subsectionNameToLinks[sectionName] = links;
+ sectionNameToLinks[sectionName] = links;
}
});
- return subsectionNameToLinks;
- }
- public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): { [name: string]: TypeDefinitionByName } {
- if (_.isUndefined(docAgnosticFormat[this.typeSectionName])) {
- return {};
- }
-
- const section = docAgnosticFormat[this.typeSectionName];
- const typeDefinitionByName = _.keyBy(section.types, 'name') as any;
- return typeDefinitionByName;
- }
- public getSectionNameToLinks(): ObjectMap<ALink[]> {
- const sectionNameToLinks: ObjectMap<ALink[]> = {};
- _.each(this.menu, (linkTitles, sectionName) => {
- sectionNameToLinks[sectionName] = [];
- _.each(linkTitles, linkTitle => {
- const to = sharedUtils.getIdFromName(linkTitle);
- const links = sectionNameToLinks[sectionName];
- links.push({
- title: linkTitle,
- to,
- });
- });
- });
return sectionNameToLinks;
}
}