Skip to content

Commit b553ea7

Browse files
committed
add DeclarationReflection.relevanceBoost back for search customization
1 parent 15f0f2a commit b553ea7

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/lib/models/DeclarationReflection.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ export class DeclarationReflection extends ContainerReflection {
4747
*/
4848
sources?: SourceReference[];
4949

50+
/**
51+
* Precomputed boost for search results, may be less than 1 to de-emphasize this member in search results.
52+
* Does NOT include group/category values as they are computed when building the JS index.
53+
*/
54+
relevanceBoost?: number;
55+
5056
/**
5157
* The escaped name of this declaration assigned by the TS compiler if there is an associated symbol.
5258
* This is used to retrieve properties for analyzing inherited members.
@@ -306,6 +312,7 @@ export class DeclarationReflection extends ContainerReflection {
306312
variant: this.variant,
307313
packageVersion: this.packageVersion,
308314
sources: serializer.toObjectsOptional(this.sources),
315+
relevanceBoost: this.relevanceBoost === 1 ? undefined : this.relevanceBoost,
309316
typeParameters: serializer.toObjectsOptional(this.typeParameters),
310317
type: serializer.toObject(this.type),
311318
signatures: serializer.toObjectsOptional(this.signatures),
@@ -366,6 +373,7 @@ export class DeclarationReflection extends ContainerReflection {
366373
obj.sources,
367374
(src) => new SourceReference(src.fileName, src.line, src.character),
368375
);
376+
this.relevanceBoost = obj.relevanceBoost;
369377

370378
this.typeParameters = de.reviveMany(obj.typeParameters, (tp) => de.constructReflection(tp));
371379
this.type = de.revive(obj.type, (t) => de.constructType(t));

src/lib/output/plugins/JavascriptIndexPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class JavascriptIndexPlugin extends RendererComponent {
177177
}
178178

179179
private getBoost(refl: DeclarationReflection | DocumentReflection): number {
180-
let boost = 1;
180+
let boost = refl.relevanceBoost ?? 1;
181181

182182
for (
183183
const group of GroupPlugin.getGroups(

src/lib/serialization/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export interface DeclarationReflection extends
165165
| "variant"
166166
| "packageVersion"
167167
| "sources"
168+
| "relevanceBoost"
168169
| "type"
169170
| "signatures"
170171
| "indexSignatures"

0 commit comments

Comments
 (0)