Skip to content

Commit

Permalink
Merge pull request #13075 from storybookjs/13074-fix-docs-warnings
Browse files Browse the repository at this point in the history
Addon-docs: Fix spurious warnings
  • Loading branch information
shilman authored Nov 10, 2020
2 parents e90dd04 + 2c23019 commit 75f0fe9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
12 changes: 3 additions & 9 deletions addons/docs/src/blocks/Source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ const getStoryContext = (storyId: StoryId, docsContext: DocsContextProps): Story

const getStorySource = (storyId: StoryId, sourceContext: SourceContextProps): string => {
const { sources } = sourceContext;

const source = sources?.[storyId];

if (!source) {
logger.warn(`Unable to find source for story ID '${storyId}'`);
return '';
}

return source;
// source rendering is async so source is unavailable at the start of the render cycle,
// so we fail gracefully here without warning
return sources?.[storyId] || '';
};

const getSnippet = (snippet: string, storyContext?: StoryContext): string => {
Expand Down
41 changes: 22 additions & 19 deletions lib/client-api/src/story_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ const checkStorySort = (parameters: Parameters) => {
if (options?.storySort) logger.error('The storySort option parameter can only be set globally');
};

const storyFnWarning = deprecate(
() => {},
dedent`
\`storyFn\` is deprecated and will be removed in Storybook 7.0.
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-storyfn`
);

interface AllowUnsafeOption {
allowUnsafe?: boolean;
}
Expand Down Expand Up @@ -410,25 +418,20 @@ export default class StoryStore {

const storyParametersWithArgTypes = { ...storyParameters, argTypes, __isArgsStory };

const storyFn: LegacyStoryFn = deprecate(
(runtimeContext: StoryContext) =>
getDecorated()({
...identification,
...runtimeContext,
// Calculate "combined" parameters at render time (NOTE: for perf we could just use combinedParameters from above?)
parameters: this.combineStoryParameters(storyParametersWithArgTypes, kind),
hooks,
args: _stories[id].args,
argTypes,
globals: this._globals,
viewMode: this._selection?.viewMode,
}),
dedent`
\`storyFn\` is deprecated and will be removed in Storybook 7.0.
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-storyfn
`
);
const storyFn: LegacyStoryFn = (runtimeContext: StoryContext) => {
storyFnWarning();
return getDecorated()({
...identification,
...runtimeContext,
// Calculate "combined" parameters at render time (NOTE: for perf we could just use combinedParameters from above?)
parameters: this.combineStoryParameters(storyParametersWithArgTypes, kind),
hooks,
args: _stories[id].args,
argTypes,
globals: this._globals,
viewMode: this._selection?.viewMode,
});
};

const unboundStoryFn: LegacyStoryFn = (context: StoryContext) => getDecorated()(context);

Expand Down

0 comments on commit 75f0fe9

Please sign in to comment.