From aa96739b0f2683d002c873174afdffb99fd811bf Mon Sep 17 00:00:00 2001 From: ejuo Date: Wed, 1 May 2019 23:36:29 +0500 Subject: [PATCH] feat(docz-core): extended path configuration for docgen (#846) --- core/docz-core/src/config/argv.ts | 3 ++- core/docz-core/src/states/props.ts | 4 ++-- core/docz/src/components/Props.tsx | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index c92dba078..5603de158 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -26,7 +26,8 @@ export type ThemeConfig = Record export interface DocgenConfig { handlers?: any[] resolver?: (ast: any, recast: any) => any - propFilter?: (prop: any) => boolean + propFilter?: (prop: any) => boolean, + searchPath: string } export interface Menu { diff --git a/core/docz-core/src/states/props.ts b/core/docz-core/src/states/props.ts index 852ec8294..71caf126d 100644 --- a/core/docz-core/src/states/props.ts +++ b/core/docz-core/src/states/props.ts @@ -9,8 +9,8 @@ import { Config } from '../config/argv' import { docgen } from '../utils/docgen' const getPattern = (config: Config) => { - const { typescript: ts, ignore, src: source } = config - const src = relative(paths.root, source) + const { typescript: ts, ignore, src: source, docgenConfig: docgenConfig } = config + const src = relative(paths.root, docgenConfig.searchPath ? docgenConfig.searchPath : source) return ignore .map(entry => `!**/${entry}`) .concat([ diff --git a/core/docz/src/components/Props.tsx b/core/docz/src/components/Props.tsx index de92f6a8a..f19282a69 100644 --- a/core/docz/src/components/Props.tsx +++ b/core/docz/src/components/Props.tsx @@ -113,7 +113,7 @@ export const Props: SFC = ({ const found = stateProps && stateProps.length > 0 && - stateProps.find(item => item.key === filename) + stateProps.find(item => filename ? item.key === filename : item.key.includes(`${componentName}.`)) const value = get('value', found) || [] const firstDefinition = first(value)