Skip to content

Commit

Permalink
Fix excludeNotDocumented on arrow functions
Browse files Browse the repository at this point in the history
Resolves #2162
  • Loading branch information
Gerrit0 committed Feb 11, 2023
1 parent f838e11 commit b77e421
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@
### Bug Fixes

- Entry points under `node_modules` will no longer be ignored, #2151.
- Corrected behavior of `excludeNotDocumented` on arrow function-variables, #2156.
- Added `package.json` to exports declaration.

### Thanks!
Expand Down
12 changes: 12 additions & 0 deletions src/lib/converter/plugins/CommentPlugin.ts
Expand Up @@ -464,6 +464,18 @@ export class CommentPlugin extends ConverterComponent {
}

if (!comment) {
// We haven't moved comments from the parent for signatures without a direct
// comment, so don't exclude those due to not being documented.
if (
reflection.kindOf(
ReflectionKind.CallSignature |
ReflectionKind.ConstructorSignature
) &&
reflection.parent?.comment
) {
return false;
}

if (this.excludeNotDocumented) {
// Don't let excludeNotDocumented remove parameters.
if (
Expand Down
6 changes: 6 additions & 0 deletions src/test/converter2/issues/gh2156.ts
@@ -0,0 +1,6 @@
/**
* Is documented
*/
export const foo = (foo: string): boolean => {
return true;
};
16 changes: 14 additions & 2 deletions src/test/issueTests.ts
Expand Up @@ -29,8 +29,8 @@ function query(project: ProjectReflection, name: string) {
}

export const issueTests: {
[issue: `pre${string}`]: (app: Application) => void;
[issue: `gh${string}`]: (
[issue: `pre${bigint}${string}`]: (app: Application) => void;
[issue: `gh${bigint}${string}`]: (
project: ProjectReflection,
logger: TestLogger
) => void;
Expand Down Expand Up @@ -836,4 +836,16 @@ export const issueTests: {
"One"
);
},

pre2156(app) {
app.options.setValue("excludeNotDocumented", true);
},
gh2156(project) {
const foo = query(project, "foo");
equal(foo.signatures?.length, 1);
equal(
Comment.combineDisplayParts(foo.signatures[0].comment?.summary),
"Is documented"
);
},
};

0 comments on commit b77e421

Please sign in to comment.