Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Fix heading levels of useOf API reference #26172

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions docs/api/doc-block-useof.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ import * as ButtonStories from './Button.stories';

## useOf

## Signature
### Type

<!-- prettier-ignore-start -->
```ts
useOf = (
(
moduleExportOrType: ModuleExport | 'story' | 'meta' | 'component',
validTypes?: Array<'story' | 'meta' | 'component'>
): EnhancedResolvedModuleExportType
) => EnhancedResolvedModuleExportType
```
<!-- prettier-ignore-end -->

## Parameters
### Parameters

### `moduleExportOrType`
#### `moduleExportOrType`

(**Required**)

Expand All @@ -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 }`

Expand Down
Loading