-
-
Notifications
You must be signed in to change notification settings - Fork 471
Description
Hey, is it possible to add the missing feature to vue-component-meta
that also extracts the JSDoc / description of emits/events?
For props, exposes and slots this is already possible, however it does not work for emits/events.
Why?
I am currently working on this Storybook PR that switches to vue language tools (Volar) / vue-component-meta for generating the documentation for props, emits/events, slots and exposed. It works like a charm except the missing feature for emits/events descriptions which would be very nice to have!
Versions
node: 20.10.0
typescript: 5.3.3
vue-component-meta: 1.8.27
vue: 3.4.19
Reproduction
Vue component:
// TestComponent.vue
<script setup lang="ts">
const emit = defineEmits<{
/** Emitted when foo... */
foo: [value: string];
}>();
</script>
<template>Example component</template>
vue-component-meta
Code:
import path from "node:path";
import { fileURLToPath } from "node:url";
import type { MetaCheckerOptions } from "vue-component-meta";
import { createComponentMetaCheckerByJsonConfig } from "vue-component-meta";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const checkerOptions: MetaCheckerOptions = {
forceUseTs: true,
noDeclarations: true,
printer: { newLine: 1 },
};
const checker = createComponentMetaCheckerByJsonConfig(__dirname, {}, checkerOptions);
const componentPath = path.join(__dirname, "./TestComponent.vue");
const meta = checker.getComponentMeta(componentPath);
console.log(JSON.stringify(meta, null, 2));
Output
The logged output can be seen below. I only included the "events" property to keep it minimal.
I would expect the event to also have a description
property with the value "Emitted when foo..."
{
"events": [
{
"name": "foo",
"type": "[value: string]",
"signature": "(event: \"foo\", value: string): void",
"declarations": [],
"schema": ["string"]
}
]
}