Properly render class/objectLiteral properties that are simple variables
This commit is contained in:
parent
a728247d6c
commit
c17d6c47c3
@ -86,7 +86,13 @@ export const typeDocUtils = {
|
|||||||
const entities = child.children;
|
const entities = child.children;
|
||||||
const commentObj = child.comment;
|
const commentObj = child.comment;
|
||||||
const sectionComment = !_.isUndefined(commentObj) ? commentObj.shortText : '';
|
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;
|
docSection.comment = sectionComment;
|
||||||
docAgnosticFormat[sectionName] = docSection;
|
docAgnosticFormat[sectionName] = docSection;
|
||||||
break;
|
break;
|
||||||
@ -127,7 +133,12 @@ export const typeDocUtils = {
|
|||||||
|
|
||||||
return docAgnosticFormat;
|
return docAgnosticFormat;
|
||||||
},
|
},
|
||||||
_convertEntitiesToDocSection(entities: TypeDocNode[], docsInfo: DocsInfo, sectionName: string): DocSection {
|
_convertEntitiesToDocSection(
|
||||||
|
entities: TypeDocNode[],
|
||||||
|
docsInfo: DocsInfo,
|
||||||
|
sectionName: string,
|
||||||
|
isClassOrObjectLiteral: boolean = false,
|
||||||
|
): DocSection {
|
||||||
const docSection: DocSection = {
|
const docSection: DocSection = {
|
||||||
comment: '',
|
comment: '',
|
||||||
constructors: [],
|
constructors: [],
|
||||||
@ -194,6 +205,32 @@ export const typeDocUtils = {
|
|||||||
}
|
}
|
||||||
break;
|
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.Interface:
|
||||||
case KindString.Variable:
|
case KindString.Variable:
|
||||||
case KindString.Enumeration:
|
case KindString.Enumeration:
|
||||||
@ -221,6 +258,7 @@ export const typeDocUtils = {
|
|||||||
throw errorUtils.spawnSwitchErr('kindString', entity.kindString);
|
throw errorUtils.spawnSwitchErr('kindString', entity.kindString);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('docSection', docSection);
|
||||||
return docSection;
|
return docSection;
|
||||||
},
|
},
|
||||||
_convertCustomType(entity: TypeDocNode, sections: SectionsMap, sectionName: string, docId: string): CustomType {
|
_convertCustomType(entity: TypeDocNode, sections: SectionsMap, sectionName: string, docId: string): CustomType {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user