# markdown-it-vue-docgen

> [![NPM version](https://img.shields.io/npm/v/markdown-it-vue-docgen?color=a1b858&label=)](https://www.npmjs.com/package/markdown-it-vue-docgen)

Latest version **0.1.1** (published 2023-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install markdown-it-vue-docgen
pnpm add markdown-it-vue-docgen
yarn add markdown-it-vue-docgen
bun add markdown-it-vue-docgen
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-05-29 |
| First published | 2023-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 16 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hairyf |
| Maintainers | tuimao |
| Keywords | markdown, vitepress, demo |

## Links

- npm: https://www.npmjs.com/package/markdown-it-vue-docgen
- Repository: https://github.com/hairyf/markdown-it-vue-docgens
- Homepage: https://github.com/hairyf/markdown-it-vue-docgens#readme
- Issues: https://github.com/hairyf/markdown-it-vue-docgens/issues
- npm.io page: https://npm.io/package/markdown-it-vue-docgen

## Dependencies (4)

- [synckit](https://npm.io/package/synckit.md) ^0.8.5
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.1
- [vue-docgen-api](https://npm.io/package/vue-docgen-api.md) ^4.72.3
- [@vue/compiler-core](https://npm.io/package/@vue/compiler-core.md) ^3.3.4

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2023-05-29
- 0.1.0 — 2023-05-29

## README

# markdown-it-vue-docgen

[![NPM version](https://img.shields.io/npm/v/markdown-it-vue-docgen?color=a1b858&label=)](https://www.npmjs.com/package/markdown-it-vue-docgen)

A markdown-it plugin implemented with [vue-docgen-api](https://www.npmjs.com/package/vue-docgen-api) for parsing documentation comments of Vue components. It is used with the `<vue-docgen />` tag.

## Install

```bash
npm install markdown-it-vue-docgen
```

## Usage

Write your Vue component and add relevant comments:

```html
<script lang="ts" setup>
import { defineExpose, ref } from 'vue'

withDefaults(
  defineProps<{
    title: string
    /**
   * This is an `optional` value
   */
    type?: 'text' | 'number' | 'digit' | 'password' | 'textarea'
  }>(),
  {
    type: 'text',
  },
)

const emit = defineEmits<{
  /**
   * This is a `click` event
   */
  (type: 'click', event: string | number): void
}>()

const value = ref('')

defineExpose({
  /**
   * This is the component property that I `expose`
   * @type {string|number}
   */
  a: value,
})
</script>

<template>
  <!-- @slot This is a default slot -->
  <slot />

  <!-- @slot This is a slot with a `name` -->
  <slot name="body" />
</template>
```

In your markdown file, use the `<vue-docgen>` tag and provide the src:

```html
<vue-docgen src="./Button.vue" />
```

The tag will parse and generate relevant markdown information:

![](./public/1.png)

You can provide a title attribute which will be added to the beginning of each line, which is useful for distinguishing multiple components:

```html
<vue-docgen title="Button" src="./Button.vue" />
```

The generated markdown will be:

```markdown
## Button Props
<!-- ... -->
## Button Events
<!-- ... -->
```

## Options

You can customize the component path being used by setting the plugin's options:

```js
import { resolve } from 'node:path'
import vueDocgen from 'markdown-it-vue-docgen'

md.use(vueDocgen, {
  dir: resolve(__dirname, '../../components/')
})
```

Then refer to the custom dir path using the `~` identifier:

```html
<vue-docgen src="~/Button.vue" />
```

You can also set the container for the popup that displays the prop type. For example, you can customize the container using `vue3-popup` loaded with `vitepress` (assuming you have registered the `popup` component globally):

```js
md.use(vueDocgen, {
  popup: (text, content) => `<popup content="${content}">${text}</popup>`
})
```

## License

[MIT](./LICENSE) License © 2022 [Hairyf](https://github.com/hairyf)

---
_Source: https://npm.io/package/markdown-it-vue-docgen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
