-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documenting components with a docstring that appears on hover documentation #280
Comments
Since this could also be valuable for components without a script tag, I propose using the HTML comment for that. Opinions? Other ideas? |
I would be really interested in having a go at implementing this. However I think it needs to be designed carefully because it's a feature some devs use very often every day. |
Something that comes to mind is: /**
* @file Here is my documentation for this component
*/ At the start of the file. But I think only HTML comments work there, right? |
Also, maybe to make it more similar to the other tags, I feel like a |
Perhaps even |
That will also needs some work in the compiler and the approval of the main repo. The options got verify by the compiler. |
I created an analogous issue on the main repo, let's see if we can reach some conclusion 👍 |
Half of it is done once #282 gets merged. The LSP wasn't showing documentation strings on hover. Now what I need to do is source a docstring from a |
@dummdidumm Currently it's not possible to add docstrings to the default exports, since they're not named: export default class {
$$prop_def = __sveltets_partial(render().props)
$$slot_def = render().slots
} I suppose, since the only things that can go on the root scope of each file are |
Yes that should be no problem. |
Does any of this code ever end up being part of the runtime of an application, or is it there just for the tooling support? |
Just for tooling. |
Right hmm. I don't understand how it works currently. If I try to emulate it in a TS-only environment like this: // Component.ts
export default class {} I don't get autocompletions for Anyway, if I do this instead: // Component.ts
export default class Component {} Then I do get autocompletions for the default export as |
Alright, so I've tried two options, but with our LSP, the only thing that works for autocompletion of component imports is: export default class {
// etc
} Things I've tried:
Update: declaring a class and then export it as default in a different line works as long as the name of the export is the same as the file name. I'm going for this option. |
Yeah the import completion for svelte components has some extra code there, essentially constructing the import suggestion. Maybe that code can be thrown away if svelte2tsx has a named default export which is the same as the file name. |
Fixed via #285 |
Problem
With React's tooling, you can comment on a component like this:
However, in Svelte, I haven't found a way to do this.
Solution
I would like to know where I can place a comment that will be taken up by the on-hover documentation of editors like VSCode and Vim/Neovim (with coc.nvim).
To illustrate, here I'm hovering
MyComponent
but I only seeimport MyComponent
:I would like my docstring
Documentation that will appear on hover in other places where this is imported
to be included in the tooltip.I've googled around for this for a while and tried my local setup with TypeScript and I can't find a way to do it. I found an interesting related discussion on metadata for Svelte components but the discussion is more about prop types.
Edit: since we're discussing whether this is better added to the compiler, I created an analogous issue here sveltejs/svelte#5102
The text was updated successfully, but these errors were encountered: