diff --git a/core/docz-core/src/utils/docgen/javascript.ts b/core/docz-core/src/utils/docgen/javascript.ts index db97ddddb..50fd5ee6e 100644 --- a/core/docz-core/src/utils/docgen/javascript.ts +++ b/core/docz-core/src/utils/docgen/javascript.ts @@ -1,4 +1,5 @@ import * as fs from 'fs-extra' +import * as path from 'path' import logger from 'signale' import externalProptypesHandler from 'react-docgen-external-proptypes-handler' import actualNameHandler from 'react-docgen-actual-name-handler' @@ -25,7 +26,7 @@ export const jsParser = (files: string[], config: Config) => { try { const code = fs.readFileSync(filepath, 'utf-8') const props = reactDocgen.parse(code, resolver, handlers) - return { key: filepath, value: props } + return { key: path.normalize(filepath), value: props } } catch (err) { if (config.debug) throwError(err) return null diff --git a/core/docz-core/src/utils/docgen/typescript.ts b/core/docz-core/src/utils/docgen/typescript.ts index 583911fea..c4f172c1c 100644 --- a/core/docz-core/src/utils/docgen/typescript.ts +++ b/core/docz-core/src/utils/docgen/typescript.ts @@ -179,7 +179,7 @@ const parseFiles = (files: string[], config: Config, tsconfig: string) => { } return files.map(filepath => ({ - key: filepath, + key: path.normalize(filepath), value: parser.parseWithProgramProvider(filepath, programProvider), })) } diff --git a/core/docz/src/components/Props.tsx b/core/docz/src/components/Props.tsx index 6a9d986bb..236aeb9d3 100644 --- a/core/docz/src/components/Props.tsx +++ b/core/docz/src/components/Props.tsx @@ -108,7 +108,7 @@ export const Props: SFC = ({ const { props: stateProps } = React.useContext(doczState.context) const PropsComponent = components.props const filename = get('__filemeta.filename', component) - const componentName = component.displayName || component.name + const componentName = get('__filemeta.name', component) || component.displayName || component.name const found = stateProps && stateProps.length > 0 &&