文档
父级: main.js|ts 配置
类型
{
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-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;