docs: simplify with regex of component log (#43995)

This commit is contained in:
二货爱吃白萝卜 2023-08-03 16:30:55 +08:00 committed by GitHub
parent 3fa4f76cd9
commit 700cb6af8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 19 deletions

View File

@ -20,25 +20,12 @@ const camelComponentNames = componentNames.map((componentName) =>
.join(''),
);
function fillComponentKey(componentName: string) {
return [
` ${componentName} `,
` ${componentName}.`,
` ${componentName},`,
` ${componentName}`,
` ${componentName}`,
` ${componentName}`,
` ${componentName})`,
` ${componentName}`,
` ${componentName}'`,
` ${componentName}/`,
`\`${componentName}\``,
`\`${componentName}.`,
];
function fillComponentKey(componentName: string): RegExp[] {
return [new RegExp(`\\b${componentName}\\b`)];
}
// Convert a mapping logic
const componentNameMap: Record<string, string[]> = {};
const componentNameMap: Record<string, (string | RegExp)[]> = {};
camelComponentNames.forEach((name) => {
componentNameMap[name] = [...fillComponentKey(name), 'Global:'];
});
@ -157,7 +144,14 @@ const miscKeys = [
Object.keys(componentNameMap).forEach((name) => {
const matchKeys = componentNameMap[name];
if (matchKeys.some((key) => line.includes(key))) {
if (
matchKeys.some((key) => {
if (typeof key === 'string') {
return line.includes(key);
}
return key.test(line);
})
) {
componentChangelog[name].push({
version: lastVersion,
changelog: changelogLine,

View File

@ -49,7 +49,6 @@ exports[`component changelog match snapshot misc changelog snapshot 1`] = `
"- 📦 在构建流程中去掉对 IE 等旧版本浏览器的支持以减少包体积。[#38779](https://github.com/ant-design/ant-design/pull/38779)",
"- 🐞 Design Token 修复组件字体错误问题。[#39806](https://github.com/ant-design/ant-design/pull/39806)",
" - 🤖 修复部分 Design Token 缺少类型提示的问题。[#39754](https://github.com/ant-design/ant-design/pull/39754)",
"- 🛠 LocaleProvider 在 4.x 中已经废弃(使用 \`<ConfigProvider locale />\` 替代),我们在 5.x 里彻底移除了相关目录 antd/es/locale-provider、antd/lib/locale-provider。[#39373](https://github.com/ant-design/ant-design/pull/39373)",
"- 🛠 简化 lodash 方法引用。[#39599](https://github.com/ant-design/ant-design/pull/39599) [#39602](https://github.com/ant-design/ant-design/pull/39602)",
" - 🇧🇪 补全 \`fr_BE\` 文案。[#39415](https://github.com/ant-design/ant-design/pull/39415) [@azro352](https://github.com/azro352)",
" - 🇨🇦 补全 \`fr_CA\` 文案。[#39416](https://github.com/ant-design/ant-design/pull/39416) [@azro352](https://github.com/azro352)",
@ -113,7 +112,6 @@ exports[`component changelog match snapshot misc changelog snapshot 1`] = `
"- 📦 Remove IE and other legacy browsers from browserslist to reduce bundle size.[#38779](https://github.com/ant-design/ant-design/pull/38779)",
"- 🐞 Fix Design Token wrong \`font-family\` of components. [#39806](https://github.com/ant-design/ant-design/pull/39806)",
" - 🤖 Fix missing type defination for Design Token. [#39754](https://github.com/ant-design/ant-design/pull/39754)",
"- 🛠 LocaleProvider has been deprecated in 4.x (use \`<ConfigProvider locale />\` instead), we removed the related folder antd/es/locale-provider and antd/lib/locale-provider in 5.x. [#39373](https://github.com/ant-design/ant-design/pull/39373)",
"- 🛠 Simplified lodash method introduction. [#39599](https://github.com/ant-design/ant-design/pull/39599) [#39602](https://github.com/ant-design/ant-design/pull/39602)",
" - 🇧🇪 Add \`fr_BE\` locale. [#39415](https://github.com/ant-design/ant-design/pull/39415) [@azro352](https://github.com/azro352)",
" - 🇨🇦 Add \`fr_CA\` locale. [#39416](https://github.com/ant-design/ant-design/pull/39416) [@azro352](https://github.com/azro352)",