文档
类型
{
autodocs?: boolean | 'tag';
defaultName?: string;
docsMode?: boolean;
}
配置 Storybook 的自动生成的文档。
autodocs
类型:boolean | 'tag'
默认值:'tag'
启用或禁用 stories 的自动文档。
true
:为所有 stories 启用false
:为所有 stories 禁用'tag'
:为标记为'autodocs'
的 stories 启用
.storybook/main.ts
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
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-webpack5, vue3-vite)
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-webpack5, vue3-vite)
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;