I’m working on a Svelte project in VSCode, and I’d like to provide some additional documentation for my Svelte components. Specifically, I want to add some simple lines of text that appear in a popup when the user hovers over the component.
Currently, when I hover over a Svelte component in VSCode, I see the following default text:
(alias) class MyComponent
import MyComponent
However, I want to add some custom text that explains how to use the component properly. (For example, for some components to work correctly, I need to tell the user to apply a tailwind class peer
to the previous element.)
Is there a way to add this type of documentation to Svelte components in VSCode? Ideally, I’d like to be able to specify the documentation text in a comment within the component file itself.
It would also be great if the documentation text could support markdown formatting, including headers (#, ##, ###), links, —- dividers, – lists and so on.
Any help would be greatly appreciated! Thank you!
2
Answers
I was searching for the same issue as in this question.
This question has useful answers: Is there a standard way to document Svelte components?
To summarize from that question:
This question should probably be marked as a duplicate.
yes, you can using vscode:
basically you need to create a html
<!-- -->
comment at the start of your*.svelte
file which includes at the beggining@component
Example:
example using your example issue:
as you see you can use also Markdown inside the comment.
how it looks?
on hover of the
import
:on hover of the component itself: