mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
build: try to use dumi as doc tool
This commit is contained in:
parent
514dedac92
commit
2d4624bb9b
41
.dumi/plugin.ts
Normal file
41
.dumi/plugin.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import type { IApi } from 'dumi';
|
||||||
|
import ReactTechStack from 'dumi/dist/techStacks/react';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extends dumi internal tech stack, for customize previewer props
|
||||||
|
*/
|
||||||
|
class AntdReactTechStack extends ReactTechStack {
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
generatePreviewerProps(...[props, opts]: any) {
|
||||||
|
if (opts.type === 'external') {
|
||||||
|
// try to find md file with the same name as the demo tsx file
|
||||||
|
const locale = opts.mdAbsPath.match(/index\.([a-z-]+)\.md$/i)?.[1];
|
||||||
|
const mdPath = opts.fileAbsPath!.replace(/\.\w+$/, '.md');
|
||||||
|
const md = fs.existsSync(mdPath) ? fs.readFileSync(mdPath, 'utf-8') : '';
|
||||||
|
|
||||||
|
if (md) {
|
||||||
|
// extract description & css style from md file
|
||||||
|
const description = md.match(
|
||||||
|
new RegExp(`(?:^|\\n)## ${locale}([^]+?)(\\n## [a-z]|\\n\`\`\`|\\n<style>|$)`),
|
||||||
|
)?.[1];
|
||||||
|
const style = md.match(/\n```css\n([^]+?)\n```|\n<style>\n([^]+?)\n<\/style>/)?.[1];
|
||||||
|
|
||||||
|
props.description ??= description?.trim();
|
||||||
|
props.style ??= style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (api: IApi) => {
|
||||||
|
// @ts-ignore
|
||||||
|
api.registerTechStack(() => new AntdReactTechStack());
|
||||||
|
|
||||||
|
// api.modifyRoutes((routes) => {
|
||||||
|
// // TODO: append extra routes, such as home, changelog, form-v3
|
||||||
|
// return routes;
|
||||||
|
// });
|
||||||
|
};
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -61,6 +61,9 @@ site/theme/template/NotFound.jsx
|
|||||||
scripts/previewEditor/index.html
|
scripts/previewEditor/index.html
|
||||||
components/version/version.tsx
|
components/version/version.tsx
|
||||||
components/version/token.tsx
|
components/version/token.tsx
|
||||||
|
.umi
|
||||||
|
.umi-test
|
||||||
|
.umi-production
|
||||||
|
|
||||||
# Image snapshot diff
|
# Image snapshot diff
|
||||||
__diff_output__/
|
__diff_output__/
|
||||||
|
29
.umirc.ts
Normal file
29
.umirc.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { defineConfig } from 'dumi';
|
||||||
|
import path from 'path';
|
||||||
|
import { version } from './package.json';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
resolve: {
|
||||||
|
// FIXME: disable docs in temporary
|
||||||
|
docDirs: [],
|
||||||
|
entityDirs: [{ type: 'component', dir: 'components' }],
|
||||||
|
codeBlockMode: 'passive',
|
||||||
|
},
|
||||||
|
locales: [
|
||||||
|
{ id: 'en-US', name: 'English', suffix: '' },
|
||||||
|
{ id: 'zh-CN', name: '中文', suffix: '-cn' },
|
||||||
|
],
|
||||||
|
define: {
|
||||||
|
antdReproduceVersion: version,
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
'@root-entry-name': 'default',
|
||||||
|
},
|
||||||
|
alias: {
|
||||||
|
'antd/lib': path.join(__dirname, 'components'),
|
||||||
|
'antd/es': path.join(__dirname, 'components'),
|
||||||
|
// Change antd from `index.js` to `.dumi/theme/antd.js` to remove deps of root style
|
||||||
|
antd: require.resolve('./.dumi/theme/antd.js'),
|
||||||
|
},
|
||||||
|
plugins: [require.resolve('./.dumi/plugin.ts')],
|
||||||
|
});
|
@ -85,6 +85,7 @@
|
|||||||
"sort": "npx sort-package-json",
|
"sort": "npx sort-package-json",
|
||||||
"sort-api": "antd-tools run sort-api-table",
|
"sort-api": "antd-tools run sort-api-table",
|
||||||
"start": "antd-tools run clean && cross-env NODE_ENV=development concurrently \"bisheng start -c ./site/bisheng.config.js\"",
|
"start": "antd-tools run clean && cross-env NODE_ENV=development concurrently \"bisheng start -c ./site/bisheng.config.js\"",
|
||||||
|
"start:dumi": "npm run version && dumi dev",
|
||||||
"test": "jest --config .jest.js --cache=false",
|
"test": "jest --config .jest.js --cache=false",
|
||||||
"test:update": "jest --config .jest.js --cache=false -u",
|
"test:update": "jest --config .jest.js --cache=false -u",
|
||||||
"test-all": "sh -e ./scripts/test-all.sh",
|
"test-all": "sh -e ./scripts/test-all.sh",
|
||||||
@ -205,6 +206,7 @@
|
|||||||
"dekko": "^0.2.1",
|
"dekko": "^0.2.1",
|
||||||
"docsearch-react-fork": "^0.0.0-alpha.0",
|
"docsearch-react-fork": "^0.0.0-alpha.0",
|
||||||
"docsearch.js": "^2.6.3",
|
"docsearch.js": "^2.6.3",
|
||||||
|
"dumi": "^2.0.0-alpha.2",
|
||||||
"duplicate-package-checker-webpack-plugin": "^3.0.0",
|
"duplicate-package-checker-webpack-plugin": "^3.0.0",
|
||||||
"enquire-js": "^0.2.1",
|
"enquire-js": "^0.2.1",
|
||||||
"enzyme": "^3.10.0",
|
"enzyme": "^3.10.0",
|
||||||
@ -244,6 +246,7 @@
|
|||||||
"jest-puppeteer": "^6.0.0",
|
"jest-puppeteer": "^6.0.0",
|
||||||
"jquery": "^3.4.1",
|
"jquery": "^3.4.1",
|
||||||
"jsdom": "^20.0.0",
|
"jsdom": "^20.0.0",
|
||||||
|
"jsonml-to-react-element": "^1.1.11",
|
||||||
"jsonml.js": "^0.1.0",
|
"jsonml.js": "^0.1.0",
|
||||||
"less-vars-to-js": "^1.3.0",
|
"less-vars-to-js": "^1.3.0",
|
||||||
"lz-string": "^1.4.4",
|
"lz-string": "^1.4.4",
|
||||||
@ -254,6 +257,7 @@
|
|||||||
"prettier-plugin-jsdoc": "^0.4.2",
|
"prettier-plugin-jsdoc": "^0.4.2",
|
||||||
"pretty-format": "^29.0.0",
|
"pretty-format": "^29.0.0",
|
||||||
"pretty-quick": "^3.0.0",
|
"pretty-quick": "^3.0.0",
|
||||||
|
"prismjs": "^1.29.0",
|
||||||
"progress": "^2.0.3",
|
"progress": "^2.0.3",
|
||||||
"qs": "^6.10.1",
|
"qs": "^6.10.1",
|
||||||
"rc-footer": "^0.6.6",
|
"rc-footer": "^0.6.6",
|
||||||
|
Loading…
Reference in New Issue
Block a user