aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-docs/src/docs_info.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-10-01 23:37:44 +0800
committerGitHub <noreply@github.com>2018-10-01 23:37:44 +0800
commitbad6761e13d5348eccdf8ae37e83b152740dbe45 (patch)
tree9687e509f18164ac78ff612ead79ebd9eb977527 /packages/react-docs/src/docs_info.ts
parentac14dd2b29b42ef4d2a46db9b70d4d30cf9bd40f (diff)
parent6ffdc318e7b15cc43f4b3e0ffc39786cdf4c5c05 (diff)
downloaddexon-sol-tools-bad6761e13d5348eccdf8ae37e83b152740dbe45.tar
dexon-sol-tools-bad6761e13d5348eccdf8ae37e83b152740dbe45.tar.gz
dexon-sol-tools-bad6761e13d5348eccdf8ae37e83b152740dbe45.tar.bz2
dexon-sol-tools-bad6761e13d5348eccdf8ae37e83b152740dbe45.tar.lz
dexon-sol-tools-bad6761e13d5348eccdf8ae37e83b152740dbe45.tar.xz
dexon-sol-tools-bad6761e13d5348eccdf8ae37e83b152740dbe45.tar.zst
dexon-sol-tools-bad6761e13d5348eccdf8ae37e83b152740dbe45.zip
Merge pull request #1099 from 0xProject/solidityDocRefImprovements
Solidity Doc Improvements
Diffstat (limited to 'packages/react-docs/src/docs_info.ts')
-rw-r--r--packages/react-docs/src/docs_info.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts
index 6355a2f88..092a8c266 100644
--- a/packages/react-docs/src/docs_info.ts
+++ b/packages/react-docs/src/docs_info.ts
@@ -18,6 +18,7 @@ export class DocsInfo {
public packageName: string;
public packageUrl: string;
public menu: DocsMenu;
+ public typeSectionName: string;
public sections: SectionsMap;
public sectionNameToMarkdownByVersion: SectionNameToMarkdownByVersion;
public contractsByVersionByNetworkId?: ContractsByVersionByNetworkId;
@@ -28,6 +29,7 @@ export class DocsInfo {
this.displayName = config.displayName;
this.packageName = config.packageName;
this.packageUrl = config.packageUrl;
+ this.typeSectionName = config.type === SupportedDocJson.SolDoc ? 'structs' : 'types';
this.sections = config.markdownSections;
this.sectionNameToMarkdownByVersion = config.sectionNameToMarkdownByVersion;
this.contractsByVersionByNetworkId = config.contractsByVersionByNetworkId;
@@ -53,7 +55,7 @@ export class DocsInfo {
_.isEmpty(docSection.properties) &&
_.isEmpty(docSection.events);
- if (!_.isUndefined(this.sections.types) && sectionName === this.sections.types) {
+ if (sectionName === this.typeSectionName) {
const sortedTypesNames = _.sortBy(docSection.types, 'name');
const typeNames = _.map(sortedTypesNames, t => t.name);
menuSubsectionsBySection[sectionName] = typeNames;
@@ -82,12 +84,12 @@ export class DocsInfo {
return menuSubsectionsBySection;
}
public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): { [name: string]: TypeDefinitionByName } {
- if (_.isUndefined(this.sections.types)) {
+ if (_.isUndefined(docAgnosticFormat[this.typeSectionName])) {
return {};
}
- const typeDocSection = docAgnosticFormat[this.sections.types];
- const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name') as any;
+ const section = docAgnosticFormat[this.typeSectionName];
+ const typeDefinitionByName = _.keyBy(section.types, 'name') as any;
return typeDefinitionByName;
}
}