Storybook Vue 2.x renderer that enables Vue 2.x component story development and documentation (Note: @storybook/vue3 is separate)
—
Automatic documentation generation including component prop extraction, source code generation, and argument type inference for Vue components in Storybook.
Extracts argument types from Vue components using docgen information and component analysis.
/**
* Extract argument types from Vue components
* @param component - Vue component to analyze
* @returns Argument type definitions or null if no docgen info available
*/
function extractArgTypes(component: VueRenderer['component']): StrictArgTypes | null;
interface StrictArgTypes {
[key: string]: {
name: string;
description?: string;
type: {
required: boolean;
name: string;
value?: any;
summary?: string;
};
table?: {
type: any;
jsDocTags?: any;
defaultValue?: any;
category: string;
};
};
}Usage Example:
import { extractArgTypes } from "@storybook/vue";
import MyButton from "./MyButton.vue";
// Automatically extract arg types from component
const argTypes = extractArgTypes(MyButton);
console.log(argTypes);
// Manual usage in meta
const meta: Meta<typeof MyButton> = {
title: "Example/Button",
component: MyButton,
argTypes: extractArgTypes(MyButton),
};Generates source code snippets for stories in the Docs addon, showing the actual Vue template syntax.
/**
* Generate source code snippets for stories
* @param storyFn - Story function to analyze
* @param context - Story context for source generation
* @returns Vue component with source generation capabilities
*/
function sourceDecorator(storyFn: any, context: StoryContext): ComponentOptions<Vue>;Usage Example:
// Applied automatically in docs preview
export const decorators: DecoratorFunction<VueRenderer>[] = [sourceDecorator];
// Results in generated source like:
// <MyButton primary="true" label="Button" />Determines whether source code should be rendered based on story parameters and configuration.
/**
* Determine if source should be rendered
* @param context - Story context to check
* @returns Boolean indicating if source rendering should be skipped
*/
function skipSourceRender(context: StoryContext): boolean;Converts Vue VNode structures to string representations for source code display.
/**
* Convert Vue VNode to string representation
* @param vnode - Vue VNode to convert
* @returns String representation of the VNode structure
*/
function vnodeToString(vnode: Vue.VNode): string;
/**
* Argument type enhancers for improving type definitions
*/
const argTypesEnhancers: ArgTypesEnhancer<VueRenderer>[];
/**
* Documentation-specific parameters for stories
*/
const parameters: {
docs: {
story: { inline: boolean; iframeHeight: string };
extractArgTypes: typeof extractArgTypes;
extractComponentDescription: Function;
};
};Configure documentation behavior in your preview:
// .storybook/preview.js
import type { Preview } from "@storybook/vue";
const preview: Preview = {
parameters: {
docs: {
story: { inline: true, iframeHeight: '120px' },
extractArgTypes,
extractComponentDescription,
},
},
};
export default preview;The documentation system recognizes these Vue component sections:
const SECTIONS = ['props', 'events', 'slots', 'methods'];Props Section:
@values tagsEvents Section:
Slots Section:
Methods Section:
Automatically infers enum types from JSDoc comments:
<script>
export default {
props: {
/**
* Button size
* @values small, medium, large
*/
size: {
type: String,
default: 'medium'
}
}
}
</script>Results in:
{
size: {
control: { type: 'select' },
options: ['small', 'medium', 'large']
}
}Control source code generation with parameters:
export const MyStory: StoryObj = {
parameters: {
docs: {
source: {
type: 'dynamic', // 'auto' | 'dynamic' | 'code'
code: '<MyButton custom="code" />', // Custom source code
},
},
},
};Automatically extract component descriptions from:
<script>
/**
* A versatile button component that supports multiple variants,
* sizes, and interaction states for consistent UI design.
*/
export default {
name: 'MyButton',
// ...
}
</script>The system automatically detects args-based stories for optimal documentation:
// Automatically detected as args story
export const Primary: StoryObj = {
args: {
primary: true,
label: 'Button',
},
};Graceful error handling for documentation generation:
Debug Information:
// Enable debug logging for documentation issues
console.warn(`Failed to find story component: ${storyComponent}`);
console.warn(`Failed to generate dynamic source: ${error}`);Install with Tessl CLI
npx tessl i tessl/npm-storybook--vue