Docs
Storybook Docs

docs

父级:main.js|ts 配置

¥Parent: main.js|ts configuration

类型:

¥Type:

{
  autodocs?: boolean | 'tag';
  defaultName?: string;
  docsMode?: boolean;
}

配置 Storybook 的 自动生成的文档

¥Configures Storybook's auto-generated documentation.

autodocs

类型:boolean | 'tag'

¥Type: boolean | 'tag'

默认:'tag'

¥Default: 'tag'

为故事启用或禁用自动文档记录。

¥Enables or disables automatic documentation for stories.

  • true:为所有故事启用它

    ¥true: Enables it for all stories

  • false:为所有故事禁用它

    ¥false: Disables it for all stories

  • 'tag':为标有 'autodocs' 的故事启用它

    ¥'tag': Enables it for stories tagged with '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

¥Type: string

默认:'Docs'

¥Default: 'Docs'

用于生成的文档页面的名称。

¥Name used for generated documentation pages.

.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

¥Type: boolean

仅在侧边栏中显示文档页面(通常使用 --docs CLI 标志设置)。

¥Only show documentation pages in the sidebar (usually set with the --docs CLI flag).

.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;