Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mattjennings/mdsvex-sveld

Generate documentation for your Svelte components using sveld
https://github.com/mattjennings/mdsvex-sveld

Last synced: about 7 hours ago
JSON representation

Generate documentation for your Svelte components using sveld

Awesome Lists containing this project

README

        

# mdsvex-sveld

Generate documentation for your Svelte components using [sveld](https://github.com/IBM/sveld)

## Setup

```
npm install mdsvex-sveld
```

In your mdsvex config:

```js
import sveld from "mdsvex-sveld";

const config = {
remarkPlugins: [sveld],
...
};
```

## Usage

You can add generated tables that describe the components props, slots, events, etc. with the following syntax:

````md
```docs
./Button.svelte
```
````

Let's say this was Button.svelte:

```svelte

/**
* The button type
*
* @type {"button" | "submit" | "reset"} */
export let type = 'button'

/**
* Set to `true` to use the primary variant
*/
export let primary = false


Click me

```

This would be the generated markdown:

```md
### Props

| Prop | Type | Default | Description |
| :------ | :--------------------------------------------------- | --------------------- | ---------------------------------------- |
| type | "button" | "submit" | "reset" | 'button' | The button type |
| primary | boolean | false | Set to `true` to use the primary variant |

### Slots

| Name | Default | Props | Fallback |
| :--- | :------ | :---- | :-------------------- |
| | Yes | | Click me |
| icon | No | | |

### Events

| Name | Type | Detail |
| :---- | :-------- | :----- |
| click | forwarded | |
```

### Options

If you don't want all tables at once, you can specify a specific table:

````md
```docs:props
./Button.svelte
```
````

```md
| Prop | Type | Default | Description |
| :------ | :--------------------------------------------------- | --------------------- | ---------------------------------------- |
| type | "button" | "submit" | "reset" | 'button' | The button type |
| primary | boolean | false | Set to `true` to use the primary variant |
```