From 69443e931e581306eed011a49168cc413246f675 Mon Sep 17 00:00:00 2001 From: Kyle Gach Date: Tue, 27 Feb 2024 12:57:53 -0700 Subject: [PATCH] Merge pull request #26172 from storybookjs/api-ref-use-of-fix-headings Docs: Fix heading levels of `useOf` API reference (cherry picked from commit 85adf5a697313270ff5fb15166ac6c380baa773f) --- docs/api/doc-block-useof.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/api/doc-block-useof.md b/docs/api/doc-block-useof.md index 4499478aef5e..613ee99016cb 100644 --- a/docs/api/doc-block-useof.md +++ b/docs/api/doc-block-useof.md @@ -56,18 +56,20 @@ import * as ButtonStories from './Button.stories'; ## useOf -## Signature +### Type + ```ts -useOf = ( +( moduleExportOrType: ModuleExport | 'story' | 'meta' | 'component', validTypes?: Array<'story' | 'meta' | 'component'> -): EnhancedResolvedModuleExportType +) => EnhancedResolvedModuleExportType ``` + -## Parameters +### Parameters -### `moduleExportOrType` +#### `moduleExportOrType` (**Required**) @@ -81,29 +83,29 @@ When the custom block is in an [attached doc](./doc-block-meta.md#attached-vs-un - `useOf('meta')` returns the annotated meta in attached mode; error in unattached mode - `useOf('component')` returns the annotated component specified in the meta in attached mode; error in unattached mode -### `validTypes` +#### `validTypes` Type: `Array<'story' | 'meta' | 'component'>` Optionally specify an array of valid types that your block accepts. Passing anything other than the valid type(s) will result in an error. For example, the [`Canvas`](./doc-block-canvas.md) block uses `useOf(of, ['story'])`, which ensures it only accepts a reference to a story, not a meta or component. -## Return +### Return The return value depends on the matched type: -### `EnhancedResolvedModuleExportType['type'] === 'story'` +#### `EnhancedResolvedModuleExportType['type'] === 'story'` Type: `{ type: 'story', story: PreparedStory }` For stories, annotated stories are returned as is. They are prepared, meaning that they are already merged with project and meta annotations. -### `EnhancedResolvedModuleExportType['type'] === 'meta'` +#### `EnhancedResolvedModuleExportType['type'] === 'meta'` Type: `{ type: 'meta', csfFile: CSFFile, preparedMeta: PreparedMeta }` For meta, the parsed CSF file is returned, along with prepared annotated meta. That is, project annotations merged with meta annotations, but no story annotations. -### `EnhancedResolvedModuleExportType['type'] === 'component'` +#### `EnhancedResolvedModuleExportType['type'] === 'component'` Type: `{ type: 'component', component: Component, projectAnnotations: NormalizedProjectAnnotations }`