mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-16 05:03:11 +08:00
Match .mdx
not .docs.mdx
for docs2
This commit is contained in:
parent
2153fca2a9
commit
fbef33d00a
@ -181,7 +181,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -193,7 +193,7 @@ describe('StoryIndexGenerator', () => {
|
||||
"entries": Object {
|
||||
"a--docs": Object {
|
||||
"id": "a--docs",
|
||||
"importPath": "./src/docs2/MetaOf.docs.mdx",
|
||||
"importPath": "./src/docs2/MetaOf.mdx",
|
||||
"name": "docs",
|
||||
"storiesImports": Array [
|
||||
"./src/A.stories.js",
|
||||
@ -210,7 +210,7 @@ describe('StoryIndexGenerator', () => {
|
||||
},
|
||||
"docs2-notitle--docs": Object {
|
||||
"id": "docs2-notitle--docs",
|
||||
"importPath": "./src/docs2/NoTitle.docs.mdx",
|
||||
"importPath": "./src/docs2/NoTitle.mdx",
|
||||
"name": "docs",
|
||||
"storiesImports": Array [],
|
||||
"title": "docs2/NoTitle",
|
||||
@ -218,7 +218,7 @@ describe('StoryIndexGenerator', () => {
|
||||
},
|
||||
"docs2-yabbadabbadooo--docs": Object {
|
||||
"id": "docs2-yabbadabbadooo--docs",
|
||||
"importPath": "./src/docs2/Title.docs.mdx",
|
||||
"importPath": "./src/docs2/Title.mdx",
|
||||
"name": "docs",
|
||||
"storiesImports": Array [],
|
||||
"title": "docs2/Yabbadabbadooo",
|
||||
@ -232,13 +232,13 @@ describe('StoryIndexGenerator', () => {
|
||||
|
||||
it('errors when docs dependencies are missing', async () => {
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/MetaOf.docs.mdx',
|
||||
'./src/**/MetaOf.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
const generator = new StoryIndexGenerator([docsSpecifier], options);
|
||||
await expect(() => generator.initialize()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Could not find \\"../A.stories\\" for docs file \\"src/docs2/MetaOf.docs.mdx\\"."`
|
||||
`"Could not find \\"../A.stories\\" for docs file \\"src/docs2/MetaOf.mdx\\"."`
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -251,7 +251,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -303,7 +303,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -362,7 +362,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -371,7 +371,7 @@ describe('StoryIndexGenerator', () => {
|
||||
await generator.getIndex();
|
||||
expect(toId).toHaveBeenCalledTimes(4);
|
||||
|
||||
generator.invalidate(docsSpecifier, './src/docs2/Title.docs.mdx', false);
|
||||
generator.invalidate(docsSpecifier, './src/docs2/Title.mdx', false);
|
||||
|
||||
toIdMock.mockClear();
|
||||
await generator.getIndex();
|
||||
@ -384,7 +384,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -484,7 +484,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -495,7 +495,7 @@ describe('StoryIndexGenerator', () => {
|
||||
|
||||
expect(Object.keys((await generator.getIndex()).entries)).toContain('docs2-notitle--docs');
|
||||
|
||||
generator.invalidate(docsSpecifier, './src/docs2/NoTitle.docs.mdx', true);
|
||||
generator.invalidate(docsSpecifier, './src/docs2/NoTitle.mdx', true);
|
||||
|
||||
expect(Object.keys((await generator.getIndex()).entries)).not.toContain(
|
||||
'docs2-notitle--docs'
|
||||
@ -508,7 +508,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -522,7 +522,7 @@ describe('StoryIndexGenerator', () => {
|
||||
generator.invalidate(storiesSpecifier, './src/A.stories.js', true);
|
||||
|
||||
await expect(() => generator.getIndex()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Could not find \\"../A.stories\\" for docs file \\"src/docs2/MetaOf.docs.mdx\\"."`
|
||||
`"Could not find \\"../A.stories\\" for docs file \\"src/docs2/MetaOf.mdx\\"."`
|
||||
);
|
||||
});
|
||||
|
||||
@ -532,7 +532,7 @@ describe('StoryIndexGenerator', () => {
|
||||
options
|
||||
);
|
||||
const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.docs.mdx',
|
||||
'./src/**/*.mdx',
|
||||
options
|
||||
);
|
||||
|
||||
@ -543,7 +543,7 @@ describe('StoryIndexGenerator', () => {
|
||||
|
||||
expect(Object.keys((await generator.getIndex()).entries)).toContain('a--docs');
|
||||
|
||||
generator.invalidate(docsSpecifier, './src/docs2/MetaOf.docs.mdx', true);
|
||||
generator.invalidate(docsSpecifier, './src/docs2/MetaOf.mdx', true);
|
||||
|
||||
expect(Object.keys((await generator.getIndex()).entries)).not.toContain('a--docs');
|
||||
|
||||
|
@ -109,7 +109,7 @@ export class StoryIndexGenerator {
|
||||
}
|
||||
|
||||
isDocsMdx(absolutePath: Path) {
|
||||
return /\.docs\.mdx$/i.test(absolutePath);
|
||||
return /(?<!\.stories)\.mdx$/i.test(absolutePath);
|
||||
}
|
||||
|
||||
async ensureExtracted(): Promise<IndexEntry[]> {
|
||||
|
@ -1 +0,0 @@
|
||||
<h1>Some MDX</h1>
|
@ -37,9 +37,9 @@ const normalizedStories = [
|
||||
{
|
||||
titlePrefix: '',
|
||||
directory: './src',
|
||||
files: '**/*.docs.mdx',
|
||||
files: '**/*.mdx',
|
||||
importPathMatcher:
|
||||
/^\.[\\/](?:src(?:\/(?!\.)(?:(?:(?!(?:^|\/)\.).)*?)\/|\/|$)(?!\.)(?=.)[^/]*?\.docs.mdx)$/,
|
||||
/^\.[\\/](?:src(?:\/(?!\.)(?:(?:(?!(?:^|\/)\.).)*?)\/|\/|$)(?!\.)(?=.)[^/]*?\.mdx)$/,
|
||||
},
|
||||
];
|
||||
|
||||
@ -115,7 +115,7 @@ describe('useStoriesJson', () => {
|
||||
"entries": Object {
|
||||
"a--docs": Object {
|
||||
"id": "a--docs",
|
||||
"importPath": "./src/docs2/MetaOf.docs.mdx",
|
||||
"importPath": "./src/docs2/MetaOf.mdx",
|
||||
"name": "docs",
|
||||
"storiesImports": Array [
|
||||
"./src/A.stories.js",
|
||||
@ -146,7 +146,7 @@ describe('useStoriesJson', () => {
|
||||
},
|
||||
"docs2-notitle--docs": Object {
|
||||
"id": "docs2-notitle--docs",
|
||||
"importPath": "./src/docs2/NoTitle.docs.mdx",
|
||||
"importPath": "./src/docs2/NoTitle.mdx",
|
||||
"name": "docs",
|
||||
"storiesImports": Array [],
|
||||
"title": "docs2/NoTitle",
|
||||
@ -154,7 +154,7 @@ describe('useStoriesJson', () => {
|
||||
},
|
||||
"docs2-yabbadabbadooo--docs": Object {
|
||||
"id": "docs2-yabbadabbadooo--docs",
|
||||
"importPath": "./src/docs2/Title.docs.mdx",
|
||||
"importPath": "./src/docs2/Title.mdx",
|
||||
"name": "docs",
|
||||
"storiesImports": Array [],
|
||||
"title": "docs2/Yabbadabbadooo",
|
||||
@ -208,13 +208,13 @@ describe('useStoriesJson', () => {
|
||||
"stories": Object {
|
||||
"a--docs": Object {
|
||||
"id": "a--docs",
|
||||
"importPath": "./src/docs2/MetaOf.docs.mdx",
|
||||
"importPath": "./src/docs2/MetaOf.mdx",
|
||||
"kind": "A",
|
||||
"name": "docs",
|
||||
"parameters": Object {
|
||||
"__id": "a--docs",
|
||||
"docsOnly": true,
|
||||
"fileName": "./src/docs2/MetaOf.docs.mdx",
|
||||
"fileName": "./src/docs2/MetaOf.mdx",
|
||||
},
|
||||
"storiesImports": Array [
|
||||
"./src/A.stories.js",
|
||||
@ -263,13 +263,13 @@ describe('useStoriesJson', () => {
|
||||
},
|
||||
"docs2-notitle--docs": Object {
|
||||
"id": "docs2-notitle--docs",
|
||||
"importPath": "./src/docs2/NoTitle.docs.mdx",
|
||||
"importPath": "./src/docs2/NoTitle.mdx",
|
||||
"kind": "docs2/NoTitle",
|
||||
"name": "docs",
|
||||
"parameters": Object {
|
||||
"__id": "docs2-notitle--docs",
|
||||
"docsOnly": true,
|
||||
"fileName": "./src/docs2/NoTitle.docs.mdx",
|
||||
"fileName": "./src/docs2/NoTitle.mdx",
|
||||
},
|
||||
"storiesImports": Array [],
|
||||
"story": "docs",
|
||||
@ -277,13 +277,13 @@ describe('useStoriesJson', () => {
|
||||
},
|
||||
"docs2-yabbadabbadooo--docs": Object {
|
||||
"id": "docs2-yabbadabbadooo--docs",
|
||||
"importPath": "./src/docs2/Title.docs.mdx",
|
||||
"importPath": "./src/docs2/Title.mdx",
|
||||
"kind": "docs2/Yabbadabbadooo",
|
||||
"name": "docs",
|
||||
"parameters": Object {
|
||||
"__id": "docs2-yabbadabbadooo--docs",
|
||||
"docsOnly": true,
|
||||
"fileName": "./src/docs2/Title.docs.mdx",
|
||||
"fileName": "./src/docs2/Title.mdx",
|
||||
},
|
||||
"storiesImports": Array [],
|
||||
"story": "docs",
|
||||
@ -712,7 +712,7 @@ describe('convertToIndexV3', () => {
|
||||
entries: {
|
||||
'a--docs': {
|
||||
id: 'a--docs',
|
||||
importPath: './src/docs2/MetaOf.docs.mdx',
|
||||
importPath: './src/docs2/MetaOf.mdx',
|
||||
name: 'docs',
|
||||
storiesImports: ['./src/A.stories.js'],
|
||||
title: 'A',
|
||||
@ -740,13 +740,13 @@ describe('convertToIndexV3', () => {
|
||||
"stories": Object {
|
||||
"a--docs": Object {
|
||||
"id": "a--docs",
|
||||
"importPath": "./src/docs2/MetaOf.docs.mdx",
|
||||
"importPath": "./src/docs2/MetaOf.mdx",
|
||||
"kind": "A",
|
||||
"name": "docs",
|
||||
"parameters": Object {
|
||||
"__id": "a--docs",
|
||||
"docsOnly": true,
|
||||
"fileName": "./src/docs2/MetaOf.docs.mdx",
|
||||
"fileName": "./src/docs2/MetaOf.mdx",
|
||||
},
|
||||
"storiesImports": Array [
|
||||
"./src/A.stories.js",
|
||||
|
@ -120,7 +120,9 @@ export class DocsRender<TFramework extends AnyFramework> implements Render<TFram
|
||||
throw new Error('`storyById` not available for modern docs files.');
|
||||
},
|
||||
componentStories: () => {
|
||||
throw new Error('You cannot render all the stories for a component in a docs.mdx file');
|
||||
throw new Error(
|
||||
'You cannot render all the stories for a component in a (non-legacy) .mdx file'
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ export const importFn = jest.fn(
|
||||
'./src/ComponentOne.stories.js': componentOneExports,
|
||||
'./src/ComponentTwo.stories.js': componentTwoExports,
|
||||
'./src/Legacy.stories.mdx': legacyDocsExports,
|
||||
'./src/Introduction.docs.mdx': modernDocsExports,
|
||||
'./src/Introduction.mdx': modernDocsExports,
|
||||
}[path])
|
||||
);
|
||||
|
||||
@ -87,7 +87,7 @@ export const storyIndex: StoryIndex = {
|
||||
id: 'introduction--docs',
|
||||
title: 'Introduction',
|
||||
name: 'Docs',
|
||||
importPath: './src/Introduction.docs.mdx',
|
||||
importPath: './src/Introduction.mdx',
|
||||
storiesImports: ['./src/ComponentTwo.stories.js'],
|
||||
},
|
||||
'legacy--docs': {
|
||||
|
@ -1100,7 +1100,7 @@ describe('PreviewWeb', () => {
|
||||
|
||||
importFn.mockClear();
|
||||
await preview.onPreloadStories(['introduction--docs']);
|
||||
expect(importFn).toHaveBeenCalledWith('./src/Introduction.docs.mdx');
|
||||
expect(importFn).toHaveBeenCalledWith('./src/Introduction.mdx');
|
||||
});
|
||||
it('loads imports of modern docs entries', async () => {
|
||||
document.location.search = '?id=component-one--a&viewMode=docs';
|
||||
|
@ -626,7 +626,7 @@ describe('StoryStore', () => {
|
||||
id: 'introduction--docs',
|
||||
title: 'Introduction',
|
||||
name: 'Docs',
|
||||
importPath: './introduction.docs.mdx',
|
||||
importPath: './introduction.mdx',
|
||||
storiesImports: [],
|
||||
},
|
||||
},
|
||||
|
@ -44,8 +44,8 @@ const ignoreList = [
|
||||
(error: any) =>
|
||||
error.message.includes('react-async-component-lifecycle-hooks') &&
|
||||
error.stack.includes('addons/knobs/src/components/__tests__/Options.js'),
|
||||
// Storyshots blows up if your project includes a .docs.mdx file (react-ts does).
|
||||
(error: any) => error.message.match(/Unexpected error while loading .*\.docs\.mdx/),
|
||||
// Storyshots blows up if your project includes a (non stories.) mdx file (react-ts does).
|
||||
(error: any) => error.message.match(/Unexpected error while loading .*(?<!stories)\.mdx/),
|
||||
];
|
||||
|
||||
const throwMessage = (type: any, message: any) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user