fix: don't attach @module JSDoc to the first symbol#795
Open
fibibot wants to merge 2 commits into
Open
Conversation
`js_doc_for_range_include_ignore` walks leading comments back from a symbol's range to find its JSDoc block. When a file's `@module` documentation comment was the only leading block before an undocumented exported symbol, that comment was returned as the symbol's JSDoc — so the same paragraph showed up twice in `deno doc` output and on unrelated symbols. Skip JSDoc blocks tagged `@module` when resolving per-symbol docs. Such blocks are file-level by intent and have already been collected by `module_js_doc_for_source`. Fixes denoland/deno#30783.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reported as denoland/deno#30783. `js_doc_for_range_include_ignore` walks leading comments back from a symbol's range to find its JSDoc block. When a file's `@module` documentation comment was the only leading block before an undocumented exported symbol, that comment was returned as the symbol's JSDoc — so the same paragraph appeared twice in `deno doc` output and on an unrelated symbol:
```js
/**
*/
export function foo() {}
/** This is the bar function. */
export function bar() {}
```
```
$ deno doc bug.js
The module docs.
@module
Defined in file:///bug.js:9:1
function bar(): void
This is the bar function.
Defined in file:///bug.js:6:1
function foo(): void
The module docs. <-- duplicated module-level doc
@module
```
Skip JSDoc blocks tagged `@module` when resolving per-symbol docs. They're file-level by intent and have already been collected by `module_js_doc_for_source`.
Test plan