Skip to content

html-language-features: include JSDoc summary and tags in <script> hover#312585

Merged
aeschli merged 4 commits into
microsoft:mainfrom
mohanrajvenkatesan23-04:fix/issue-268776-html-script-js-hover
Jun 1, 2026
Merged

html-language-features: include JSDoc summary and tags in <script> hover#312585
aeschli merged 4 commits into
microsoft:mainfrom
mohanrajvenkatesan23-04:fix/issue-268776-html-script-js-hover

Conversation

@mohanrajvenkatesan23-04

Copy link
Copy Markdown

Fixes #268776

Summary

Hovering over a JavaScript class or method declared inside a <script> block in an HTML file currently only shows the symbol's signature, not its JSDoc description or @param/@returns tags. The same symbol declared in a .js/.ts file shows the full description. This PR brings the HTML embedded-JS hover to parity with the standalone JS/TS hover.

Changes

  • extensions/html-language-features/server/src/modes/javascriptMode.ts — In doHover, in addition to the existing info.displayParts signature, surface info.documentation (the JSDoc summary) and info.tags (@param, @returns, etc.). The hover now returns a MarkupContent markdown payload with three sections (signature, description, tags) joined by blank lines. Two small helpers tagToMarkdown / tagsToMarkdown are added, modeled after the equivalent helpers in extensions/typescript-language-features/src/languageFeatures/util/textRendering.ts.
  • extensions/html-language-features/server/src/test/hover.test.ts — New regression test file with two cases: hover on a JSDoc'd class declared inside <script>, and hover on a JSDoc'd method. Both assert the description text is included in the hover. Confirmed the new tests fail without the fix and pass with it.

How to test

  1. Open an HTML file containing a <script> block, e.g.:
    <script>
      /**
       * Greets a user by name.
       * @param name The user's name.
       * @returns A greeting string.
       */
      class Greeter {
        greet(name) { return 'Hello, ' + name; }
      }
    </script>
  2. Hover over Greeter (or greet).
  3. Before this change: the hover only shows the signature (e.g. class Greeter).
  4. After this change: the hover shows the signature, the JSDoc description ("Greets a user by name."), and the @param / @returns tag information.
  5. Run the html-language-features server tests; the two new cases in hover.test.ts should pass.

In doHover for JavaScript embedded in HTML <script> blocks, surface
info.documentation (JSDoc summary) and info.tags (@param, @returns,
etc.) alongside the existing info.displayParts signature. The hover
now returns a MarkupContent markdown payload with the signature,
description, and tag sections so HTML files get parity with
.js/.ts hovers.

Fixes microsoft#268776
Copilot AI review requested due to automatic review settings June 1, 2026 15:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the HTML language server’s embedded-JavaScript hover behavior so that hover tooltips inside <script> blocks include JSDoc documentation (summary + tags) instead of showing only the symbol signature, bringing it closer to the JS/TS hover experience.

Changes:

  • Enhance javascriptMode.doHover to include info.documentation and info.tags, returning a markdown hover payload with signature + docs + tags.
  • Add regression tests that assert JSDoc summaries appear in hover results for a class and a method declared inside <script> in an HTML document.
Show a summary per file
File Description
extensions/html-language-features/server/src/modes/javascriptMode.ts Builds a markdown hover value combining signature, JSDoc summary, and formatted JSDoc tags for embedded JS/TS.
extensions/html-language-features/server/src/test/hover.test.ts Adds coverage ensuring embedded <script> hover includes JSDoc summary text for class and method symbols.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread extensions/html-language-features/server/src/modes/javascriptMode.ts Outdated
aeschli and others added 2 commits June 1, 2026 17:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@aeschli aeschli enabled auto-merge (squash) June 1, 2026 15:29
@aeschli

aeschli commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Thanks a lot!

@aeschli aeschli merged commit c2f5cea into microsoft:main Jun 1, 2026
23 of 25 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: No description for JS classes/methods in script tag for html file

4 participants