From 7f38c5c874a1048058c9bab191da79eae7d2d265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Thu, 12 Dec 2019 22:55:41 +0100 Subject: [PATCH 1/3] feat(docz-core): allow custom pattern for globbing components --- core/docz-core/src/config/argv.ts | 1 + core/docz-core/src/states/props.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index e05cb1c37..e884dfb3c 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -75,6 +75,7 @@ export interface Config extends Argv { themesDir: string mdxExtensions: string[] filterComponents: (files: string[]) => string[] + customPattern: string[] } export const setArgs = (yargs: Yargs) => { diff --git a/core/docz-core/src/states/props.ts b/core/docz-core/src/states/props.ts index edb6820c4..51fc36cba 100644 --- a/core/docz-core/src/states/props.ts +++ b/core/docz-core/src/states/props.ts @@ -44,7 +44,11 @@ export const initial = (config: Config, pattern: string[]) => async ( ) => { const { filterComponents } = config const cwd = paths.getRootDir(config) - const files = await fastglob(pattern, { cwd, caseSensitiveMatch: false }) + const { customPattern } = config + const files = await fastglob(customPattern || pattern, { + cwd, + caseSensitiveMatch: false, + }) const filtered = filterComponents ? filterComponents(files) : files const metadata = await docgen(filtered, config) p.setState('props', metadata) From 4d77d18c686f04bd9b750dbc60ebc1600a2f374c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Fri, 13 Dec 2019 13:01:35 +0100 Subject: [PATCH 2/3] fixup! feat(docz-core): allow custom pattern for globbing components --- core/docz-core/src/config/argv.ts | 1 + core/docz-core/src/states/props.ts | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index e884dfb3c..26836c8ec 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -27,6 +27,7 @@ export interface DocgenConfig { resolver?: (ast: any, recast: any) => any propFilter?: (prop: any) => boolean searchPath: string + searchPatterns: string[] } export interface Menu { diff --git a/core/docz-core/src/states/props.ts b/core/docz-core/src/states/props.ts index 51fc36cba..99f55e799 100644 --- a/core/docz-core/src/states/props.ts +++ b/core/docz-core/src/states/props.ts @@ -17,6 +17,10 @@ export const getPattern = (config: Config) => { docgenConfig: docgenConfig, } = config + if (docgenConfig.searchPatterns) { + return docgenConfig.searchPatterns + } + const searchPath = docgenConfig.searchPath ? docgenConfig.searchPath : source const root = paths.getRootDir(config) const srcDir = path.resolve(root, searchPath) @@ -44,11 +48,7 @@ export const initial = (config: Config, pattern: string[]) => async ( ) => { const { filterComponents } = config const cwd = paths.getRootDir(config) - const { customPattern } = config - const files = await fastglob(customPattern || pattern, { - cwd, - caseSensitiveMatch: false, - }) + const files = await fastglob(pattern, { cwd, caseSensitiveMatch: false }) const filtered = filterComponents ? filterComponents(files) : files const metadata = await docgen(filtered, config) p.setState('props', metadata) From eb7f33b8114c0cef0732e180dc3b823f4290aa03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Fri, 13 Dec 2019 13:02:30 +0100 Subject: [PATCH 3/3] fixup! fixup! feat(docz-core): allow custom pattern for globbing components --- core/docz-core/src/config/argv.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index 26836c8ec..3a6b5c08a 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -76,7 +76,6 @@ export interface Config extends Argv { themesDir: string mdxExtensions: string[] filterComponents: (files: string[]) => string[] - customPattern: string[] } export const setArgs = (yargs: Yargs) => {