Skip to content

Commit 3b64ffd

Browse files
committed
Add documentation about the new supported HTML comments
1 parent bcd9936 commit 3b64ffd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,35 @@ It's also necessary to add a `type="text/language-name"` or `lang="language-name
4343
</style>
4444
```
4545

46+
## Documenting components
47+
48+
To add documentation on a Svelte component that will show up as a docstring in
49+
LSP-compatible editors, you can use an HTML comment with the `@component` tag:
50+
51+
```html
52+
<!--
53+
@component
54+
Here's some documentation for this component. It will show up on hover for
55+
JavaScript/TypeScript projects using a LSP-compatible editor such as VSCode or
56+
Vim/Neovim with coc.nvim.
57+
58+
- You can use markdown here.
59+
- You can use code blocks here.
60+
- JSDoc/TSDoc will be respected by LSP-compatible editors.
61+
- Indentation will be respected as much as possible.
62+
-->
63+
64+
<!-- @component You can use a single line, too -->
65+
66+
<!-- @component But only the last documentation comment will be used -->
67+
68+
<main>
69+
<h1>
70+
Hello world
71+
</h1>
72+
</main>
73+
```
74+
4675
## Troubleshooting / FAQ
4776

4877
### Using TypeScript? See [this section](./preprocessors/typescript.md#troubleshooting--faq)

0 commit comments

Comments
 (0)