aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/pages/documentation/docs_info.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-29 05:11:04 +0800
committerFabio Berger <me@fabioberger.com>2017-11-29 05:11:04 +0800
commit72a00ac2df47ff793d74c2a82c7f403f501e784a (patch)
tree082d38d2ed5a36ec4b8f7e0bd156841ca86cf005 /packages/website/ts/pages/documentation/docs_info.ts
parentfcddd503b76283266946dc1f04b299d0606c90bb (diff)
downloaddexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.gz
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.bz2
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.lz
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.xz
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.tar.zst
dexon-sol-tools-72a00ac2df47ff793d74c2a82c7f403f501e784a.zip
Refactor the topLevel documentation react components for 0x.js and Smart contracts into a single component
Diffstat (limited to 'packages/website/ts/pages/documentation/docs_info.ts')
-rw-r--r--packages/website/ts/pages/documentation/docs_info.ts55
1 files changed, 54 insertions, 1 deletions
diff --git a/packages/website/ts/pages/documentation/docs_info.ts b/packages/website/ts/pages/documentation/docs_info.ts
index 326ebb31c..f607c2185 100644
--- a/packages/website/ts/pages/documentation/docs_info.ts
+++ b/packages/website/ts/pages/documentation/docs_info.ts
@@ -1,6 +1,14 @@
import compareVersions = require('compare-versions');
import * as _ from 'lodash';
-import {DocsInfoConfig, DocsMenu, SectionsMap} from 'ts/types';
+import {
+ DocAgnosticFormat,
+ DocsInfoConfig,
+ DocsMenu,
+ DoxityDocObj,
+ MenuSubsectionsBySection,
+ SectionsMap,
+ TypeDocNode,
+} from 'ts/types';
export class DocsInfo {
public packageName: string;
@@ -49,4 +57,49 @@ export class DocsInfo {
});
return finalMenu;
}
+ public getMenuSubsectionsBySection(docAgnosticFormat?: DocAgnosticFormat): MenuSubsectionsBySection {
+ const menuSubsectionsBySection = {} as MenuSubsectionsBySection;
+ if (_.isUndefined(docAgnosticFormat)) {
+ return menuSubsectionsBySection;
+ }
+
+ const docSections = _.keys(this.sections);
+ _.each(docSections, sectionName => {
+ const docSection = docAgnosticFormat[sectionName];
+ if (_.isUndefined(docSection)) {
+ return; // no-op
+ }
+
+ if (!_.isUndefined(this.sections.types) && sectionName === this.sections.types) {
+ const sortedTypesNames = _.sortBy(docSection.types, 'name');
+ const typeNames = _.map(sortedTypesNames, t => t.name);
+ menuSubsectionsBySection[sectionName] = typeNames;
+ } else {
+ let eventNames: string[] = [];
+ if (!_.isUndefined(docSection.events)) {
+ const sortedEventNames = _.sortBy(docSection.events, 'name');
+ eventNames = _.map(sortedEventNames, m => m.name);
+ }
+ const sortedMethodNames = _.sortBy(docSection.methods, 'name');
+ const methodNames = _.map(sortedMethodNames, m => m.name);
+ menuSubsectionsBySection[sectionName] = [...methodNames, ...eventNames];
+ }
+ });
+ return menuSubsectionsBySection;
+ }
+ public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat) {
+ if (_.isUndefined(this.sections.types)) {
+ return {};
+ }
+
+ const typeDocSection = docAgnosticFormat[this.sections.types];
+ const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name');
+ return typeDefinitionByName;
+ }
+ public isVisibleConstructor(sectionName: string): boolean {
+ return _.includes(this.docsInfo.visibleConstructors, sectionName);
+ }
+ public convertToDocAgnosticFormat(docObj: DoxityDocObj|TypeDocNode): DocAgnosticFormat {
+ return this.docsInfo.convertToDocAgnosticFormatFn(docObj, this);
+ }
}