diff --git a/package.json b/package.json index 7dfe46239e..70a9a9c788 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "shallow-element-equals": "^1.0.1" }, "devDependencies": { - "@alifd/api-extractor": "^3.0.0", + "@alifd/api-extractor": "^3.4.0", "@alifd/babel-preset-next": "^2.0.0", "@alifd/doc-parser": "^1.0.0", "@alifd/dts-generator": "^1.0.0", diff --git a/scripts/build/export-api-schema.js b/scripts/build/export-api-schema.js index 36b95b4281..89b05ad68d 100644 --- a/scripts/build/export-api-schema.js +++ b/scripts/build/export-api-schema.js @@ -3,8 +3,21 @@ const fs = require('fs-extra'); const apiExtractor = require('@alifd/api-extractor'); const tsgen = require('@alifd/dts-generator'); const { logger } = require('../utils'); +const config = require('../config'); const cwd = process.cwd(); +const parentMap = config.child2parent; +const parentPathMap = {}; + +Object.keys(parentMap).forEach(child => { + const parent = parentMap[child]; + const component = parent.split('.')[0].toLowerCase(); + + parentPathMap[child] = { + name: parent, + path: path.join(cwd, 'src', component) + }; +}); module.exports = function (options) { const libPath = path.join(cwd, 'lib'); @@ -20,7 +33,7 @@ module.exports = function (options) { const srcComponentPath = path.join(cwd, 'src', shortName); const libComponentPath = path.join(cwd, 'lib', shortName); - const apiInfo = apiExtractor.extract(srcComponentPath); + const apiInfo = apiExtractor.extract(srcComponentPath, {}, parentPathMap); const apiPath = path.join(libComponentPath, 'api-schema.json'); const exportDTSPath = path.join(libComponentPath, 'index.d.ts'); diff --git a/scripts/config.js b/scripts/config.js index 332331e234..61af3a7850 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -1,4 +1,19 @@ module.exports = { + child2parent: { + // Overlay.Popup inherent from Overlay, add this to generate entire d.ts files + 'Overlay.Popup': 'Overlay', + Dropdown: 'Overlay.Popup', + 'Form.Submit': 'Button', + 'Form.Reset': 'Button', + Nav: 'Menu', + 'Nav.Group': 'Menu.Group', + 'Nav.Item': 'Menu.Item', + 'Nav.PopupItem': 'Menu.PopupItem', + 'Nav.SubMenu': 'Menu.SubMenu', + Search: 'Select.AutoComplete', + 'Upload.Card': 'Upload', + 'Upload.Drager': 'Upload' + }, components: [ 'affix', 'animate',