Skip to content

Conversation

@ouvreboite
Copy link

@ouvreboite ouvreboite commented Nov 2, 2025

Currently, custom elements added to SvelteHTMLElements supports autocompletion, but no description is displayed (from the JSDoc), while their attributes support both autocompletion and JSDoc description.

This PR's goal is to enable JSDoc documentation during autocompletion and hover for custom element's tags.

For example, this declaration would yield this autocomplete:

declare module 'svelte/elements' {
  export interface SvelteHTMLElements {
    /** 
     * Custom doc for custom element 
     * 
     * ### Details
     * Some interesting stuff about this component (in markdown)
    */
    'custom-element': any;
  }
}

@changeset-bot
Copy link

changeset-bot bot commented Nov 2, 2025

⚠️ No Changeset found

Latest commit: 6a70aca

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ouvreboite ouvreboite changed the title ✨ Use custom element's JSDoc as doc for completion ✨ Use custom element's JSDoc as doc for completion/hover Nov 2, 2025
sourceFile
let tags = getCustomElementsSymbols(lang, lsContainer, tsDoc).filter((t) =>
t.name.startsWith(tag.tag!)
);
Copy link
Author

@ouvreboite ouvreboite Nov 2, 2025

Choose a reason for hiding this comment

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

Before, only the CompletionProvider was checking the custom elements, and not the HoverProvider. So I moved the logic that extracts the custom "types" to utils.ts to share across both

@jasonlyu123
Copy link
Member

jasonlyu123 commented Nov 6, 2025

I think it would be better to resolve the documentation in resolveCompletion. Could you check if it's possible? This way, it'll only calculate the documentation when it's needed. In hover, the reused method also only needs to calculate the documentation needed instead of all the customer elements.

@ouvreboite
Copy link
Author

I'm away from home the next few days, but I'll look into that shortly.

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.

2 participants