From 14b87cfe0c11c2de655342483df51d4a81deea87 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Sun, 21 Jul 2024 09:29:58 -0600 Subject: [PATCH] Allow comments on signature parents to count for docs This is necessary because TypeDoc 0.26 allows function reflections to have documentation comments, not just signature reflections. This edge case was missed when adding support for that. Resolves #2644 --- src/lib/validation/documentation.ts | 8 +++++++- src/test/converter2/issues/gh2644.ts | 7 +++++++ src/test/issues.c2.test.ts | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/test/converter2/issues/gh2644.ts diff --git a/src/lib/validation/documentation.ts b/src/lib/validation/documentation.ts index da9df9db4..d57feafd1 100644 --- a/src/lib/validation/documentation.ts +++ b/src/lib/validation/documentation.ts @@ -100,7 +100,13 @@ export function validateDocumentation( const symbolId = project.getSymbolIdFromReflection(ref); - if (!ref.hasComment() && symbolId) { + // #2644, signatures may be documented by their parent reflection. + const hasComment = + ref.hasComment() || + (ref.kindOf(ReflectionKind.SomeSignature) && + ref.parent?.hasComment()); + + if (!hasComment && symbolId) { if (symbolId.fileName.includes("node_modules")) { continue; } diff --git a/src/test/converter2/issues/gh2644.ts b/src/test/converter2/issues/gh2644.ts new file mode 100644 index 000000000..a802fe388 --- /dev/null +++ b/src/test/converter2/issues/gh2644.ts @@ -0,0 +1,7 @@ +/** + * Lambda docs + * @param value - Value. + */ +export const voidLambda = (value: unknown): void => { + // ... +}; diff --git a/src/test/issues.c2.test.ts b/src/test/issues.c2.test.ts index 97162d2c8..8ec277621 100644 --- a/src/test/issues.c2.test.ts +++ b/src/test/issues.c2.test.ts @@ -1663,4 +1663,11 @@ describe("Issue Tests", () => { [[]], ); }); + + it("#2644 allows comments on signature parents to count for being documented", () => { + app.options.setValue("validation", { notDocumented: true }); + const project = convert(); + app.validate(project); + logger.expectNoOtherMessages(); + }); });