Skip to content

Commit

Permalink
Fix discovery of module comments
Browse files Browse the repository at this point in the history
Resolves #1963
  • Loading branch information
Gerrit0 committed Jun 28, 2022
1 parent 6e5753e commit 238a8b6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
### Bug Fixes

- Module comments will no longer be inappropriately attached to signatures, #1962.
- Projects with a single entry point will now parse `@module` comments in the entry point, #1963.
- Removed duplicate "in comment" warning when parsing comments, #1964.

## v0.23.1 (2022-06-26)
Expand Down
11 changes: 10 additions & 1 deletion src/lib/converter/converter.ts
Expand Up @@ -13,7 +13,7 @@ import { createMinimatch, matchesAny } from "../utils/paths";
import type { IMinimatch } from "minimatch";
import { hasAllFlags, hasAnyFlag } from "../utils/enum";
import type { DocumentationEntryPoint } from "../utils/entry-point";
import type { CommentParserConfig } from "./comments";
import { CommentParserConfig, getComment } from "./comments";
import type { CommentStyle } from "../utils/options/declaration";

/**
Expand Down Expand Up @@ -238,6 +238,15 @@ export class Converter extends ChildableComponent<
// Special case for when we're giving a single entry point, we don't need to
// create modules for each entry. Register the project as this module.
context.project.registerReflection(context.project, symbol);
context.project.comment =
symbol &&
getComment(
symbol,
context.project.kind,
this.config,
this.application.logger,
this.commentStyle
);
context.trigger(
Converter.EVENT_CREATE_DECLARATION,
context.project
Expand Down
9 changes: 9 additions & 0 deletions src/test/converter2/issues/gh1963.ts
@@ -0,0 +1,9 @@
/**
* Module comment
* @module
*/

/**
* Some code reproducing a bug.
*/
export const bug = 123;
7 changes: 5 additions & 2 deletions src/test/issueTests.ts
Expand Up @@ -529,11 +529,14 @@ export const issueTests: {
gh1962(project) {
const foo = query(project, "foo");
ok(foo.signatures);
// #1963
// ok(project.hasComment(), "Missing module comment");
ok(project.hasComment(), "Missing module comment");
ok(
!foo.signatures[0].hasComment(),
"Module comment attached to signature"
);
},

gh1963(project) {
ok(project.hasComment(), "Missing module comment");
},
};

0 comments on commit 238a8b6

Please sign in to comment.