vue-docgen-api is a robust toolbox designed to programmatically extract detailed structural and behavioral information from Vue component files, whether they are Single File Components (SFCs), JavaScript, or TypeScript. It leverages `@babel/parser` to analyze component code, providing insights into props, events, slots, and methods, which is crucial for automated documentation generation. The current stable version is `4.79.2`, with a consistent release cadence of patch and minor updates, indicating active development and responsiveness to bug fixes and new Vue features (like `defineEmits` syntax in Vue 3.3). Its key differentiators include a highly configurable API with options for custom handlers to extend parsing logic, support for aliased paths, and the ability to handle both single and multiple component exports within a single file. This makes it an essential utility for projects building design systems, component libraries, or custom documentation platforms, often used as the core parser for tools like `vue-styleguidist`.
npm install vue-docgen-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `parseSource` to extract documentation information from a Vue 3 component defined as a string, including props, emits, and methods. It also shows how to configure `jsx` and `alias` options.
Replace `parse(filePath)` with `parseMulti(filePath)` and handle the returned array of ComponentDoc objects.
Carefully order your `alias` configurations, placing more specific aliases before general ones. Test your alias resolutions thoroughly to ensure they match expectations.
Upgrade to `vue-docgen-api@4.79.2` or higher to resolve issues with interface extension parsing.
Ensure `vue-docgen-api` is at version `4.72.4` or higher for full compatibility with Vue 3.3.2 and later.
Upgrade to `vue-docgen-api@4.75.0` or newer to ensure correct parsing of components utilizing Vue 3.3's `defineEmits` syntax.
Change your import and function call from `parse(filePath)` to `parseMulti(filePath)`. The `parseMulti` function returns an array of component documentation objects, one for each component found in the file.
Update `vue-docgen-api` to version `4.79.1` or higher. This specific issue was addressed in that patch version.
Pass a `DocGenOptions` object to `parse` or `parseMulti` with the `alias` property configured to mirror your project's alias settings. For example: `{ alias: { '@assets': path.resolve(__dirname, 'src/assets') } }`. Ensure the order of aliases is correct if you have overlapping patterns.