Skip to content

Commit

Permalink
feat: Vue docgen options
Browse files Browse the repository at this point in the history
  • Loading branch information
OssamaSijbesma committed Sep 7, 2023
1 parent 3b7f12e commit c28e680
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions code/frameworks/vue-vite/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { StorybookConfig as StorybookConfigBase } from '@storybook/types';
import type { StorybookConfigVite, BuilderOptions } from '@storybook/builder-vite';
import type { DocGenOptions } from 'vue-docgen-api';

type FrameworkName = '@storybook/vue-vite';
type BuilderName = '@storybook/builder-vite';

export type FrameworkOptions = {
builder?: BuilderOptions;
docgenOptions?: DocGenOptions;
};

type StorybookConfigFramework = {
Expand Down
4 changes: 2 additions & 2 deletions code/frameworks/vue3-vite/src/plugins/vue-docgen.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { parse } from 'vue-docgen-api';
import { DocGenOptions, parse } from 'vue-docgen-api';
import type { PluginOption } from 'vite';
import { createFilter } from 'vite';
import MagicString from 'magic-string';

export function vueDocgen(options): PluginOption {
export function vueDocgen(options?: DocGenOptions): PluginOption {
const include = /\.(vue)$/;
const filter = createFilter(include);

Expand Down
4 changes: 3 additions & 1 deletion code/frameworks/vue3-vite/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export const viteFinal: StorybookConfig['viteFinal'] = async (config, { presets
plugins.push(vue());
}

const framework = await presets.apply<StorybookConfig['framework']>('framework');

// Add docgen plugin
plugins.push(vueDocgen());
plugins.push(vueDocgen(typeof framework === 'string' ? undefined : framework.options.docgenOptions));

return mergeConfig(config, {
plugins,
Expand Down
2 changes: 2 additions & 0 deletions code/frameworks/vue3-vite/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { StorybookConfig as StorybookConfigBase } from '@storybook/types';
import type { StorybookConfigVite, BuilderOptions } from '@storybook/builder-vite';
import type { DocGenOptions } from 'vue-docgen-api';

type FrameworkName = '@storybook/vue3-vite';
type BuilderName = '@storybook/builder-vite';

export type FrameworkOptions = {
builder?: BuilderOptions;
docgenOptions?: DocGenOptions;
};

type StorybookConfigFramework = {
Expand Down

0 comments on commit c28e680

Please sign in to comment.