Skip to content

Commit

Permalink
Allow comments on signature parents to count for docs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gerrit0 committed Jul 21, 2024
1 parent 44a72e5 commit 14b87cf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/validation/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/converter2/issues/gh2644.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Lambda docs
* @param value - Value.
*/
export const voidLambda = (value: unknown): void => {
// ...
};
7 changes: 7 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

0 comments on commit 14b87cf

Please sign in to comment.