Skip to content

Commit a7e5256

Browse files
authored
feat(api-markdown-documenter): Update filtering logic to exclude api items based on release tags (#20591)
[AB#7194](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/7194) ## Description This PR adds filtering logic in the link generation code to exclude api items based on release tags. If a resolved API item should not be included based on its release tag, a span node in italics is generated instead.
1 parent 308c21f commit a7e5256

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

tools/api-markdown-documenter/src/api-item-transforms/Utilities.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import { type DocDeclarationReference } from "@microsoft/tsdoc";
1313

1414
import { DocumentNode, type SectionNode } from "../documentation-domain/index.js";
1515
import { type Link } from "../Link.js";
16-
import { getDocumentPathForApiItem, getLinkForApiItem } from "./ApiItemTransformUtilities.js";
16+
import {
17+
getDocumentPathForApiItem,
18+
getLinkForApiItem,
19+
shouldItemBeIncluded,
20+
} from "./ApiItemTransformUtilities.js";
1721
import { type TsdocNodeTransformOptions } from "./TsdocNodeTransforms.js";
1822
import { type ApiItemTransformationConfiguration } from "./configuration/index.js";
1923
import { wrapInSection } from "./helpers/index.js";
@@ -123,6 +127,13 @@ function resolveSymbolicLink(
123127

124128
return undefined;
125129
}
130+
const resolvedApiItem = resolvedReference.resolvedApiItem;
131+
132+
// Return undefined if the resolved API item should be excluded based on release tags
133+
if (!shouldItemBeIncluded(resolvedApiItem, config)) {
134+
logger.verbose("Excluding link to item based on release tags");
135+
return undefined;
136+
}
126137

127138
return getLinkForApiItem(resolvedReference.resolvedApiItem, config);
128139
}

tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/flat-config/simple-suite-test.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h1 id="simple-suite-test-remarks">
4848
- Good link (no alias): <a href='docs/simple-suite-test#testclass-class'>TestClass</a>
4949
</p>
5050
<p>
51-
- Good link (with alias): <a href='docs/simple-suite-test#testfunction-function'>function alias text</a>
51+
- Good link (with alias): <span><i>function alias text</i></span>
5252
</p>
5353
<p>
5454
- Bad link (no alias): <span><i>InvalidItem</i></span>

tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/sparse-config/simple-suite-test.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ <h3 id="simple-suite-test-remarks">
4646
- Good link (no alias): <a href='docs/simple-suite-test/testclass-class'>TestClass</a>
4747
</p>
4848
<p>
49-
- Good link (with alias): <a href='docs/simple-suite-test/testfunction-function'>function alias text</a>
49+
- Good link (with alias): <span><i>function alias text</i></span>
5050
</p>
5151
<p>
5252
- Bad link (no alias): <span><i>InvalidItem</i></span>

tools/api-markdown-documenter/src/test/snapshots/markdown/simple-suite-test/flat-config/simple-suite-test.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Also, here is a link test, including a bad link, because we should have some rea
2424

2525
- Good link (no alias): [TestClass](docs/simple-suite-test#testclass-class)
2626

27-
- Good link (with alias): [function alias text](docs/simple-suite-test#testfunction-function)
27+
- Good link (with alias): _function alias text_
2828

2929
- Bad link (no alias): _InvalidItem_
3030

tools/api-markdown-documenter/src/test/snapshots/markdown/simple-suite-test/sparse-config/simple-suite-test.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Also, here is a link test, including a bad link, because we should have some rea
2222

2323
- Good link (no alias): [TestClass](docs/simple-suite-test/testclass-class)
2424

25-
- Good link (with alias): [function alias text](docs/simple-suite-test/testfunction-function)
25+
- Good link (with alias): _function alias text_
2626

2727
- Bad link (no alias): _InvalidItem_
2828

0 commit comments

Comments
 (0)