From dac44a858ea25482d7e173236d1cdf0461a48ecd Mon Sep 17 00:00:00 2001 From: cjsha Date: Mon, 28 Oct 2024 21:45:36 -0400 Subject: [PATCH] Filter out properties w/ [Browsable(false)] attribute --- template/ManagedReference.extension.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/template/ManagedReference.extension.js b/template/ManagedReference.extension.js index 2c162f1..c3f99d7 100644 --- a/template/ManagedReference.extension.js +++ b/template/ManagedReference.extension.js @@ -31,7 +31,8 @@ function processChildProperty(child, sharedModel) { return { 'name': child.name[0].value, 'type': child.syntax.return.type.specName[0].value, - 'propertyDescription': { + 'propertyDescription': + { 'text': addCodeTag([child.summary, child.remarks].join('')), 'hasEnum': enumFields.length > 0, 'enum': enumFields, @@ -39,27 +40,34 @@ function processChildProperty(child, sharedModel) { } } +const filterProperties = propertyCandidate => propertyCandidate.type === 'property' && !propertyCandidate?.attributes.some(attribute => + attribute.type === 'System.ComponentModel.BrowsableAttribute' && attribute.arguments[0].value === false); + function extractPropertiesData(model, sharedModel) { return model?.children - .filter(child => child.type === 'property' && child.syntax) + .filter(filterProperties) .map(child => processChildProperty(child, sharedModel)); } function extractPropertiesFromInheritedMembersData(model, sharedModel) { return model.inheritedMembers - .filter(inheritedMember => inheritedMember.type === 'property') - .map(inheritedMember => ( - processChildProperty( + .filter(filterProperties) + .map(inheritedMember => + ( + processChildProperty + ( sharedModel[`~/api/${inheritedMember.parent}.yml`].children.find(inheritedMemberChild => inheritedMemberChild.uid === inheritedMember.uid), sharedModel ) - )); + ) + ); } function extractConstituentOperatorsData(model) { return model?.children .filter(child => child.type === 'property' && model.__global._shared?.[`~/api/${child.syntax.return.type.uid}.yml`].type === 'class') - .map(child => { + .map(child => + { const deviceModel = model.__global._shared?.[`~/api/${child.syntax.return.type.uid}.yml`]; const subProperties = sortPropertiesData(extractPropertiesData(deviceModel, model.__global._shared)); return { @@ -69,7 +77,8 @@ function extractConstituentOperatorsData(model) { 'hasSubProperties': subProperties === undefined || subProperties.length === 0 ? false : true, 'subProperties': subProperties, }; - }); + } + ); } function extractOperatorData(model) {