From dddfe8ae50f315159143dfbd8e5dbfaf75de9210 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 27 Sep 2018 18:51:30 +0100 Subject: Add typeSectionName to docsInfo so we don't use hard-coded "Types" --- packages/react-docs/src/components/documentation.tsx | 2 +- packages/react-docs/src/docs_info.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'packages') diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 55aa1587e..f1cb32b68 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -266,7 +266,7 @@ export class Documentation extends React.Component
- +
{this._renderNetworkBadgesIfExists(sectionName)}
diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts index 6355a2f88..bf6aa07a7 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; @@ -86,8 +88,8 @@ export class DocsInfo { return {}; } - const typeDocSection = docAgnosticFormat[this.sections.types]; - const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name') as any; + const section = docAgnosticFormat[this.sections.types]; + const typeDefinitionByName = _.keyBy(section.types, 'name') as any; return typeDefinitionByName; } } -- cgit v1.2.3