build(docs-infra): include inherited members in search index (#26676)
Closes #23800 PR Close #26676
This commit is contained in:
parent
f233131974
commit
7c730fe5b3
|
@ -164,10 +164,18 @@ function extractWords(text, words, keywordMap) {
|
|||
}
|
||||
|
||||
function extractMemberWords(doc, members, membersMap) {
|
||||
if (!doc) return;
|
||||
|
||||
if (doc.members) {
|
||||
doc.members.forEach(function(member) { extractWords(member.name, members, membersMap); });
|
||||
doc.members.forEach(member => extractWords(member.name, members, membersMap));
|
||||
}
|
||||
if (doc.statics) {
|
||||
doc.statics.forEach(function(member) { extractWords(member.name, members, membersMap); });
|
||||
doc.statics.forEach(member => extractWords(member.name, members, membersMap));
|
||||
}
|
||||
if (doc.extendsClauses) {
|
||||
doc.extendsClauses.forEach(clause => extractMemberWords(clause.doc, members, membersMap));
|
||||
}
|
||||
if (doc.implementsClauses) {
|
||||
doc.implementsClauses.forEach(clause => extractMemberWords(clause.doc, members, membersMap));
|
||||
}
|
||||
}
|
|
@ -128,6 +128,46 @@ describe('generateKeywords processor', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should add inherited member doc properties to the search terms', () => {
|
||||
const processor = processorFactory(mockLogger, mockReadFilesProcessor);
|
||||
const parentClass = {
|
||||
docType: 'class',
|
||||
name: 'ParentClass',
|
||||
members: [
|
||||
{ name: 'parentMember1' },
|
||||
],
|
||||
statics: [
|
||||
{ name: 'parentMember2' },
|
||||
],
|
||||
};
|
||||
const parentInterface = {
|
||||
docType: 'interface',
|
||||
name: 'ParentInterface',
|
||||
members: [
|
||||
{ name: 'parentMember3' },
|
||||
]
|
||||
};
|
||||
|
||||
const childClass = {
|
||||
docType: 'class',
|
||||
name: 'Child',
|
||||
members: [
|
||||
{ name: 'childMember1' }
|
||||
],
|
||||
statics: [
|
||||
{ name: 'childMember2' }
|
||||
],
|
||||
extendsClauses: [{ doc: parentClass }],
|
||||
implementsClauses: [{ doc: parentInterface }]
|
||||
};
|
||||
const docs = [childClass, parentClass, parentInterface];
|
||||
processor.$process(docs);
|
||||
const keywordsDoc = docs[docs.length - 1];
|
||||
expect(keywordsDoc.data[0].members.split(' ').sort().join(' ')).toEqual(
|
||||
'childmember1 childmember2 parentmember1 parentmember2 parentmember3'
|
||||
);
|
||||
});
|
||||
|
||||
it('should process terms prefixed with "ng" to include the term stripped of "ng"', () => {
|
||||
const processor = processorFactory(mockLogger, mockReadFilesProcessor);
|
||||
const docs = [
|
||||
|
|
Loading…
Reference in New Issue