From 450df6a532d6664cb2790b6da05e4fe37f4dff9b Mon Sep 17 00:00:00 2001 From: zuolung Date: Tue, 16 Nov 2021 17:36:58 +0800 Subject: [PATCH 1/3] feat: ts to md --- packages/vantui-doc/package.json | 3 + packages/vantui-doc/scripts/ts-to-md.js | 137 +++++++++ .../vantui-doc/scripts/utils/ts-parser.js | 203 +++++++++++++ packages/vantui-doc/yarn.lock | 275 +++++++++++++++++- 4 files changed, 611 insertions(+), 7 deletions(-) create mode 100644 packages/vantui-doc/scripts/ts-to-md.js create mode 100644 packages/vantui-doc/scripts/utils/ts-parser.js diff --git a/packages/vantui-doc/package.json b/packages/vantui-doc/package.json index 4f894dca9..ef9d3363b 100644 --- a/packages/vantui-doc/package.json +++ b/packages/vantui-doc/package.json @@ -18,8 +18,11 @@ "devDependencies": { "@vant/cli": "^3.9.0", "@vue/compiler-sfc": "^3.0.0", + "ast-to-markdown": "^1.0.0", "cross-env": "^7.0.3", "glob": "^7.2.0", + "markdown-to-ast": "^6.0.3", + "prettier": "^2.4.1", "vue": "^3.0.0" }, "browserslist": [ diff --git a/packages/vantui-doc/scripts/ts-to-md.js b/packages/vantui-doc/scripts/ts-to-md.js new file mode 100644 index 000000000..70b1aab9d --- /dev/null +++ b/packages/vantui-doc/scripts/ts-to-md.js @@ -0,0 +1,137 @@ +const fs = require('fs') +const path = require('path') +const glob = require('glob') +const parser = require('./utils/ts-parser') +const markdownToAst = require('markdown-to-ast') +const astToMarkdown = require('ast-to-markdown') +const ora = require('../node_modules/ora/index') + +const GITHUB_TYPESHS = `https://github.com/AntmJS/vantui/tree/main/packages/vantui/types` +const READMES_PATH = `${path.resolve(process.cwd(), './src/**/README.md')}` +const spinner = ora(`文档 API 同步开始`) + +glob(READMES_PATH, + function (err, path_) { + path_.map((item) => { + const componentName = item.split('/').reverse()[1] + let content = fs.readFileSync(item, 'utf-8') + spinner.start(`${componentName}文档 API 同步中...`) + + if (content) { + content = removeOldTable(content) + } + + if ( + fs.existsSync(`../vantui/types/${componentName}.d.ts`) && + componentName !== 'index' + ) { + let tsInfo = fs.readFileSync( + `../vantui/types/${componentName}.d.ts`, + 'utf-8', + ) + const res = parser(tsInfo) + + fs.writeFileSync(item, content + createMd(res, componentName)) + spinner.stop(`${componentName}文档 API 同步完成`) + } + }) + + spinner.succeed(`文档 API 同步完成`) + }, +) + +function createMd(obj, compName) { + let mdRes = `` + for (const Dkey in obj) { + const item = obj[Dkey] + if (!Object.keys(item).length) continue + mdRes += + `### ${item['title'] && typeof item['title'] === 'string' + ? item['title'] + : Dkey + }` + + ` [[详情]](${GITHUB_TYPESHS}/${compName}.d.ts) +` + mdRes += `${item['description'] || ''} +` + let header = `| 参数 | 说明 | 类型 | 默认值 | 必填 | +| --- | --- | --- | --- | --- | +` + let key = ['self', 'description', 'value', 'default', 'require'] + if (!Dkey.includes('Props')) { + header = `| 参数 | 说明 | 类型 | +| --- | --- | --- | +` + key = ['self', 'description', 'value'] + } + + if (Dkey.includes('Instance')) { + header = `| 方法 | 说明 | 类型 | +| --- | --- | --- | +` + key = ['self', 'description', 'value'] + } + mdRes += header + Object.keys(item).map((_key) => { + if (typeof item[_key] === 'object' && item[_key]) { + key.forEach((k) => { + if (k === 'self') { + mdRes += `| ${_key} ` + } else { + let con = item[_key][k] + if (k === 'value') { + con = con + .replace(/[\n]+/g, '
') + .replace(/\s(?!=\/)/g, ' ') + } + if (con && k === 'value') { + con = `_${con}_` + } else if (con && k === 'require') { + con = '`' + con + '`' + } else if (!con) { + con = `-` + } + mdRes += `| ` + `${con} `.replace(/\|/g, '¦') + } + }) + + mdRes += `| +` + } + }) + mdRes += `\n` + } + return mdRes +} + +function removeOldTable(md) { + let ast = markdownToAst.parse(md) + let shouldRmoveIndex + let firstTableIndex + ast.children.forEach((as, index) => { + if (as.type === 'Table' && firstTableIndex === undefined) { + firstTableIndex = index + } + }) + + for (let index = firstTableIndex; index >= 0; index--) { + if (ast.children[index].type === 'Header') { + shouldRmoveIndex = index + break + } + } + // 处理第一版ts的展示 + if (shouldRmoveIndex === undefined) { + ast.children.forEach((as, index) => { + if (as.type === 'Header' && + as.raw === '### TS信息' && + shouldRmoveIndex === undefined + ) { + shouldRmoveIndex = index + } + }) + } + + ast.children = ast.children.slice(0, shouldRmoveIndex) + return astToMarkdown(ast) +} diff --git a/packages/vantui-doc/scripts/utils/ts-parser.js b/packages/vantui-doc/scripts/utils/ts-parser.js new file mode 100644 index 000000000..dddfd0470 --- /dev/null +++ b/packages/vantui-doc/scripts/utils/ts-parser.js @@ -0,0 +1,203 @@ +const Prettier = require('prettier') +/** 收集d.ts暴露第一层级的属性和注释 */ +module.exports = function main(tsStr) { + tsStr = Prettier.format(tsStr, { semi: false, parser: 'typescript' }) + const { TOKENS } = getAllTokens(tsStr) + const res = parseTokens(TOKENS) + + return res +} + +function getAllTokens(str) { + let TOKENS = [] + let token = '' + for (let i = 0; i < str.length; i++) { + let curItem = str.charAt(i) + if (curItem === ' ' || curItem === '\n') { + if (token) TOKENS.push(token.replace(/[\s]+/, '')) + TOKENS.push(curItem) + token = '' + } else { + token += curItem + } + } + + TOKENS = TOKENS.slice(TOKENS.indexOf('export'), TOKENS.length) + TOKENS = TOKENS.slice(0, TOKENS.indexOf('declare')) + + return { TOKENS } +} + +function parseTokens(TOKENS) { + const res = {} + let value = '' + let count = 0 + let exportName = '' + let attrName = '' + let attrNamePrev = '' + let InBrackets = 0 + let commentsPenddingStr = '' + let commentsStr = '' + let STATUS = { + EXPORT_1: 'EXPORT_WHAT', + EXPORT_2: 'EXPORT_GET_WHAT', + EXPORT_3: 'EXPORTING', + } + let status = STATUS.EXPORT_1 + + for (let i = 0; i < TOKENS.length; i++) { + let curToken = TOKENS[i] + let nextToken = getRealTokenNext(1, TOKENS.slice(i + 1, TOKENS.length - 1)) + let next2Token = getRealTokenNext(2, TOKENS.slice(i + 1, TOKENS.length - 1)) + + if (curToken === '/**' || commentsPenddingStr) { + commentsPenddingStr += curToken + } + + if (curToken === 'export' && ['interface', 'type'].includes(nextToken)) { + if (!res[next2Token]) { + exportName = next2Token + res[exportName] = { + ...parseComments(commentsStr), + } + commentsStr = '' + } + status = STATUS.EXPORT_2 + } + + if (curToken.includes('}') || curToken.includes('})')) { + count-- + if (count === 0) { + status = STATUS.EXPORT_1 + if (attrName && exportName) res[exportName][attrName]['value'] = formatTsValue(value) + value = '' + attrNamePrev = '' + attrName = '' + InBrackets = 0 + exportName = '' + } + } + + if (exportName && count !== 0) { + if ( + curToken.includes(':') && + count < 2 && + !curToken.includes('(') && + InBrackets === 0 + ) { + attrNamePrev = attrName + attrName = curToken.replace(':', '').replace('?', '') + if (!res[exportName][attrName]) { + res[exportName][attrName] = { + ...parseComments(commentsStr), + } + commentsStr = '' + } + if (curToken.includes('?')) { + res[exportName][attrName]['require'] = 'false' + } else { + res[exportName][attrName]['require'] = 'true' + } + if (attrNamePrev) { + if (!res[exportName]) res[exportName] = {} + if (!res[exportName][attrNamePrev]) res[exportName][attrNamePrev] = {} + res[exportName][attrNamePrev]['value'] = formatTsValue(value) + value = '' + } + } else if (status === STATUS.EXPORT_3 && !commentsPenddingStr) { + value += `${curToken}` + } + } + if (curToken === '*/') { + commentsStr = commentsPenddingStr + curToken + commentsPenddingStr = '' + } + const InBracketsNum1 = countStrNumInToken('(', curToken) + const InBracketsNum2 = countStrNumInToken(')', curToken) + + if (InBracketsNum1 > 0) { + InBrackets += InBracketsNum1 + } + if (InBracketsNum2) { + InBrackets -= InBracketsNum2 + } + + if (curToken.includes('{') && status === STATUS.EXPORT_2) { + status = STATUS.EXPORT_3 + } + + if (curToken.includes('{') || curToken.includes('({')) { + count++ + } + } + + return res +} + +function countStrNumInToken(str, token) { + let res = 0 + for (let i = 0; i < token.length; i++) { + if (token.charAt(i) === str) { + res++ + } + } + + return res +} + +function getRealTokenNext(nextNum, lastTokens) { + let res = '' + let next_i = 0 + for (let a = 0; a < lastTokens.length; a++) { + if (lastTokens[a] !== ' ' && lastTokens[a] !== '\n') { + next_i++ + if (next_i === nextNum) { + res = lastTokens[a] + break + } + } + } + + return res +} + +function parseComments(comments = '') { + let res = {} + const arr = comments + .split('\n') + .filter((item) => item.includes('@')) + .map((item) => item.replace(/^[\s]+/g, '')) + .map((item) => item.replace('* ', '')) + .map((item) => item.replace('@', '')) + .map((item) => item.replace(/[\s]+/, '##')) + + arr.forEach((item) => { + const cons = item.split('##') + res[cons[0]] = cons[1] + }) + + return res +} + +function formatTsValue(tsValue) { + let res = Prettier.format( + `type temp = { +attr:${tsValue} +} +// END`, + { + parser: 'typescript', + semi: false, + printWidth: 48, + }, + ).replace('type temp = {\n', '') + .replace('attr: ', '') + .replace( + `} +// END`, + '', + ) + + return res +} + diff --git a/packages/vantui-doc/yarn.lock b/packages/vantui-doc/yarn.lock index 7dfe37466..0266effa2 100644 --- a/packages/vantui-doc/yarn.lock +++ b/packages/vantui-doc/yarn.lock @@ -1481,6 +1481,11 @@ dependencies: defer-to-connect "^2.0.0" +"@textlint/ast-node-types@^4.0.0": + version "4.4.3" + resolved "https://registry.nlark.com/@textlint/ast-node-types/download/@textlint/ast-node-types-4.4.3.tgz#fdba16e8126cddc50f45433ce7f6c55e7829566c" + integrity sha1-/boW6BJs3cUPRUM85/bFXngpVmw= + "@tootallnate/once@1": version "1.1.2" resolved "https://registry.npmmirror.com/@tootallnate/once/download/@tootallnate/once-1.1.2.tgz?cache=0&sync_timestamp=1632734105305&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40tootallnate%2Fonce%2Fdownload%2F%40tootallnate%2Fonce-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" @@ -2536,6 +2541,11 @@ assign-symbols@^1.0.0: resolved "https://registry.nlark.com/assign-symbols/download/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= +ast-to-markdown@^1.0.0: + version "1.0.0" + resolved "https://registry.npmmirror.com/ast-to-markdown/download/ast-to-markdown-1.0.0.tgz#3073c3e15ec1a768404ca458f26a9f03e1e93d70" + integrity sha1-MHPD4V7Bp2hATKRY8mqfA+HpPXA= + astral-regex@^2.0.0: version "2.0.0" resolved "https://registry.npm.taobao.org/astral-regex/download/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" @@ -2810,6 +2820,11 @@ boolbase@^1.0.0: resolved "https://registry.nlark.com/boolbase/download/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= +boundary@^1.0.1: + version "1.0.1" + resolved "https://registry.nlark.com/boundary/download/boundary-1.0.1.tgz#4d67dc2602c0cc16dd9bce7ebf87e948290f5812" + integrity sha1-TWfcJgLAzBbdm85+v4fpSCkPWBI= + boxen@^5.0.0: version "5.1.2" resolved "https://registry.npmmirror.com/boxen/download/boxen-5.1.2.tgz?cache=0&sync_timestamp=1634028659618&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fboxen%2Fdownload%2Fboxen-5.1.2.tgz#788cb686fc83c1f486dfa8a40c68fc2b831d2b50" @@ -3011,6 +3026,11 @@ capture-exit@^2.0.0: dependencies: rsvp "^4.8.4" +ccount@^1.0.0: + version "1.1.0" + resolved "https://registry.npm.taobao.org/ccount/download/ccount-1.1.0.tgz#246687debb6014735131be8abab2d93898f8d043" + integrity sha1-JGaH3rtgFHNRMb6KurLZOJj40EM= + chalk@4.1.2, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: version "4.1.2" resolved "https://registry.nlark.com/chalk/download/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -3033,6 +3053,11 @@ char-regex@^1.0.2: resolved "https://registry.nlark.com/char-regex/download/char-regex-1.0.2.tgz?cache=0&sync_timestamp=1622809071355&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fchar-regex%2Fdownload%2Fchar-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" integrity sha1-10Q1giYhf5ge1Y9Hmx1rzClUXc8= +character-entities-html4@^1.0.0: + version "1.1.4" + resolved "https://registry.npmmirror.com/character-entities-html4/download/character-entities-html4-1.1.4.tgz#0e64b0a3753ddbf1fdc044c5fd01d0199a02e125" + integrity sha1-DmSwo3U92/H9wETF/QHQGZoC4SU= + character-entities-legacy@^1.0.0: version "1.1.4" resolved "https://registry.npm.taobao.org/character-entities-legacy/download/character-entities-legacy-1.1.4.tgz#94bc1845dce70a5bb9d2ecc748725661293d8fc1" @@ -3226,6 +3251,11 @@ co@^4.6.0: resolved "https://registry.npm.taobao.org/co/download/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= +collapse-white-space@^1.0.2: + version "1.0.6" + resolved "https://registry.npm.taobao.org/collapse-white-space/download/collapse-white-space-1.0.6.tgz?cache=0&sync_timestamp=1615196661688&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcollapse-white-space%2Fdownload%2Fcollapse-white-space-1.0.6.tgz#e63629c0016665792060dbbeb79c42239d2c5287" + integrity sha1-5jYpwAFmZXkgYNu+t5xCI50sUoc= + collect-v8-coverage@^1.0.0: version "1.0.1" resolved "https://registry.npm.taobao.org/collect-v8-coverage/download/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" @@ -3707,7 +3737,7 @@ dateformat@^3.0.0: resolved "https://registry.npmmirror.com/dateformat/download/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha1-puN0maTZqc+F71hyBE1ikByYia4= -debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: +debug@2.6.9, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: version "2.6.9" resolved "https://registry.nlark.com/debug/download/debug-2.6.9.tgz?cache=0&sync_timestamp=1625374675284&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdebug%2Fdownload%2Fdebug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8= @@ -5276,7 +5306,7 @@ has-yarn@^2.1.0: resolved "https://registry.nlark.com/has-yarn/download/has-yarn-2.1.0.tgz?cache=0&sync_timestamp=1631299286113&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fhas-yarn%2Fdownload%2Fhas-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" integrity sha1-E34RNUp7W/EapctknPDG8/8rLnc= -has@^1.0.3: +has@^1.0.1, has@^1.0.3: version "1.0.3" resolved "https://registry.nlark.com/has/download/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y= @@ -5605,7 +5635,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: +inherits@2, inherits@2.0.4, inherits@^2.0.0, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: version "2.0.4" resolved "https://registry.nlark.com/inherits/download/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w= @@ -5706,6 +5736,11 @@ is-alphabetical@^1.0.0: resolved "https://registry.nlark.com/is-alphabetical/download/is-alphabetical-1.0.4.tgz#9e7d6b94916be22153745d184c298cbf986a686d" integrity sha1-nn1rlJFr4iFTdF0YTCmMv5hqaG0= +is-alphanumeric@^1.0.0: + version "1.0.0" + resolved "https://registry.npm.taobao.org/is-alphanumeric/download/is-alphanumeric-1.0.0.tgz#4a9cef71daf4c001c1d81d63d140cf53fd6889f4" + integrity sha1-Spzvcdr0wAHB2B1j0UDPU/1oifQ= + is-alphanumerical@^1.0.0: version "1.0.4" resolved "https://registry.npm.taobao.org/is-alphanumerical/download/is-alphanumerical-1.0.4.tgz?cache=0&sync_timestamp=1615453958702&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-alphanumerical%2Fdownload%2Fis-alphanumerical-1.0.4.tgz#7eb9a2431f855f6b1ef1a78e326df515696c4dbf" @@ -5756,7 +5791,7 @@ is-boolean-object@^1.1.0: call-bind "^1.0.2" has-tostringtag "^1.0.0" -is-buffer@^1.1.5: +is-buffer@^1.1.4, is-buffer@^1.1.5: version "1.1.6" resolved "https://registry.nlark.com/is-buffer/download/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha1-76ouqdqg16suoTqXsritUf776L4= @@ -6083,11 +6118,21 @@ is-what@^3.12.0: resolved "https://registry.npmmirror.com/is-what/download/is-what-3.14.1.tgz?cache=0&sync_timestamp=1634283398540&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fis-what%2Fdownload%2Fis-what-3.14.1.tgz#e1222f46ddda85dead0fd1c9df131760e77755c1" integrity sha1-4SIvRt3ahd6tD9HJ3xMXYOd3VcE= +is-whitespace-character@^1.0.0: + version "1.0.4" + resolved "https://registry.npmmirror.com/is-whitespace-character/download/is-whitespace-character-1.0.4.tgz#0858edd94a95594c7c9dd0b5c174ec6e45ee4aa7" + integrity sha1-CFjt2UqVWUx8ndC1wXTsbkXuSqc= + is-windows@^1.0.2: version "1.0.2" resolved "https://registry.nlark.com/is-windows/download/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha1-0YUOuXkezRjmGCzhKjDzlmNLsZ0= +is-word-character@^1.0.0: + version "1.0.4" + resolved "https://registry.npmmirror.com/is-word-character/download/is-word-character-1.0.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fis-word-character%2Fdownload%2Fis-word-character-1.0.4.tgz#ce0e73216f98599060592f62ff31354ddbeb0230" + integrity sha1-zg5zIW+YWZBgWS9i/zE1TdvrAjA= + is-wsl@^1.1.0: version "1.1.0" resolved "https://registry.nlark.com/is-wsl/download/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" @@ -6984,7 +7029,7 @@ loglevel@^1.6.8: resolved "https://registry.nlark.com/loglevel/download/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197" integrity sha1-AF/eL15uRwaPk1/yhXPhJe9y8Zc= -longest-streak@^2.0.0: +longest-streak@^2.0.0, longest-streak@^2.0.1: version "2.0.4" resolved "https://registry.nlark.com/longest-streak/download/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4" integrity sha1-uFmZV9pbXatk3uP+MW+ndFl9kOQ= @@ -7074,6 +7119,11 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +markdown-escapes@^1.0.0: + version "1.0.4" + resolved "https://registry.npmmirror.com/markdown-escapes/download/markdown-escapes-1.0.4.tgz?cache=0&sync_timestamp=1635887464232&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fmarkdown-escapes%2Fdownload%2Fmarkdown-escapes-1.0.4.tgz#c95415ef451499d7602b91095f3c8e8975f78535" + integrity sha1-yVQV70UUmddgK5EJXzyOiXX3hTU= + markdown-it-anchor@^7.1.0: version "7.1.0" resolved "https://registry.npmmirror.com/markdown-it-anchor/download/markdown-it-anchor-7.1.0.tgz#30fb21497bf59e83ff4d1ddc052d821962e2489e" @@ -7090,11 +7140,34 @@ markdown-it@^12.0.4: mdurl "^1.0.1" uc.micro "^1.0.5" +markdown-table@^1.1.0: + version "1.1.3" + resolved "https://registry.nlark.com/markdown-table/download/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60" + integrity sha1-n8tpvP24cXv9A5jG7C2TA2743mA= + +markdown-to-ast@^6.0.3: + version "6.0.3" + resolved "https://registry.npmmirror.com/markdown-to-ast/download/markdown-to-ast-6.0.3.tgz#c939442fee0e2074975cd7049ce8103d7be8f021" + integrity sha1-yTlEL+4OIHSXXNcEnOgQPXvo8CE= + dependencies: + "@textlint/ast-node-types" "^4.0.0" + debug "^2.1.3" + remark "^7.0.1" + structured-source "^3.0.2" + traverse "^0.6.6" + mathml-tag-names@^2.1.3: version "2.1.3" resolved "https://registry.npm.taobao.org/mathml-tag-names/download/mathml-tag-names-2.1.3.tgz?cache=0&sync_timestamp=1615374040090&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmathml-tag-names%2Fdownload%2Fmathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" integrity sha1-TdrdZzCOeAzxakdoWHjuJ7c2oKM= +mdast-util-compact@^1.0.0: + version "1.0.4" + resolved "https://registry.nlark.com/mdast-util-compact/download/mdast-util-compact-1.0.4.tgz?cache=0&sync_timestamp=1627636001332&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmdast-util-compact%2Fdownload%2Fmdast-util-compact-1.0.4.tgz#d531bb7667b5123abf20859be086c4d06c894593" + integrity sha1-1TG7dme1Ejq/IIWb4IbE0GyJRZM= + dependencies: + unist-util-visit "^1.1.0" + mdast-util-from-markdown@^0.8.0, mdast-util-from-markdown@^0.8.5: version "0.8.5" resolved "https://registry.npmmirror.com/mdast-util-from-markdown/download/mdast-util-from-markdown-0.8.5.tgz?cache=0&sync_timestamp=1633769932076&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fmdast-util-from-markdown%2Fdownload%2Fmdast-util-from-markdown-0.8.5.tgz#d1ef2ca42bc377ecb0463a987910dae89bd9a28c" @@ -7876,6 +7949,18 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +parse-entities@^1.0.2: + version "1.2.2" + resolved "https://registry.npmmirror.com/parse-entities/download/parse-entities-1.2.2.tgz#c31bf0f653b6661354f8973559cb86dd1d5edf50" + integrity sha1-wxvw9lO2ZhNU+Jc1WcuG3R1e31A= + dependencies: + character-entities "^1.0.0" + character-entities-legacy "^1.0.0" + character-reference-invalid "^1.0.0" + is-alphanumerical "^1.0.0" + is-decimal "^1.0.0" + is-hexadecimal "^1.0.0" + parse-entities@^2.0.0: version "2.0.0" resolved "https://registry.npm.taobao.org/parse-entities/download/parse-entities-2.0.0.tgz#53c6eb5b9314a1f4ec99fa0fdf7ce01ecda0cbe8" @@ -8261,6 +8346,11 @@ prettier@2.1.0: resolved "https://registry.nlark.com/prettier/download/prettier-2.1.0.tgz?cache=0&sync_timestamp=1631777167012&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fprettier%2Fdownload%2Fprettier-2.1.0.tgz#5a9789f767a243118c60f3e56d95cb6544914fbb" integrity sha1-WpeJ92eiQxGMYPPlbZXLZUSRT7s= +prettier@^2.4.1: + version "2.4.1" + resolved "https://registry.nlark.com/prettier/download/prettier-2.4.1.tgz?cache=0&sync_timestamp=1631777167012&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fprettier%2Fdownload%2Fprettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c" + integrity sha1-Zx4RyJwUpM/Ids5WQQbEpnJsn1w= + pretty-error@^4.0.0: version "4.0.0" resolved "https://registry.npmmirror.com/pretty-error/download/pretty-error-4.0.0.tgz#90a703f46dd7234adb46d0f84823e9d1cb8f10d6" @@ -8651,6 +8741,28 @@ release-it@^14.8.0: yaml "1.10.2" yargs-parser "20.2.9" +remark-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.nlark.com/remark-parse/download/remark-parse-3.0.1.tgz?cache=0&sync_timestamp=1627989789864&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fremark-parse%2Fdownload%2Fremark-parse-3.0.1.tgz#1b9f841a44d8f4fbf2246850265459a4eb354c80" + integrity sha1-G5+EGkTY9PvyJGhQJlRZpOs1TIA= + dependencies: + collapse-white-space "^1.0.2" + has "^1.0.1" + is-alphabetical "^1.0.0" + is-decimal "^1.0.0" + is-whitespace-character "^1.0.0" + is-word-character "^1.0.0" + markdown-escapes "^1.0.0" + parse-entities "^1.0.2" + repeat-string "^1.5.4" + state-toggle "^1.0.0" + trim "0.0.1" + trim-trailing-lines "^1.0.0" + unherit "^1.0.4" + unist-util-remove-position "^1.0.0" + vfile-location "^2.0.0" + xtend "^4.0.1" + remark-parse@^9.0.0: version "9.0.0" resolved "https://registry.nlark.com/remark-parse/download/remark-parse-9.0.0.tgz?cache=0&sync_timestamp=1627989789864&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fremark-parse%2Fdownload%2Fremark-parse-9.0.0.tgz#4d20a299665880e4f4af5d90b7c7b8a935853640" @@ -8658,6 +8770,26 @@ remark-parse@^9.0.0: dependencies: mdast-util-from-markdown "^0.8.0" +remark-stringify@^3.0.0: + version "3.0.1" + resolved "https://registry.npmmirror.com/remark-stringify/download/remark-stringify-3.0.1.tgz#79242bebe0a752081b5809516fa0c06edec069cf" + integrity sha1-eSQr6+CnUggbWAlRb6DAbt7Aac8= + dependencies: + ccount "^1.0.0" + is-alphanumeric "^1.0.0" + is-decimal "^1.0.0" + is-whitespace-character "^1.0.0" + longest-streak "^2.0.1" + markdown-escapes "^1.0.0" + markdown-table "^1.1.0" + mdast-util-compact "^1.0.0" + parse-entities "^1.0.2" + repeat-string "^1.5.4" + state-toggle "^1.0.0" + stringify-entities "^1.0.1" + unherit "^1.0.4" + xtend "^4.0.1" + remark-stringify@^9.0.0: version "9.0.1" resolved "https://registry.npmmirror.com/remark-stringify/download/remark-stringify-9.0.1.tgz#576d06e910548b0a7191a71f27b33f1218862894" @@ -8674,6 +8806,15 @@ remark@^13.0.0: remark-stringify "^9.0.0" unified "^9.1.0" +remark@^7.0.1: + version "7.0.1" + resolved "https://registry.nlark.com/remark/download/remark-7.0.1.tgz#a5de4dacfabf0f60a49826ef24c479807f904bfb" + integrity sha1-pd5NrPq/D2CkmCbvJMR5gH+QS/s= + dependencies: + remark-parse "^3.0.0" + remark-stringify "^3.0.0" + unified "^6.0.0" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.nlark.com/remove-trailing-separator/download/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -8695,11 +8836,16 @@ repeat-element@^1.1.2: resolved "https://registry.npm.taobao.org/repeat-element/download/repeat-element-1.1.4.tgz#be681520847ab58c7568ac75fbfad28ed42d39e9" integrity sha1-vmgVIIR6tYx1aKx1+/rSjtQtOek= -repeat-string@^1.0.0, repeat-string@^1.6.1: +repeat-string@^1.0.0, repeat-string@^1.5.4, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.npm.taobao.org/repeat-string/download/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= +replace-ext@1.0.0: + version "1.0.0" + resolved "https://registry.npm.taobao.org/replace-ext/download/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" + integrity sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.npm.taobao.org/require-directory/download/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -9361,6 +9507,11 @@ stack-utils@^2.0.2: dependencies: escape-string-regexp "^2.0.0" +state-toggle@^1.0.0: + version "1.0.3" + resolved "https://registry.npm.taobao.org/state-toggle/download/state-toggle-1.0.3.tgz?cache=0&sync_timestamp=1615190484861&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstate-toggle%2Fdownload%2Fstate-toggle-1.0.3.tgz#e123b16a88e143139b09c6852221bc9815917dfe" + integrity sha1-4SOxaojhQxObCcaFIiG8mBWRff4= + static-extend@^0.1.1: version "0.1.2" resolved "https://registry.nlark.com/static-extend/download/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -9447,6 +9598,16 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +stringify-entities@^1.0.1: + version "1.3.2" + resolved "https://registry.npmmirror.com/stringify-entities/download/stringify-entities-1.3.2.tgz#a98417e5471fd227b3e45d3db1861c11caf668f7" + integrity sha1-qYQX5Ucf0iez5F09sYYcEcr2aPc= + dependencies: + character-entities-html4 "^1.0.0" + character-entities-legacy "^1.0.0" + is-alphanumerical "^1.0.0" + is-hexadecimal "^1.0.0" + stringify-object@^3.3.0: version "3.3.0" resolved "https://registry.nlark.com/stringify-object/download/stringify-object-3.3.0.tgz#703065aefca19300d3ce88af4f5b3956d7556629" @@ -9521,6 +9682,13 @@ strip-outer@^1.0.1: dependencies: escape-string-regexp "^1.0.2" +structured-source@^3.0.2: + version "3.0.2" + resolved "https://registry.npmmirror.com/structured-source/download/structured-source-3.0.2.tgz#dd802425e0f53dc4a6e7aca3752901a1ccda7af5" + integrity sha1-3YAkJeD1PcSm56yjdSkBoczaevU= + dependencies: + boundary "^1.0.1" + style-loader@^2.0.0: version "2.0.0" resolved "https://registry.npmmirror.com/style-loader/download/style-loader-2.0.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fstyle-loader%2Fdownload%2Fstyle-loader-2.0.0.tgz#9669602fd4690740eaaec137799a03addbbc393c" @@ -9845,6 +10013,11 @@ transliteration@^2.2.0: dependencies: yargs "^16.1.0" +traverse@^0.6.6: + version "0.6.6" + resolved "https://registry.npm.taobao.org/traverse/download/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" + integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= + trim-newlines@^3.0.0: version "3.0.1" resolved "https://registry.nlark.com/trim-newlines/download/trim-newlines-3.0.1.tgz?cache=0&sync_timestamp=1623341669040&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftrim-newlines%2Fdownload%2Ftrim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" @@ -9857,6 +10030,16 @@ trim-repeated@^1.0.0: dependencies: escape-string-regexp "^1.0.2" +trim-trailing-lines@^1.0.0: + version "1.1.4" + resolved "https://registry.nlark.com/trim-trailing-lines/download/trim-trailing-lines-1.1.4.tgz#bd4abbec7cc880462f10b2c8b5ce1d8d1ec7c2c0" + integrity sha1-vUq77HzIgEYvELLItc4djR7HwsA= + +trim@0.0.1: + version "0.0.1" + resolved "https://registry.npm.taobao.org/trim/download/trim-0.0.1.tgz?cache=0&sync_timestamp=1617312392149&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftrim%2Fdownload%2Ftrim-0.0.1.tgz#5858547f6b290757ee95cccc666fb50084c460dd" + integrity sha1-WFhUf2spB1fulczMZm+1AITEYN0= + trough@^1.0.0: version "1.0.5" resolved "https://registry.nlark.com/trough/download/trough-1.0.5.tgz#b8b639cefad7d0bb2abd37d433ff8293efa5f406" @@ -10009,6 +10192,14 @@ unbox-primitive@^1.0.1: has-symbols "^1.0.2" which-boxed-primitive "^1.0.2" +unherit@^1.0.4: + version "1.1.3" + resolved "https://registry.nlark.com/unherit/download/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22" + integrity sha1-bJtQPytBsmIzDIDpHIYUq9qmnCI= + dependencies: + inherits "^2.0.0" + xtend "^4.0.0" + unicode-canonical-property-names-ecmascript@^2.0.0: version "2.0.0" resolved "https://registry.nlark.com/unicode-canonical-property-names-ecmascript/download/unicode-canonical-property-names-ecmascript-2.0.0.tgz?cache=0&sync_timestamp=1631615505724&other_urls=https%3A%2F%2Fregistry.nlark.com%2Funicode-canonical-property-names-ecmascript%2Fdownload%2Funicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc" @@ -10032,6 +10223,18 @@ unicode-property-aliases-ecmascript@^2.0.0: resolved "https://registry.nlark.com/unicode-property-aliases-ecmascript/download/unicode-property-aliases-ecmascript-2.0.0.tgz?cache=0&sync_timestamp=1631609408629&other_urls=https%3A%2F%2Fregistry.nlark.com%2Funicode-property-aliases-ecmascript%2Fdownload%2Funicode-property-aliases-ecmascript-2.0.0.tgz#0a36cb9a585c4f6abd51ad1deddb285c165297c8" integrity sha1-CjbLmlhcT2q9Ua0d7dsoXBZSl8g= +unified@^6.0.0: + version "6.2.0" + resolved "https://registry.nlark.com/unified/download/unified-6.2.0.tgz?cache=0&sync_timestamp=1627639621063&other_urls=https%3A%2F%2Fregistry.nlark.com%2Funified%2Fdownload%2Funified-6.2.0.tgz#7fbd630f719126d67d40c644b7e3f617035f6dba" + integrity sha1-f71jD3GRJtZ9QMZEt+P2FwNfbbo= + dependencies: + bail "^1.0.0" + extend "^3.0.0" + is-plain-obj "^1.1.0" + trough "^1.0.0" + vfile "^2.0.0" + x-is-string "^0.1.0" + unified@^9.1.0: version "9.2.2" resolved "https://registry.nlark.com/unified/download/unified-9.2.2.tgz?cache=0&sync_timestamp=1627639621063&other_urls=https%3A%2F%2Fregistry.nlark.com%2Funified%2Fdownload%2Funified-9.2.2.tgz#67649a1abfc3ab85d2969502902775eb03146975" @@ -10068,11 +10271,28 @@ unist-util-find-all-after@^3.0.2: dependencies: unist-util-is "^4.0.0" +unist-util-is@^3.0.0: + version "3.0.0" + resolved "https://registry.nlark.com/unist-util-is/download/unist-util-is-3.0.0.tgz#d9e84381c2468e82629e4a5be9d7d05a2dd324cd" + integrity sha1-2ehDgcJGjoJinkpb6dfQWi3TJM0= + unist-util-is@^4.0.0: version "4.1.0" resolved "https://registry.nlark.com/unist-util-is/download/unist-util-is-4.1.0.tgz#976e5f462a7a5de73d94b706bac1b90671b57797" integrity sha1-l25fRip6Xec9lLcGusG5BnG1d5c= +unist-util-remove-position@^1.0.0: + version "1.1.4" + resolved "https://registry.nlark.com/unist-util-remove-position/download/unist-util-remove-position-1.1.4.tgz#ec037348b6102c897703eee6d0294ca4755a2020" + integrity sha1-7ANzSLYQLIl3A+7m0ClMpHVaICA= + dependencies: + unist-util-visit "^1.1.0" + +unist-util-stringify-position@^1.0.0, unist-util-stringify-position@^1.1.1: + version "1.1.2" + resolved "https://registry.npm.taobao.org/unist-util-stringify-position/download/unist-util-stringify-position-1.1.2.tgz#3f37fcf351279dcbca7480ab5889bb8a832ee1c6" + integrity sha1-Pzf881EnncvKdICrWIm7ioMu4cY= + unist-util-stringify-position@^2.0.0: version "2.0.3" resolved "https://registry.npm.taobao.org/unist-util-stringify-position/download/unist-util-stringify-position-2.0.3.tgz#cce3bfa1cdf85ba7375d1d5b17bdc4cada9bd9da" @@ -10080,6 +10300,20 @@ unist-util-stringify-position@^2.0.0: dependencies: "@types/unist" "^2.0.2" +unist-util-visit-parents@^2.0.0: + version "2.1.2" + resolved "https://registry.nlark.com/unist-util-visit-parents/download/unist-util-visit-parents-2.1.2.tgz?cache=0&sync_timestamp=1632208991791&other_urls=https%3A%2F%2Fregistry.nlark.com%2Funist-util-visit-parents%2Fdownload%2Funist-util-visit-parents-2.1.2.tgz#25e43e55312166f3348cae6743588781d112c1e9" + integrity sha1-JeQ+VTEhZvM0jK5nQ1iHgdESwek= + dependencies: + unist-util-is "^3.0.0" + +unist-util-visit@^1.1.0: + version "1.4.1" + resolved "https://registry.npmmirror.com/unist-util-visit/download/unist-util-visit-1.4.1.tgz?cache=0&sync_timestamp=1632405298952&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Funist-util-visit%2Fdownload%2Funist-util-visit-1.4.1.tgz#4724aaa8486e6ee6e26d7ff3c8685960d560b1e3" + integrity sha1-RySqqEhububibX/zyGhZYNVgseM= + dependencies: + unist-util-visit-parents "^2.0.0" + universal-user-agent@^6.0.0: version "6.0.0" resolved "https://registry.npmmirror.com/universal-user-agent/download/universal-user-agent-6.0.0.tgz?cache=0&sync_timestamp=1632414657936&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Funiversal-user-agent%2Fdownload%2Funiversal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" @@ -10230,6 +10464,18 @@ vary@~1.1.2: resolved "https://registry.nlark.com/vary/download/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= +vfile-location@^2.0.0: + version "2.0.6" + resolved "https://registry.nlark.com/vfile-location/download/vfile-location-2.0.6.tgz#8a274f39411b8719ea5728802e10d9e0dff1519e" + integrity sha1-iidPOUEbhxnqVyiALhDZ4N/xUZ4= + +vfile-message@^1.0.0: + version "1.1.1" + resolved "https://registry.nlark.com/vfile-message/download/vfile-message-1.1.1.tgz#5833ae078a1dfa2d96e9647886cd32993ab313e1" + integrity sha1-WDOuB4od+i2W6WR4hs0ymTqzE+E= + dependencies: + unist-util-stringify-position "^1.1.1" + vfile-message@^2.0.0: version "2.0.4" resolved "https://registry.nlark.com/vfile-message/download/vfile-message-2.0.4.tgz#5b43b88171d409eae58477d13f23dd41d52c371a" @@ -10238,6 +10484,16 @@ vfile-message@^2.0.0: "@types/unist" "^2.0.0" unist-util-stringify-position "^2.0.0" +vfile@^2.0.0: + version "2.3.0" + resolved "https://registry.npmmirror.com/vfile/download/vfile-2.3.0.tgz#e62d8e72b20e83c324bc6c67278ee272488bf84a" + integrity sha1-5i2OcrIOg8MkvGxnJ47ickiL+Eo= + dependencies: + is-buffer "^1.1.4" + replace-ext "1.0.0" + unist-util-stringify-position "^1.0.0" + vfile-message "^1.0.0" + vfile@^4.0.0: version "4.2.1" resolved "https://registry.npmmirror.com/vfile/download/vfile-4.2.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fvfile%2Fdownload%2Fvfile-4.2.1.tgz#03f1dce28fc625c625bc6514350fbdb00fa9e624" @@ -10629,6 +10885,11 @@ ws@^7.4.6: resolved "https://registry.npmmirror.com/ws/download/ws-7.5.5.tgz?cache=0&sync_timestamp=1633200113162&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fws%2Fdownload%2Fws-7.5.5.tgz#8b4bc4af518cfabd0473ae4f99144287b33eb881" integrity sha1-i0vEr1GM+r0Ec65PmRRCh7M+uIE= +x-is-string@^0.1.0: + version "0.1.0" + resolved "https://registry.npm.taobao.org/x-is-string/download/x-is-string-0.1.0.tgz#474b50865af3a49a9c4657f05acd145458f77d82" + integrity sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI= + xdg-basedir@^4.0.0: version "4.0.0" resolved "https://registry.nlark.com/xdg-basedir/download/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13" @@ -10644,7 +10905,7 @@ xmlchars@^2.2.0: resolved "https://registry.npm.taobao.org/xmlchars/download/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha1-Bg/hvLf5x2/ioX24apvDq4lCEMs= -xtend@~4.0.1: +xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: version "4.0.2" resolved "https://registry.nlark.com/xtend/download/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" integrity sha1-u3J3n1+kZRhrH0OPZ0+jR/2121Q= From abdc2b86a19ddeeae47555d72a8152d0a8eb90b8 Mon Sep 17 00:00:00 2001 From: zuolung Date: Tue, 16 Nov 2021 18:32:30 +0800 Subject: [PATCH 2/3] feat: update cli --- packages/vantui-doc/package.json | 2 +- packages/vantui-doc/synch.js | 29 ----------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 packages/vantui-doc/synch.js diff --git a/packages/vantui-doc/package.json b/packages/vantui-doc/package.json index ef9d3363b..bf347d429 100644 --- a/packages/vantui-doc/package.json +++ b/packages/vantui-doc/package.json @@ -8,7 +8,7 @@ "test:coverage": "open test/coverage/index.html", "build": "node synch.js && sh ./build.sh", "release": "npx gh-pages -d site", - "docs-ts": "node ./synch.js" + "docs-ts": "node ./scripts/ts-to-md" }, "author": "sanshao", "license": "MIT", diff --git a/packages/vantui-doc/synch.js b/packages/vantui-doc/synch.js deleted file mode 100644 index 2ff36ef4d..000000000 --- a/packages/vantui-doc/synch.js +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const fs = require('fs') -const path = require('path') -const glob = require('glob') - -glob( - `${path.resolve(process.cwd(), './src/**/README.md')}`, - function (err, path_) { - path_.map((item) => { - const componentName = item.split('/').reverse()[1] - let content = fs - .readFileSync(item, 'utf-8') - .replace(/###\sTS信息[\s\S]+```$/, '') - - if ( - fs.existsSync(`../vantui/types/${componentName}.d.ts`) && - componentName !== 'index' - ) { - content += - `### TS信息` + - '\n```ts \n' + - fs.readFileSync(`../vantui/types/${componentName}.d.ts`, 'utf-8') + - '```' - } - - fs.writeFileSync(item, content) - }) - }, -) From e1978642e6ba3ac3e39559f267ddf2ecb5c9e2b4 Mon Sep 17 00:00:00 2001 From: zuolung Date: Tue, 16 Nov 2021 18:42:25 +0800 Subject: [PATCH 3/3] feat: upodate cli --- packages/vantui-doc/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vantui-doc/package.json b/packages/vantui-doc/package.json index 7a7e6872a..4da088d00 100644 --- a/packages/vantui-doc/package.json +++ b/packages/vantui-doc/package.json @@ -4,9 +4,9 @@ "version": "1.2.2", "description": "", "scripts": { - "dev": "node synch.js && npx vant-cli dev", + "dev": "node ./scripts/ts-to-md && npx vant-cli dev", "test:coverage": "open test/coverage/index.html", - "build": "node synch.js && sh ./build.sh", + "build": "node ./scripts/ts-to-md && sh ./build.sh", "release": "npx gh-pages -d site", "docs-ts": "node ./scripts/ts-to-md" },