文档
类型
{
autodocs?: boolean | 'tag';
defaultName?: string;
docsMode?: boolean;
}
配置 Storybook 的自动生成文档。
autodocs
类型:boolean | 'tag'
默认值:'tag'
启用或禁用故事的自动文档生成。
true
:为所有故事启用false
:为所有故事禁用'tag'
:为带有'autodocs'
标签的故事启用
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { StorybookConfig } from '@storybook/your-framework';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
docs: {
autodocs: 'tag',
},
};
export default config;
defaultName
类型:string
默认值:'Docs'
用于生成文档页面的名称。
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { StorybookConfig } from '@storybook/your-framework';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
docs: {
defaultName: 'Documentation',
},
};
export default config;
docsMode
类型:boolean
仅在侧边栏中显示文档页面(通常使用 --docs
CLI 标志设置)。
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { StorybookConfig } from '@storybook/your-framework';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
docs: {
docsMode: true,
},
};
export default config;