diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-04 01:24:58 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-04 01:24:58 +0800 |
commit | c17d6c47c3253cf32c2dada8f7f871563f7209e9 (patch) | |
tree | eeed0148c8a9b60a5e3aa31c50cc8f4953b6a25d /packages/react-docs/src/utils | |
parent | a728247d6c4819d15a7fadd4cd6dd582f150b258 (diff) | |
download | dexon-sol-tools-c17d6c47c3253cf32c2dada8f7f871563f7209e9.tar dexon-sol-tools-c17d6c47c3253cf32c2dada8f7f871563f7209e9.tar.gz dexon-sol-tools-c17d6c47c3253cf32c2dada8f7f871563f7209e9.tar.bz2 dexon-sol-tools-c17d6c47c3253cf32c2dada8f7f871563f7209e9.tar.lz dexon-sol-tools-c17d6c47c3253cf32c2dada8f7f871563f7209e9.tar.xz dexon-sol-tools-c17d6c47c3253cf32c2dada8f7f871563f7209e9.tar.zst dexon-sol-tools-c17d6c47c3253cf32c2dada8f7f871563f7209e9.zip |
Properly render class/objectLiteral properties that are simple variables
Diffstat (limited to 'packages/react-docs/src/utils')
-rw-r--r-- | packages/react-docs/src/utils/typedoc_utils.ts | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index b74b9562b..2eee2fa59 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -86,7 +86,13 @@ export const typeDocUtils = { const entities = child.children; const commentObj = child.comment; const sectionComment = !_.isUndefined(commentObj) ? commentObj.shortText : ''; - const docSection = typeDocUtils._convertEntitiesToDocSection(entities, docsInfo, sectionName); + const isClassOrObjectLiteral = true; + const docSection = typeDocUtils._convertEntitiesToDocSection( + entities, + docsInfo, + sectionName, + isClassOrObjectLiteral, + ); docSection.comment = sectionComment; docAgnosticFormat[sectionName] = docSection; break; @@ -127,7 +133,12 @@ export const typeDocUtils = { return docAgnosticFormat; }, - _convertEntitiesToDocSection(entities: TypeDocNode[], docsInfo: DocsInfo, sectionName: string): DocSection { + _convertEntitiesToDocSection( + entities: TypeDocNode[], + docsInfo: DocsInfo, + sectionName: string, + isClassOrObjectLiteral: boolean = false, + ): DocSection { const docSection: DocSection = { comment: '', constructors: [], @@ -194,6 +205,32 @@ export const typeDocUtils = { } break; + case KindString.Variable: + if (isClassOrObjectLiteral) { + // Render as a property + const property = typeDocUtils._convertProperty( + entity, + docsInfo.sections, + sectionName, + docsInfo.id, + ); + docSection.properties.push(property); + } else { + // Otherwise, render as a type + const customType = typeDocUtils._convertCustomType( + entity, + docsInfo.sections, + sectionName, + docsInfo.id, + ); + const seenTypeNames = _.map(docSection.types, t => t.name); + const isUnseen = !_.includes(seenTypeNames, customType.name); + if (isUnseen) { + docSection.types.push(customType); + } + } + break; + case KindString.Interface: case KindString.Variable: case KindString.Enumeration: @@ -221,6 +258,7 @@ export const typeDocUtils = { throw errorUtils.spawnSwitchErr('kindString', entity.kindString); } }); + console.log('docSection', docSection); return docSection; }, _convertCustomType(entity: TypeDocNode, sections: SectionsMap, sectionName: string, docId: string): CustomType { |