mirror of https://github.com/sveltejs/svelte
commit
24187fe97f
@ -0,0 +1,32 @@
|
||||
---
|
||||
question: How do I document my components?
|
||||
---
|
||||
|
||||
In editors which use the Svelte Language Server you can document Components, functions and exports using specially formatted comments.
|
||||
|
||||
````svelte
|
||||
<script>
|
||||
/** What should we call the user? */
|
||||
export let name = 'world';
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@component
|
||||
Here's some documentation for this component.
|
||||
It will show up on hover.
|
||||
|
||||
- You can use markdown here.
|
||||
- You can also use code blocks here.
|
||||
- Usage:
|
||||
```tsx
|
||||
<main name="Arethra">
|
||||
```
|
||||
-->
|
||||
<main>
|
||||
<h1>
|
||||
Hello, {name}
|
||||
</h1>
|
||||
</main>
|
||||
````
|
||||
|
||||
Note: The `@component` is necessary in the HTML comment which describes your component.
|
@ -0,0 +1 @@
|
||||
<slot props={$$props}/>
|
@ -0,0 +1,21 @@
|
||||
export default {
|
||||
html: `
|
||||
<h1>hi</h1>
|
||||
<button>Change</button>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const btn = target.querySelector("button");
|
||||
const clickEvent = new window.MouseEvent("click");
|
||||
|
||||
await btn.dispatchEvent(clickEvent);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<h1>changed</h1>
|
||||
<button>Change</button>
|
||||
`
|
||||
);
|
||||
},
|
||||
};
|
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import Comp from './Comp.svelte'
|
||||
let p = "hi"
|
||||
</script>
|
||||
|
||||
<Comp someprop={p} let:props>
|
||||
<h1>
|
||||
{props.someprop}
|
||||
</h1>
|
||||
</Comp>
|
||||
|
||||
<button on:click={()=> p = "changed"}>Change
|
||||
</button>
|
Loading…
Reference in new issue