Skip to content

Commit 0e27f35

Browse files
committed
Update YamlDocumenter to use ApiItem.getMergedSiblings() API
1 parent 3e6239e commit 0e27f35

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

apps/api-documenter/src/documenters/YamlDocumenter.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,12 @@ export class YamlDocumenter {
7575

7676
private _apiItemsByCanonicalReference: Map<string, ApiItem>;
7777
private _yamlReferences: IYamlReferences | undefined;
78-
// Keeps track of ApiItems whose names collide with one or more siblings.
79-
private _collisions: Set<ApiItem>;
80-
8178
private _outputFolder: string;
8279

8380
public constructor(apiModel: ApiModel) {
8481
this._apiModel = apiModel;
8582
this._markdownEmitter = new CustomMarkdownEmitter(this._apiModel);
8683
this._apiItemsByCanonicalReference = new Map<string, ApiItem>();
87-
this._collisions = new Set<ApiItem>();
8884

8985
this._initApiItems();
9086
}
@@ -274,7 +270,7 @@ export class YamlDocumenter {
274270
name = PackageName.getUnscopedName(name);
275271
}
276272

277-
if (this._collisions.has(apiItem)) {
273+
if (apiItem.getMergedSiblings().length > 1) {
278274
name += ` (${apiItem.kind})`;
279275
}
280276

@@ -613,37 +609,12 @@ export class YamlDocumenter {
613609

614610
// Recurse container members
615611
if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {
616-
const singletons: Map<string, ApiItem> = new Map<string, ApiItem>();
617-
const collidingNames: Set<string> = new Set<string>();
618612
for (const apiMember of apiItem.members) {
619-
this._trackCollisionsWithSiblings(apiMember, singletons, collidingNames);
620613
this._initApiItemsRecursive(apiMember);
621614
}
622615
}
623616
}
624617

625-
private _trackCollisionsWithSiblings(
626-
apiItem: ApiItem,
627-
singletons: Map<string, ApiItem>,
628-
collidingNames: Set<string>
629-
): void {
630-
if (!collidingNames.has(apiItem.displayName)) {
631-
const collision: ApiItem | undefined = singletons.get(apiItem.displayName);
632-
if (!collision) {
633-
// No collision. Record this singleton entry.
634-
singletons.set(apiItem.displayName, apiItem);
635-
return;
636-
}
637-
// First collision. Record the colliding name.
638-
collidingNames.add(apiItem.displayName);
639-
singletons.delete(apiItem.displayName);
640-
// Record the initial entry.
641-
this._collisions.add(collision);
642-
}
643-
// Record the colliding entry.
644-
this._collisions.add(apiItem);
645-
}
646-
647618
private _ensureYamlReferences(): IYamlReferences {
648619
if (!this._yamlReferences) {
649620
this._yamlReferences = {
@@ -839,7 +810,7 @@ export class YamlDocumenter {
839810
}
840811

841812
let disambiguator: string = '';
842-
if (this._collisions.has(apiItem)) {
813+
if (apiItem.getMergedSiblings().length > 1) {
843814
disambiguator = `-${apiItem.kind.toLowerCase()}`;
844815
}
845816

@@ -850,4 +821,4 @@ export class YamlDocumenter {
850821
console.log('Deleting old output from ' + this._outputFolder);
851822
FileSystem.ensureEmptyFolder(this._outputFolder);
852823
}
853-
}
824+
}

0 commit comments

Comments
 (0)