From bd5cd66b98827eb4d1aa26b8f067fa199e058c18 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Thu, 22 Aug 2024 18:40:40 -0600 Subject: [PATCH] Fix validation of @link tags to symbols outside documentation Resolves #2681 --- CHANGELOG.md | 1 + src/lib/validation/links.ts | 3 ++- src/test/converter2/issues/gh2681.ts | 4 ++++ src/test/issues.c2.test.ts | 10 ++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/test/converter2/issues/gh2681.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index aed1336d1..165382f49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Bug Fixes - Fixed an issue where links in packages mode would be resolved incorrectly, #2680. +- `@link` tags to symbols which are not included in the documentation will produce invalid link warnings again, #2681. - Fixed handling of `@param` tags on comments attached to function callback parameters, #2683. ## v0.26.6 (2024-08-18) diff --git a/src/lib/validation/links.ts b/src/lib/validation/links.ts index dd63a1fdc..9608a2b6a 100644 --- a/src/lib/validation/links.ts +++ b/src/lib/validation/links.ts @@ -4,6 +4,7 @@ import { type Comment, type CommentDisplayPart, type ProjectReflection, + ReflectionSymbolId, } from "../models"; import type { Logger } from "../utils"; @@ -16,7 +17,7 @@ function getBrokenPartLinks(parts: readonly CommentDisplayPart[]) { if ( part.kind === "inline-tag" && linkTags.includes(part.tag) && - !part.target + (!part.target || part.target instanceof ReflectionSymbolId) ) { links.push(part.text.trim()); } diff --git a/src/test/converter2/issues/gh2681.ts b/src/test/converter2/issues/gh2681.ts new file mode 100644 index 000000000..1bf23a79a --- /dev/null +++ b/src/test/converter2/issues/gh2681.ts @@ -0,0 +1,4 @@ +/** + * {@link Generator} + */ +export const bug = 123; diff --git a/src/test/issues.c2.test.ts b/src/test/issues.c2.test.ts index 57033865c..9fec15046 100644 --- a/src/test/issues.c2.test.ts +++ b/src/test/issues.c2.test.ts @@ -1671,6 +1671,16 @@ describe("Issue Tests", () => { logger.expectNoOtherMessages(); }); + it("#2681 reports warnings on @link tags which resolve to a type not included in the documentation", () => { + const project = convert(); + app.options.setValue("validation", false); + app.options.setValue("validation", { invalidLink: true }); + app.validate(project); + logger.expectMessage( + 'warn: Failed to resolve link to "Generator" in comment for bug', + ); + }); + it("#2683 supports @param on parameters with functions", () => { const project = convert(); const action = querySig(project, "action");