Skip to content

Commit

Permalink
feat(docz): 实现文档与组件分离后,文档依然可以获得组件的TS 类型
Browse files Browse the repository at this point in the history
  • Loading branch information
mjzhang1993 committed Jan 4, 2021
1 parent 542da71 commit 86c63c0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/docs/doczrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
/**
* 排除哪些文件
*/
ignore: ["README.md"],
ignore: ["README.md", "../mjz-ui/node_modules"],
/**
* 网站的标题,默认是 package.json name
*/
Expand All @@ -32,4 +32,9 @@ export default {
* docz dev 环境的端口号配置,同样可配置 host
*/
port: 3000,
docgenConfig: {
searchPatterns: ["../mjz-ui/**/*"],
},
filterComponents: (files) =>
files.filter((filepath) => /\/[A-Z]\w*\.(js|jsx|ts|tsx)$/.test(filepath)),
};
11 changes: 11 additions & 0 deletions packages/docs/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require("path");

exports.onCreateWebpackConfig = (args) => {
args.actions.setWebpackConfig({
resolve: {
alias: {
"@mjz-test/mjz-ui": path.resolve(__dirname, "../../../packages/mjz-ui/src"),
},
},
});
};
5 changes: 3 additions & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
"url": "https://github.com/mjzhang1993/lerna-test/issues"
},
"dependencies": {
"@mjz-test/mjz-ui": "^0.8.0",
"@mjz-test/mjz-ui": "0.8.0",
"docz": "^2.3.1",
"gatsby": "^2.29.2",
"gatsby-plugin-less": "^4.4.0",
"gatsby-theme-docz": "^2.3.1",
"less": "^4.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1"
"react-dom": "^17.0.1",
"typescript": "^4.1.3"
}
}
2 changes: 1 addition & 1 deletion packages/docs/src/components/Alert.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {Alert, Button} from '@mjz-test/mjz-ui';
## 基本使用

<Playground>
<Alert>Open</Alert>
<Alert label="xxx">Open</Alert>
<Alert type="error">Open</Alert>
<Alert type="primary">Open</Alert>
</Playground>
Expand Down
26 changes: 26 additions & 0 deletions packages/docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src",
"../mjz-ui/"
]
}

0 comments on commit 86c63c0

Please sign in to comment.