From 427ec4433d6d6cea778c4650237450b8ad7db719 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 21 Dec 2022 21:49:57 +1100 Subject: [PATCH] Rename docsPage to autodocs And change semantics: `docsPage:true` = `autodocs: 'tag'` and `docsPage: 'automatic'` = `autodocs: true`. --- MIGRATION.md | 16 +++---- code/addons/docs/src/preset.ts | 2 +- .../stories/docspage/autoplay.stories.ts | 2 +- .../stories/docspage/basic.stories.ts | 2 +- .../stories/docspage/description.stories.ts | 2 +- .../docspage/extract-description.stories.ts | 2 +- .../stories/docspage/iframe.stories.ts | 2 +- .../stories/docspage/overflow.stories.ts | 2 +- .../stories/docspage/override.stories.ts | 2 +- .../stories/docspage/source.stories.ts | 2 +- .../angular/template/cli/Button.stories.ts | 2 +- .../angular/template/cli/Header.stories.ts | 4 +- .../nextjs/template/cli/js/Button.stories.js | 2 +- .../nextjs/template/cli/js/Header.stories.js | 4 +- .../template/cli/ts-legacy/Button.stories.ts | 2 +- .../template/cli/ts-legacy/Header.stories.ts | 4 +- ...docsPage-automatic.ts => autodocs-true.ts} | 26 +++++------ code/lib/cli/src/automigrate/fixes/index.ts | 4 +- code/lib/cli/src/generators/baseGenerator.ts | 2 +- .../src/utils/StoryIndexGenerator.test.ts | 46 +++++++++---------- .../src/utils/StoryIndexGenerator.ts | 10 ++-- .../utils/__mockdata__/duplicate/A.stories.js | 2 +- .../__mockdata__/duplicate/SecondA.stories.js | 2 +- .../src/utils/__mockdata__/src/A.stories.js | 2 +- .../src/utils/__mockdata__/src/B.stories.ts | 2 +- .../src/utils/__mockdata__/src/D.stories.jsx | 2 +- .../src/utils/stories-json.test.ts | 18 ++++---- .../core-server/src/utils/summarizeIndex.ts | 6 +-- .../modules/client-api/StoryStoreFacade.ts | 8 ++-- .../src/modules/core-client/start.test.ts | 38 +++++++-------- .../template/stories/shortcuts.stories.ts | 2 +- code/lib/types/src/modules/core-common.ts | 7 +-- .../html/template/cli/js/Button.stories.js | 2 +- .../html/template/cli/js/Header.stories.js | 4 +- .../html/template/cli/ts/Button.stories.ts | 2 +- .../html/template/cli/ts/Header.stories.ts | 4 +- .../preact/template/cli/Button.stories.jsx | 2 +- .../preact/template/cli/Header.stories.jsx | 4 +- .../react/template/cli/js/Button.stories.js | 2 +- .../react/template/cli/js/Header.stories.js | 4 +- .../react/template/cli/ts/Button.stories.ts | 2 +- .../react/template/cli/ts/Header.stories.ts | 4 +- .../svelte/template/cli/js/Button.stories.js | 2 +- .../svelte/template/cli/js/Header.stories.js | 4 +- .../template/cli/ts-legacy/Button.stories.ts | 2 +- .../template/cli/ts-legacy/Header.stories.ts | 4 +- .../svelte/template/cli/ts/Button.stories.ts | 2 +- .../svelte/template/cli/ts/Header.stories.ts | 4 +- .../vue/template/cli/Button.stories.js | 2 +- .../vue/template/cli/Header.stories.js | 4 +- .../vue3/template/cli/Button.stories.js | 2 +- .../vue3/template/cli/Header.stories.js | 4 +- .../template/cli/js/Button.stories.js | 2 +- .../template/cli/js/Header.stories.js | 4 +- .../template/cli/ts/Button.stories.ts | 2 +- .../template/cli/ts/Header.stories.ts | 4 +- .../blocks/src/controls/Boolean.stories.tsx | 2 +- code/ui/blocks/src/controls/Color.stories.tsx | 2 +- code/ui/blocks/src/controls/Date.stories.tsx | 2 +- code/ui/blocks/src/controls/Files.stories.tsx | 2 +- .../ui/blocks/src/controls/Number.stories.tsx | 2 +- .../ui/blocks/src/controls/Object.stories.tsx | 2 +- code/ui/blocks/src/controls/Range.stories.tsx | 2 +- code/ui/blocks/src/controls/Text.stories.tsx | 2 +- .../controls/options/CheckOptions.stories.tsx | 2 +- .../controls/options/RadioOptions.stories.tsx | 2 +- .../options/SelectOptions.stories.tsx | 2 +- .../angular/button-story-auto-docs.ts.mdx | 2 +- .../storybook-auto-docs-full-config.js.mdx | 4 +- .../storybook-auto-docs-full-config.ts.mdx | 4 +- ...torybook-main-config-remark-options.js.mdx | 2 +- ...torybook-main-config-remark-options.ts.mdx | 2 +- .../react/button-story-auto-docs.js.mdx | 2 +- .../react/button-story-auto-docs.ts.mdx | 2 +- .../svelte/button-story-auto-docs.js.mdx | 2 +- .../vue/button-story-auto-docs.js.mdx | 2 +- .../vue/button-story-auto-docs.ts.mdx | 2 +- docs/writing-docs/docs-page.md | 4 +- 78 files changed, 176 insertions(+), 175 deletions(-) rename code/lib/cli/src/automigrate/fixes/{docsPage-automatic.ts => autodocs-true.ts} (58%) diff --git a/MIGRATION.md b/MIGRATION.md index 2cca9327d9d9..d922d696fabd 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -40,7 +40,7 @@ - [Docs Changes](#docs-changes) - [Standalone docs files](#standalone-docs-files) - [Referencing stories in docs files](#referencing-stories-in-docs-files) - - [Docs Page](#docs-page) + - [Autodocs](#autodocs) - [Configuring the Docs Container](#configuring-the-docs-container) - [External Docs](#external-docs) - [MDX2 upgrade](#mdx2-upgrade) @@ -754,32 +754,32 @@ import * as SecondComponentStories from './second-component.stories'; ``` -#### Docs Page +#### Autodocs -In 7.0, rather than rendering each story in "docs view mode", Docs Page operates by adding additional sidebar entries for each component. By default it uses the same template as was used in 6.x, and the entries are entitled `Docs`. +In 7.0, rather than rendering each story in "docs view mode", Autodocs (ex. "Docs Page") operates by adding additional sidebar entries for each component. By default it uses the same template as was used in 6.x, and the entries are entitled `Docs`. -You can configure Docs Page in `main.js`: +You can configure Autodocs in `main.js`: ```js module.exports = { docs: { - docsPage: 'automatic', // see below for alternatives + autodocs: true, // see below for alternatives defaultName: 'Docs', // set to change the name of generated docs entries }, }; ``` -If you are migrating from 6.x your `docs.docsPage` option will have been set to `'automatic'`, which has the effect of enabling docs page for _every_ CSF file. However, as of 7.0, the new default is `true`, which requires opting into DocsPage per-CSF file, with the `docsPage` **tag** on your component export: +If you are migrating from 6.x your `docs.autodocs` option will have been set to `true`, which has the effect of enabling docs page for _every_ CSF file. However, as of 7.0, the new default is `'tag'`, which requires opting into Autodocs per-CSF file, with the `autodocs` **tag** on your component export: ```ts export default { component: MyComponent // Tags are a new feature coming in 7.1, that we are using to drive this behaviour. - tags: ['docsPage'] + tags: ['autodocs'] } ``` -You can also set `docsPage: false` to opt-out of docs page entirely. +You can also set `autodocs: false` to opt-out of Autodocs entirely. You can change the default template in the same way as in 6.x, using the `docs.page` parameter. diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 67ba5aeaeb3d..9438433d3fa0 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -152,7 +152,7 @@ const docs = (docsOptions: DocsOptions) => { ...docsOptions, disable: true, defaultName: 'Docs', - docsPage: true, + autodocs: 'tag', }; }; diff --git a/code/addons/docs/template/stories/docspage/autoplay.stories.ts b/code/addons/docs/template/stories/docspage/autoplay.stories.ts index 50b01ae74504..7f32348bc00c 100644 --- a/code/addons/docs/template/stories/docspage/autoplay.stories.ts +++ b/code/addons/docs/template/stories/docspage/autoplay.stories.ts @@ -4,7 +4,7 @@ import { within } from '@storybook/testing-library'; export default { component: globalThis.Components.Pre, - tags: ['docsPage'], + tags: ['autodocs'], args: { text: 'Play has not run' }, parameters: { chromatic: { disable: true } }, }; diff --git a/code/addons/docs/template/stories/docspage/basic.stories.ts b/code/addons/docs/template/stories/docspage/basic.stories.ts index cf8768751607..72d1059758d7 100644 --- a/code/addons/docs/template/stories/docspage/basic.stories.ts +++ b/code/addons/docs/template/stories/docspage/basic.stories.ts @@ -2,7 +2,7 @@ import { global as globalThis } from '@storybook/global'; export default { component: globalThis.Components.Button, - tags: ['docsPage'], + tags: ['autodocs'], args: { label: 'Click Me!' }, parameters: { chromatic: { disable: true } }, }; diff --git a/code/addons/docs/template/stories/docspage/description.stories.ts b/code/addons/docs/template/stories/docspage/description.stories.ts index 98ed1de51473..f42edc5901c3 100644 --- a/code/addons/docs/template/stories/docspage/description.stories.ts +++ b/code/addons/docs/template/stories/docspage/description.stories.ts @@ -6,7 +6,7 @@ export default { subcomponents: { Pre: globalThis.Components.Pre, }, - tags: ['docsPage'], + tags: ['autodocs'], args: { label: 'Click Me!' }, parameters: { docs: { diff --git a/code/addons/docs/template/stories/docspage/extract-description.stories.ts b/code/addons/docs/template/stories/docspage/extract-description.stories.ts index bc9033127f68..cb5986ac7dbe 100644 --- a/code/addons/docs/template/stories/docspage/extract-description.stories.ts +++ b/code/addons/docs/template/stories/docspage/extract-description.stories.ts @@ -2,7 +2,7 @@ import { global as globalThis } from '@storybook/global'; export default { component: globalThis.Components.Button, - tags: ['docsPage'], + tags: ['autodocs'], args: { label: 'Click Me!' }, parameters: { docs: { diff --git a/code/addons/docs/template/stories/docspage/iframe.stories.ts b/code/addons/docs/template/stories/docspage/iframe.stories.ts index 8a087afca04a..80cff47272c8 100644 --- a/code/addons/docs/template/stories/docspage/iframe.stories.ts +++ b/code/addons/docs/template/stories/docspage/iframe.stories.ts @@ -2,7 +2,7 @@ import { global as globalThis } from '@storybook/global'; export default { component: globalThis.Components.Button, - tags: ['docsPage'], + tags: ['autodocs'], args: { label: 'Rendered in iframe' }, parameters: { chromatic: { disable: true }, diff --git a/code/addons/docs/template/stories/docspage/overflow.stories.ts b/code/addons/docs/template/stories/docspage/overflow.stories.ts index 9c3c7f7b70d9..71893031af5b 100644 --- a/code/addons/docs/template/stories/docspage/overflow.stories.ts +++ b/code/addons/docs/template/stories/docspage/overflow.stories.ts @@ -2,7 +2,7 @@ import { global as globalThis } from '@storybook/global'; export default { component: globalThis.Components.Pre, - tags: ['docsPage'], + tags: ['autodocs'], args: { text: 'Demonstrates overflow', style: { width: 2000, height: 500, background: 'hotpink' }, diff --git a/code/addons/docs/template/stories/docspage/override.stories.ts b/code/addons/docs/template/stories/docspage/override.stories.ts index 0f46a108c325..18d2d4e5e25c 100644 --- a/code/addons/docs/template/stories/docspage/override.stories.ts +++ b/code/addons/docs/template/stories/docspage/override.stories.ts @@ -15,7 +15,7 @@ const Override = () => 'overridden'; export default { component: globalThis.Components.Button, - tags: ['docsPage'], + tags: ['autodocs'], args: { label: 'Click Me!' }, parameters: { chromatic: { disable: true }, diff --git a/code/addons/docs/template/stories/docspage/source.stories.ts b/code/addons/docs/template/stories/docspage/source.stories.ts index 84d12fe56f1c..9d30522758d2 100644 --- a/code/addons/docs/template/stories/docspage/source.stories.ts +++ b/code/addons/docs/template/stories/docspage/source.stories.ts @@ -2,7 +2,7 @@ import { global as globalThis } from '@storybook/global'; export default { component: globalThis.Components.Button, - tags: ['docsPage'], + tags: ['autodocs'], args: { label: 'Click Me!' }, parameters: { chromatic: { disable: true } }, }; diff --git a/code/frameworks/angular/template/cli/Button.stories.ts b/code/frameworks/angular/template/cli/Button.stories.ts index 6bcd3ee47389..85ce82c88270 100644 --- a/code/frameworks/angular/template/cli/Button.stories.ts +++ b/code/frameworks/angular/template/cli/Button.stories.ts @@ -5,7 +5,7 @@ import Button from './button.component'; const meta: Meta