Skip to content

fix: extract embedded shared component props - #213

Open
QDyanbing wants to merge 4 commits into
ant-design:mainfrom
QDyanbing:fix-tooltip-shared-props
Open

fix: extract embedded shared component props#213
QDyanbing wants to merge 4 commits into
ant-design:mainfrom
QDyanbing:fix-tooltip-shared-props

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Aug 6, 2026

Copy link
Copy Markdown
Member

背景

antd 的 Tooltip、Popover、Popconfirm 等组件通过 dumi embed 复用共享 API 表,当前提取器未展开嵌入文件,导致 antd info Tooltip --version 6.4.5 漏掉共享属性。

改动

  • 递归展开本地 dumi embed,并限制在 antd 源码目录内、避免循环引用
  • 统一中英文共享 API 标题,合并组件专属属性与共享属性
  • 组件专属非空字段优先,共享定义只补齐空缺字段,同时保留合法的重复定义
  • 回填受影响的 v5/v6 历史元数据并更新 changelog 快照
  • 增加提取器回归测试并更新 spec.md

验证

  • npm run typecheck
  • npm run build
  • npm test -- --coverage(51 个测试文件、694 个测试全部通过)
  • git diff --check

Summary by CodeRabbit

  • 文档
    • 完善 Popconfirm、Popover 和 Tooltip 的属性 API 文档,涵盖内容、按钮、定位、触发、显隐、样式、生命周期及回调等配置。
    • 补充默认值、版本、弃用状态及中英文说明,并修正部分无效元数据。
    • 完善 Skeleton 的 widthclassNamesstyles 和动画相关文档。
  • 改进
    • API 提取支持嵌入文档、共享属性合并及中英文属性解析。
    • 增强属性字段补全、重复属性处理和安全的文件引用校验。

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b3b63cc8-6e65-464a-a65f-cd0aa058bb1b

📥 Commits

Reviewing files that changed from the base of the PR and between 1d4bf53 and 1a3d011.

📒 Files selected for processing (5)
  • data/v6.5.4.json
  • data/v6.json
  • scripts/extractors/__tests__/props.test.ts
  • scripts/extractors/props.ts
  • spec.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • spec.md
  • scripts/extractors/tests/props.test.ts
  • data/v6.json

📝 Walkthrough

Walkthrough

本次变更扩展 API 提取器,支持递归解析本地 embed 文档和共享属性合并。多个 v5、v6 数据文件补充 Popconfirm、Popover、Tooltip 与 Skeleton 的属性元数据,并修正文案、类型和版本字段。

Changes

API 提取与验证

Layer / File(s) Summary
共享 API 展开与属性合并
scripts/extractors/props.ts, spec.md
提取器支持 Default value 表头、共享分区规范化、递归嵌入、本地路径限制、双语属性匹配、字段回填和重复属性保留。
提取器集成测试
scripts/extractors/__tests__/props.test.ts
测试覆盖中英文文档、共享属性、递归嵌入、字段补全、重复 width、子组件属性、无标题嵌入和源目录外符号链接。

v5 浮层属性文档

Layer / File(s) Summary
Popconfirm、Popover 与 Tooltip 属性元数据
data/v5.22.7.json, data/v5.23.4.json, data/v5.24.9.json, data/v5.25.4.json, data/v5.26.7.json, data/v5.27.6.json, data/v5.28.1.json, data/v5.29.3.json, data/v5.json
补充按钮、内容、定位、箭头、触发、显隐、样式、销毁、缓存、层级和回调属性。补充默认值、版本和弃用信息,并移除无效的 since: "-"

v6 组件与浮层文档

Layer / File(s) Summary
Popconfirm、Popover 与 Tooltip 属性元数据
data/v6.0.1.json, data/v6.1.4.json, data/v6.2.3.json, data/v6.3.7.json, data/v6.4.5.json, data/v6.5.4.json, data/v6.json
补充浮层组件的内容、按钮、定位、触发、显隐、样式、生命周期和回调属性,并清理无效版本字段。
Skeleton 属性与文案修正
data/v6.0.1.json, data/v6.1.4.json, data/v6.2.3.json, data/v6.3.7.json, data/v6.4.5.json, data/v6.5.4.json, data/v6.json
新增 classNamesstyles,将标题 width 类型收窄为 `number

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • ant-design/ant-design-cli#132:相关提取器和运行时回填逻辑用于恢复及验证本次补充的 Popconfirm、Popover 和 Tooltip 属性数据。

Suggested reviewers: afc163

Poem

我是小兔,抱来 API 胡萝卜,
Popconfirm 和 Popover 排好队,
Tooltip 的属性闪闪发光,
Skeleton 也穿上新衣裳。
嵌入文档一路展开,
测试守住每个小月亮。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了提取嵌入式共享组件属性这一核心修复,与代码变更和 PR 目标一致。
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from afc163 August 6, 2026 01:56
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.69%. Comparing base (12c192d) to head (1a3d011).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #213   +/-   ##
=======================================
  Coverage   99.69%   99.69%           
=======================================
  Files          40       40           
  Lines        2599     2599           
  Branches      801      801           
=======================================
  Hits         2591     2591           
  Misses          8        8           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 17

🧹 Nitpick comments (1)
scripts/extractors/__tests__/props.test.ts (1)

89-209: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

补充递归 embed 和循环引用的回归测试。

当前 fixture 只验证一级 <embed>。它不能验证嵌套共享文件会被展开,也不能验证循环引用会安全终止。

让共享文件再嵌入一个属性文件,并让该属性文件引用上层文件。断言嵌套属性只出现一次,且 extractProps 正常返回。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/extractors/__tests__/props.test.ts` around lines 89 - 209, 扩展现有
extractProps 回归测试的 fixture:让 sharedProps 文件嵌入另一个属性文件,并让该属性文件反向引用上层共享文件,覆盖嵌套
embed 与循环引用场景。更新期望结果,断言嵌套属性仅展开一次且不会因循环引用重复或失控,同时保留现有属性、重复字段及子组件断言,确认
extractProps 能正常返回。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@data/v5.23.4.json`:
- Around line 13890-13930: Update the Popconfirm API metadata defaults for
cancelText, disabled, icon, okText, and okType from "-" to Cancel, false, the
ExclamationCircle icon, OK, and primary respectively, matching antd 5.23.4.

In `@data/v5.24.9.json`:
- Around line 13936-13984: 更新 Popconfirm 元数据中
cancelText、disabled、icon、okText、okType 和 showCancel 的 default 值,分别记录为
`Cancel`、false、<ExclamationCircle />、`OK`、`primary` 和 true,替换当前的 `-`,其余字段保持不变。

In `@data/v5.25.4.json`:
- Around line 14171-14218: 更新 Popconfirm 元数据中
cancelText、disabled、icon、okText、okType 和 showCancel 的 default 字段,分别恢复为
Cancel、false、<ExclamationCircle />、OK、primary 和 true;仅修改这些属性的默认值,保持其他描述和字段不变。

In `@data/v5.26.7.json`:
- Around line 14183-14194: 在 Popconfirm 属性定义中恢复默认值:将
cancelText、disabled、icon、okText、okType 和 showCancel 分别设置为
Cancel、false、<ExclamationCircle />、OK、primary 和 true,替换当前的 "-" 占位值。

In `@data/v5.27.6.json`:
- Around line 14242-14289: Update the Popconfirm API entries for cancelText,
disabled, icon, okText, okType, and showCancel to use their actual defaults:
`Cancel`, false, <ExclamationCircle />, `OK`, `primary`, and true respectively,
while leaving the existing descriptions unchanged.

In `@data/v5.28.1.json`:
- Around line 14235-14283: Update the Popconfirm metadata entries for
cancelText, disabled, icon, okText, okType, and showCancel to use the upstream
v5.28.1 default values: "Cancel", "false", "<ExclamationCircle />", "OK",
"`primary`", and "true", respectively, replacing each "-" placeholder.

In `@data/v6.0.1.json`:
- Around line 16174-16199: 更新 Popover
属性提取器的共享属性合并逻辑:合并组件专属属性与共享属性时,若名称已存在于组件专属记录中,则跳过对应共享记录,并优先保留组件专属的非空字段。仅过滤共享属性中的重复项,不要去重组件专属表内合法的同名条目,确保
classNames 和 styles 各只输出一次。
- Around line 19416-19419: 更新 data/v6.0.1.json 中 width 配置项的
descriptionZh,将其改为与英文 “Set the width of title” 及当前 number | string
类型一致的标题宽度说明,移除段落占位图和数组行为描述。

In `@data/v6.1.4.json`:
- Around line 19450-19454: Update the descriptionZh field for
SkeletonTitleProps.width to describe the title placeholder width, removing the
incorrect paragraph-placeholder wording and all array-specific behavior.
- Around line 16258-16263: Remove the duplicate classNames property from the
Popover props metadata, retaining the existing definition in the earlier props
entry. Update the extraction/merge deduplication logic to enforce uniqueness by
property name so repeated classNames entries are not emitted in generated API
metadata or documentation.

In `@data/v6.2.3.json`:
- Around line 16230-16235: Remove the later duplicate Popover semantic-property
entries for classNames and styles, retaining the earlier definitions. Update the
merge/generation logic to deduplicate entries by name so regeneration does not
reintroduce these duplicate API records.
- Around line 19489-19492: 更新 width 配置项的
descriptionZh,使其仅描述标题占位图的宽度,并移除数组及按行宽度相关表述;保持与 type 为 number | string 及英文
description 的语义一致。

In `@data/v6.4.5.json`:
- Around line 20874-20875: 删除该条目中的 since 字段,并移除 descriptionZh
行末的逗号;未标注版本时保持字段省略,不要替换为空字符串或连字符。

In `@data/v6.5.3.json`:
- Around line 21166-21167: 删除 active 条目中的 since 字段,不要保留 "-"
占位值;确保该条目在没有上游版本标签时省略 since 元数据。

In `@data/v6.json`:
- Around line 21166-21167: 删除 data/v6.json 中该条目值为 "-" 的 since
字段;上游未标注版本时省略字段,不要保留占位符。
- Around line 18036-18041: Remove the duplicate styles property entry from the
Popover props definition in components[42], keeping only one complete styles
record with its existing metadata and description so the generated documentation
lists the property once.

In `@scripts/extractors/props.ts`:
- Around line 234-266: Update readMarkdownWithEmbeds to resolve both rootDir and
filePath with fs.realpathSync before path.relative checks and cycle detection,
so symlinked embeds outside the root are rejected. Use the canonical resolved
file path for subsequent existence, reading, recursion, and stack tracking while
preserving the existing empty-string behavior for invalid or cyclic references.

---

Nitpick comments:
In `@scripts/extractors/__tests__/props.test.ts`:
- Around line 89-209: 扩展现有 extractProps 回归测试的 fixture:让 sharedProps
文件嵌入另一个属性文件,并让该属性文件反向引用上层共享文件,覆盖嵌套 embed
与循环引用场景。更新期望结果,断言嵌套属性仅展开一次且不会因循环引用重复或失控,同时保留现有属性、重复字段及子组件断言,确认 extractProps
能正常返回。
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8238f26c-9a36-49cd-b2f6-b7d590b80ff6

📥 Commits

Reviewing files that changed from the base of the PR and between ed1422e and 537163d.

⛔ Files ignored due to path filters (1)
  • src/__tests__/snapshots/__snapshots__/changelog.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (19)
  • data/v5.22.7.json
  • data/v5.23.4.json
  • data/v5.24.9.json
  • data/v5.25.4.json
  • data/v5.26.7.json
  • data/v5.27.6.json
  • data/v5.28.1.json
  • data/v5.29.3.json
  • data/v5.json
  • data/v6.0.1.json
  • data/v6.1.4.json
  • data/v6.2.3.json
  • data/v6.3.7.json
  • data/v6.4.5.json
  • data/v6.5.3.json
  • data/v6.json
  • scripts/extractors/__tests__/props.test.ts
  • scripts/extractors/props.ts
  • spec.md

Comment thread data/v5.23.4.json
Comment thread data/v5.24.9.json
Comment thread data/v5.25.4.json
Comment thread data/v5.26.7.json
Comment thread data/v5.27.6.json
Comment thread data/v6.4.5.json Outdated
Comment thread data/v6.5.3.json Outdated
Comment thread data/v6.json Outdated
Comment thread data/v6.json Outdated
Comment thread scripts/extractors/props.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants