-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement(api-markdown-documenter): Check for duplicate document pa…
…ths in transformation output and log warning for any encountered (#23514) It is possible to configure the system to generate multiple output documents targeting the same file path. To help users detect such cases, logic has been added to check transformation output for any documents with duplicate paths. If any are found, a warning is logged.
- Loading branch information
Showing
5 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tools/api-markdown-documenter/src/api-item-transforms/test/Utilities.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*! | ||
* Copyright (c) Microsoft Corporation and contributors. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { expect } from "chai"; | ||
|
||
import type { DocumentNode } from "../../index.js"; | ||
import { checkForDuplicateDocumentPaths } from "../Utilities.js"; | ||
|
||
describe("ApiItem to Documentation transformation utilities tests", () => { | ||
describe("checkForDuplicateDocumentPaths", () => { | ||
it("Empty list", () => { | ||
expect(() => checkForDuplicateDocumentPaths([])).to.not.throw(); | ||
}); | ||
|
||
it("No duplicates", () => { | ||
const documents: DocumentNode[] = [ | ||
{ documentPath: "foo" } as unknown as DocumentNode, | ||
{ documentPath: "bar" } as unknown as DocumentNode, | ||
{ documentPath: "baz" } as unknown as DocumentNode, | ||
]; | ||
expect(() => checkForDuplicateDocumentPaths(documents)).to.not.throw(); | ||
}); | ||
|
||
it("Contains duplicates", () => { | ||
const documents: DocumentNode[] = [ | ||
{ documentPath: "foo" } as unknown as DocumentNode, | ||
{ documentPath: "bar" } as unknown as DocumentNode, | ||
{ documentPath: "foo" } as unknown as DocumentNode, | ||
]; | ||
expect(() => checkForDuplicateDocumentPaths(documents)).to.throw(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters