-
Notifications
You must be signed in to change notification settings - Fork 669
[api-extractor] Customize which TSDoc tags appear in API reports #5079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d588278
feat: [WIP]: Allow customization of tags included in API reports
Josmithr 2eb8a36
docs: Update code comments
Josmithr 6a017cb
fix: Align schema property name with code
Josmithr 05bae99
test: Update test case to leverage new functionality
Josmithr c2c0dc1
refactor: Rename property
Josmithr 6dab01c
refactor: Make the structure of `tagsToReport` easier to override
Josmithr bc7a038
fix: Config handling
Josmithr 7473f54
test: Update test scenario
Josmithr da818e6
docs: Fix comment
Josmithr 71799fe
Merge branch 'main' into api-extractor/custom-tags
example 53ab8d1
docs: Update comments
example 9873057
docs: Examples
example 6a058f6
test: Add unit test case
example cf8e2dc
revert: Test
example f074834
test: Add and fix tests
example fd164c6
revert: Line formatting change
Josmithr b4963c3
docs: Add changesets
example 521aeba
Merge branch 'api-extractor/custom-tags' of https://github.com/Josmit…
example 4a2b163
revert: Schema base changes
Josmithr d9f2922
build: Add missing test dependency
example 70b98ba
build: Update lockfile
example b449e09
test: Update test to work `api-extractor-scenarios` limitations with …
example 8a06d08
test: Fix test case
example File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
apps/api-extractor/src/api/test/ExtractorConfig-tagsToReport.test.ts
This file contains hidden or 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,36 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import * as path from 'path'; | ||
|
|
||
| import { ExtractorConfig } from '../ExtractorConfig'; | ||
|
|
||
| const testDataFolder: string = path.join(__dirname, 'test-data'); | ||
|
|
||
| describe('ExtractorConfig-tagsToReport', () => { | ||
| it('tagsToReport merge correctly', () => { | ||
| const extractorConfig: ExtractorConfig = ExtractorConfig.loadFileAndPrepare( | ||
| path.join(testDataFolder, 'tags-to-report/api-extractor.json') | ||
| ); | ||
| const { tagsToReport } = extractorConfig; | ||
| expect(tagsToReport).toEqual({ | ||
| '@deprecated': true, | ||
| '@eventProperty': true, | ||
| '@myCustomTag': true, | ||
| '@myCustomTag2': false, | ||
| '@override': false, | ||
| '@sealed': true, | ||
| '@virtual': true | ||
| }); | ||
| }); | ||
| it('Invalid tagsToReport values', () => { | ||
| const expectedErrorMessage = `"tagsToReport" contained one or more invalid tags: | ||
| \t- @public: Release tags are always included in API reports and must not be specified | ||
| \t- @-invalid-tag-2: A TSDoc tag name must start with a letter and contain only letters and numbers`; | ||
| expect(() => | ||
| ExtractorConfig.loadFileAndPrepare( | ||
| path.join(testDataFolder, 'invalid-tags-to-report/api-extractor.json') | ||
| ) | ||
| ).toThrowError(expectedErrorMessage); | ||
| }); | ||
| }); |
1 change: 1 addition & 0 deletions
1
apps/api-extractor/src/api/test/test-data/invalid-tags-to-report/README.md
This file contains hidden or 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 @@ | ||
| Test case to ensure that merging of `apiReport.tagsToReport` is correct. |
23 changes: 23 additions & 0 deletions
23
apps/api-extractor/src/api/test/test-data/invalid-tags-to-report/api-extractor.json
This file contains hidden or 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,23 @@ | ||
| { | ||
| "$schema": "../../../../schemas/api-extractor.schema.json", | ||
|
|
||
| "mainEntryPointFilePath": "index.d.ts", | ||
|
|
||
| "apiReport": { | ||
| "enabled": true, | ||
| "tagsToReport": { | ||
| "@validTag1": true, // Valid custom tag | ||
| "@-invalid-tag-2": true, // Invalid tag - invalid characters | ||
| "@public": false, // Release tags must not be specified | ||
| "@override": false // Valid (override base tag) | ||
| } | ||
| }, | ||
|
|
||
| "docModel": { | ||
| "enabled": true | ||
| }, | ||
|
|
||
| "dtsRollup": { | ||
| "enabled": true | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
apps/api-extractor/src/api/test/test-data/invalid-tags-to-report/index.d.ts
This file contains hidden or 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 @@ | ||
| // empty file |
4 changes: 4 additions & 0 deletions
4
apps/api-extractor/src/api/test/test-data/invalid-tags-to-report/package.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "name": "tags-to-report", | ||
| "version": "1.0.0" | ||
| } |
1 change: 1 addition & 0 deletions
1
apps/api-extractor/src/api/test/test-data/tags-to-report/README.md
This file contains hidden or 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 @@ | ||
| Test case to ensure that merging of `apiReport.tagsToReport` is correct. |
17 changes: 17 additions & 0 deletions
17
apps/api-extractor/src/api/test/test-data/tags-to-report/api-extractor-base.json
This file contains hidden or 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,17 @@ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
|
|
||
| "mainEntryPointFilePath": "index.d.ts", | ||
|
|
||
| "apiReport": { | ||
| "enabled": true | ||
| }, | ||
|
|
||
| "docModel": { | ||
| "enabled": true | ||
| }, | ||
|
|
||
| "dtsRollup": { | ||
| "enabled": true | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
apps/api-extractor/src/api/test/test-data/tags-to-report/api-extractor.json
This file contains hidden or 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,11 @@ | ||
| { | ||
| "extends": "./api-extractor-base.json", | ||
|
|
||
| "apiReport": { | ||
| "tagsToReport": { | ||
| "@myCustomTag": true, // Enable reporting of custom tag | ||
| "@override": false, // Disable default reporting of `@override` tag | ||
| "@myCustomTag2": false // Disable reporting of custom tag (not included by base config) | ||
| } | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
apps/api-extractor/src/api/test/test-data/tags-to-report/index.d.ts
This file contains hidden or 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 @@ | ||
| // empty file |
4 changes: 4 additions & 0 deletions
4
apps/api-extractor/src/api/test/test-data/tags-to-report/package.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "name": "tags-to-report", | ||
| "version": "1.0.0" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.