oh-doc-knowledge-verifier
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese文档知识正确性验证
Documentation Knowledge Correctness Validation
Task and Boundaries
Task and Boundaries
验证 OpenHarmony API 文档中的知识性描述是否正确。这类问题主要与代码实现无关,而是文档本身对标准规范、数学定义、技术概念的描述存在错误。
核心工作流:知识验证(对照权威标准)→ 发现问题 → 代码实现二次验证(对照业务代码)→ 判定根因。
适用范围:
- 文档中对标准规范属性/参数的描述(如 SVG transform、CSS 属性等)
- 文档中对数学定义的描述(如变换矩阵、颜色空间、插值公式等)
- 文档中对技术概念的描述(如渲染管线、动画原理等)
- 当知识验证发现文档与标准不一致时,进一步对照业务代码确定实际行为,区分根因类型
不适用:
- 纯代码逻辑层面的"代码与文档不一致"问题
- 文档结构、模板、标签等格式问题
- SDK d.ts 类型定义与文档的一致性
Validate whether the knowledge-based descriptions in OpenHarmony API documentation are correct. Such issues are generally unrelated to code implementation; instead, the documentation itself contains errors in its descriptions of standards and specifications, mathematical definitions, or technical concepts.
Core workflow: Knowledge validation (comparison against authoritative standards) → Identify the issue → Secondary code implementation validation (comparison against implementation code) → Determine the root cause.
Applicable scope:
- Descriptions of attributes or parameters defined by standards and specifications, such as SVG transform and CSS properties
- Descriptions of mathematical definitions, such as transformation matrices, color spaces, and interpolation formulas
- Descriptions of technical concepts, such as rendering pipelines and animation principles
- When knowledge validation finds an inconsistency between the documentation and a standard, further compare it with the implementation code to determine the actual behavior and identify the root-cause type
Not applicable:
- Pure code-logic issues involving a "code and documentation inconsistency"
- Documentation structure, template, tag, or other formatting issues
- Consistency between SDK d.ts type definitions and documentation
Trigger Signals
Trigger Signals
- "文档描述是否准确"
- "这个参数说明对不对"
- "文档里说 X,但标准里是 Y"
- "帮我看下这个描述有没有写反"
- "文档纠错"、"描述验证"
- "文档与代码对照"、"看下代码是不是这样实现的"
- "标准说 X,文档说 Y,代码实际是什么"
- "Is this description in the documentation accurate?"
- "Is this parameter description correct?"
- "The documentation says X, but the standard says Y"
- "Check whether this description has the two meanings reversed"
- "Documentation correction" or "description validation"
- "Documentation-to-code comparison" or "Check whether the code implements it this way"
- "The standard says X, the documentation says Y, and what does the code actually do?"
Initial Checks
Initial Checks
- 获取验证目标:用户提供文档片段或属性名 + 具体描述
- 定位文档文件:在文档仓库下搜索
- 提取可验证声明:从文档中识别出所有可验证的知识性陈述
- Obtain the validation target: The user provides a documentation excerpt or an attribute name together with the specific description
- Locate the documentation file: Search the documentation repository
- Extract verifiable claims: Identify all verifiable knowledge-based statements in the documentation
Execution Strategy
Execution Strategy
步骤 1:声明分类
Step 1: Claim Classification
对每条文档声明判断其知识来源类型,不同类型使用不同的验证源:
| 类型 | 特征 | 验证源 |
|---|---|---|
| 标准规范型 | 行为由外部标准(W3C、CSS、IEEE 等)定义 | 标准规范原文 |
| 数学事实型 | 由数学定义决定,不存在歧义 | 数学公式/定义 |
| 竞品对标型 | 同类平台通用行为,多家实现一致 | Android/iOS/Chrome 等文档交叉验证 |
分类判断规则:
- 如果属性/参数来自 W3C 标准(SVG、CSS、DOM 等) → 标准规范型
- 如果描述涉及数学公式、矩阵运算、几何变换 → 数学事实型
- 如果描述的是平台通用行为且无标准约束 → 竞品对标型
- 不确定时,默认按标准规范型处理,尝试查找对应标准
For each documentation claim, determine the type of its knowledge source and use the corresponding validation source:
| Type | Characteristics | Validation Source |
|---|---|---|
| Standard-specification type | The behavior is defined by an external standard or specification (W3C, CSS, IEEE, etc.) | The original standard or specification |
| Mathematical-fact type | The claim is determined by a mathematical definition and is unambiguous | Mathematical formulas or definitions |
| Competitive-benchmark type | The claim describes behavior common across similar platforms and consistently implemented by multiple vendors | Cross-validation against Android, iOS, Chrome, and other documentation |
Classification rules:
- If an attribute or parameter comes from a W3C standard, such as SVG, CSS, or DOM, classify it as standard-specification type
- If the description involves mathematical formulas, matrix operations, or geometric transformations, classify it as mathematical-fact type
- If the description concerns common platform behavior that is not governed by a standard, classify it as competitive-benchmark type
- When uncertain, default to standard-specification type and attempt to locate the corresponding standard
步骤 2:查找权威验证源
Step 2: Locate Authoritative Validation Sources
按声明类型查找验证源:
标准规范型:
- W3C SVG 规范:
https://www.w3.org/TR/SVG/ - CSS 规范:
https://www.w3.org/Style/CSS/ - Web API 规范:(MDN 作为标准参考)
https://developer.mozilla.org/ - 使用 WebSearch 搜索
{属性名} W3C specification
数学事实型:
- 使用 WebSearch 搜索
{概念} mathematical definition - 对比多个来源确认数学定义的一致性
竞品对标型:
- Android:
https://developer.android.com/ - iOS:
https://developer.apple.com/ - Web:
https://developer.mozilla.org/ - Flutter:
https://api.flutter.dev/
Locate validation sources according to the claim type:
Standard-specification type:
- W3C SVG specification:
https://www.w3.org/TR/SVG/ - CSS specifications:
https://www.w3.org/Style/CSS/ - Web API specifications: (use MDN as a standards reference)
https://developer.mozilla.org/ - Use WebSearch to search for
{property name} W3C specification
Mathematical-fact type:
- Use WebSearch to search for
{concept} mathematical definition - Compare multiple sources to confirm that the mathematical definition is consistent
Competitive-benchmark type:
- Android:
https://developer.android.com/ - iOS:
https://developer.apple.com/ - Web:
https://developer.mozilla.org/ - Flutter:
https://api.flutter.dev/
步骤 3:逐条对比
Step 3: Compare Claim by Claim
对每条声明进行对比验证:
文档描述 → 权威验证源描述 → 是否一致重点关注的高频错误模式:
- 参数作用写反:两个参数的描述互换(如 SVG matrix 的 b/c)
- 方向描述错误:x/y 方向搞反、顺时针/逆时针搞反
- 类型描述错误:整数写成浮点、百分比写成像素等
- 默认值错误:默认值与标准不符
- 枚举值遗漏或错误:遗漏标准枚举值或写错值名
- 作用域描述过宽或过窄:描述的适用范围与标准不符
Compare each claim against its validation source:
Documentation description → Authoritative validation source description → Consistent?Common high-frequency error patterns:
- Parameter roles written in reverse: The descriptions of two parameters are swapped, such as the b/c values of an SVG matrix
- Incorrect direction: The x/y direction or clockwise/counterclockwise direction is reversed
- Incorrect type description: An integer is described as a floating-point value, a percentage as pixels, and so on
- Incorrect default value: The default value differs from the standard
- Missing or incorrect enumeration value: A standard enumeration value is omitted or assigned the wrong name
- Scope described too broadly or too narrowly: The stated applicability differs from the standard
步骤 4:代码实现二次验证(条件触发)
Step 4: Secondary Code Implementation Validation (Conditionally Triggered)
触发条件: 当步骤 3 发现文档与权威标准不一致时,必须进一步对照业务代码实现,区分根因类型。
核心目的: 仅靠标准对比无法判断是"文档写错了"还是"代码实现错了"——必须看代码实际行为才能下结论。同一份文档可能有三种根因:
| 根因类型 | 文档 | 标准 | 代码 | 处置 |
|---|---|---|---|---|
| A. 文档错误 | ✗ | ✓ | ✓ | 改文档 |
| B. 代码错误 | ✓ | ✗ | ✗ | 改代码 |
| C. 三方不一致 | ✗ | ✓ | ✗ | 改文档+改代码,并明确文档对齐代码还是标准 |
| D. 平台有意扩展 | ✗ | ✓ | ✗(刻意) | 文档补充"扩展说明" |
验证流程:
- 定位代码仓
- 四层追踪:
- 入口层(前端桥接):
frameworks/bridge/declarative_frontend/jsview/ - 数据层(属性存储):、
frameworks/core/components_ng/property/frameworks/core/components/common/properties/ - 处理层(校验/钳位):、
frameworks/core/components_ng/render/frameworks/core/components/common/painter/ - 渲染层(绘制修正):
frameworks/core/components_ng/render/adapter/
- 入口层(前端桥接):
- 比对代码实际值:找到默认值初始化、钳位逻辑、回退分支
- 判定根因:根据上表归类
代码追踪必须给出:
- 具体文件路径和行号(如 )
js_view_abstract.cpp:2198 - 关键代码片段(默认值赋值、条件分支、钳位逻辑)
- 实际输出值(数据层 + 渲染层叠加结果)
禁止的做法:
- 禁止仅凭标准结论就判定"文档错误"——必须确认代码是否与标准一致
- 禁止忽略 API 版本条件分支——等判断可能导致不同 API 版本默认值不同
PlatformVersion::VERSION_TEN
Trigger condition: When Step 3 finds an inconsistency between the documentation and an authoritative standard, it is mandatory to compare the implementation code to distinguish the root-cause type.
Core purpose: A comparison against the standard alone cannot determine whether the documentation or the implementation is incorrect. The code's actual behavior must be examined before drawing a conclusion. A single document may have one of four root causes:
| Root-Cause Type | Documentation | Standard | Code | Resolution |
|---|---|---|---|---|
| A. Documentation error | ✗ | ✓ | ✓ | Update the documentation |
| B. Code error | ✓ | ✗ | ✗ | Update the code |
| C. Three-way inconsistency | ✗ | ✓ | ✗ | Update both the documentation and code, and explicitly state whether the documentation should align with the code or the standard |
| D. Intentional platform extension | ✗ | ✓ | ✗ (intentional) | Add an "extension note" to the documentation |
Validation workflow:
- Locate the code repository
- Trace through four layers:
- Entry layer (frontend bridge):
frameworks/bridge/declarative_frontend/jsview/ - Data layer (property storage): ,
frameworks/core/components_ng/property/frameworks/core/components/common/properties/ - Processing layer (validation/clamping): ,
frameworks/core/components_ng/render/frameworks/core/components/common/painter/ - Rendering layer (drawing correction):
frameworks/core/components_ng/render/adapter/
- Entry layer (frontend bridge):
- Compare actual values in the code: Locate default-value initialization, clamping logic, and fallback branches
- Determine the root cause: Classify it according to the table above
Code tracing must provide:
- Specific file paths and line numbers, such as
js_view_abstract.cpp:2198 - Key code snippets, including default-value assignments, conditional branches, and clamping logic
- Actual output values, including the combined result of the data and rendering layers
Prohibited practices:
- Do not use the code implementation as the sole validation source for standard-specification claims. The code may contain bugs or deviations, while the standard is authoritative
- Do not classify an issue as a "documentation error" solely from the standard comparison. When a knowledge inconsistency is found, inspect the code to confirm the actual behavior, distinguish the root-cause type (A/B/C/D), and then decide whether to update the documentation or the code
- Do not determine parameter meanings from memory. In particular, mathematical concepts such as matrices and transformations must be checked against their definitions
- Do not ignore differences between standard versions. SVG 1.1 and SVG 2, for example, may differ, so the version referenced by the documentation must be confirmed
步骤 5:生成报告
Step 5: Generate the Report
markdown
undefinedmarkdown
undefined文档知识验证报告
Documentation Knowledge Validation Report
验证目标
Validation Target
- 文档:{文件名}
- 章节:{章节名}
- Documentation: {file name}
- Section: {section name}
声明验证
Claim Validation
| # | 文档描述 | 声明类型 | 验证源 | 验证源内容 | 判定 |
|---|---|---|---|---|---|
| 1 | {原文} | {类型} | {来源} | {正确描述} | {一致/不一致} |
| # | Documentation Description | Claim Type | Validation Source | Validation Source Content | Verdict |
|---|---|---|---|---|---|
| 1 | {original text} | {type} | {source} | {correct description} | {consistent/inconsistent} |
代码二次验证(仅不一致项)
Secondary Code Validation (inconsistent claims only)
| # | 文档描述 | 标准规定 | 代码实际 | 根因类型 |
|---|---|---|---|---|
| 1 | {原文} | {标准} | {代码值} | {A/B/C/D} |
代码追踪证据:
| 层级 | 文件:行号 | 关键逻辑 | 输出值 |
|---|---|---|---|
| 入口层 | {path}:{line} | {代码片段} | — |
| 数据层 | {path}:{line} | {代码片段} | {值} |
| 处理层 | {path}:{line} | {代码片段} | {值} |
| # | Documentation Description | Standard Specification | Actual Code Behavior | Root-Cause Type |
|---|---|---|---|---|
| 1 | {original text} | {standard} | {code value} | {A/B/C/D} |
Code tracing evidence:
| Layer | File:Line | Key Logic | Output Value |
|---|---|---|---|
| Entry layer | {path}:{line} | {code snippet} | — |
| Data layer | {path}:{line} | {code snippet} | {value} |
| Processing layer | {path}:{line} | {code snippet} | {value} |
错误详情(如有)
Error Details (if any)
错误 #1:{根因类型}
- 文档位置:{文件:行号}
- 文档描述:{原文}
- 标准描述:{标准内容}
- 代码实际:{代码行为}
- 验证依据:{标准链接 + 代码文件:行号}
Error #1: {root-cause type}
- Documentation location: {file:line}
- Documentation description: {original text}
- Standard description: {standard content}
- Actual code behavior: {code behavior}
- Verification basis: {standard link + code file:line}
修正建议
Correction Recommendations
{根据根因类型给出针对性建议:
- A 类:改文档对齐标准
- B 类:建议提单改代码
- C 类:分别说明文档/代码的修正方向
- D 类:文档补充"OpenHarmony 相对标准的扩展说明"}
undefined{Provide targeted recommendations based on the root-cause type:
- Type A: Update the documentation to align with the standard
- Type B: File a ticket to update the code
- Type C: Explain the documentation and code correction directions separately
- Type D: Add an "OpenHarmony extension relative to the standard" note to the documentation}
undefined高频错误模式速查
High-Frequency Error Pattern Quick Reference
当需要快速判断常见错误类型时,读取 references/common-errors.md
| 错误模式 | 典型表现 | 检查方法 |
|---|---|---|
| 参数作用互换 | 两个参数描述写反 | 对比标准定义中每个参数的数学含义 |
| 方向描述错误 | x/y、水平/垂直、顺时针/逆时针搞反 | 查标准定义,数学公式无歧义 |
| 顺序/索引错误 | 参数位置与标准不一致 | 对比标准函数签名的参数顺序 |
| 类型与值域错误 | 取值范围或数据类型描述错误 | 查标准中的类型定义和约束条件 |
To quickly identify common error types, read references/common-errors.md.
| Error Pattern | Typical Manifestation | Inspection Method |
|---|---|---|
| Swapped parameter roles | The descriptions of two parameters are reversed | Compare the mathematical meaning of each parameter with the standard definition |
| Incorrect direction description | The x/y, horizontal/vertical, or clockwise/counterclockwise direction is reversed | Check the standard definition; mathematical formulas are unambiguous |
| Incorrect order or index | The parameter position differs from the standard | Compare the parameter order in the standard function signature |
| Incorrect type or value range | The data type or allowed value range is described incorrectly | Check the type definitions and constraints in the standard |
Prohibited Practices
Prohibited Practices
- 禁止用代码实现作为标准规范型声明的唯一验证源:代码可能有 bug 或偏差,标准才是权威
- 禁止仅凭标准结论就判定"文档错误":发现知识不一致时,必须先看代码确认实际行为,区分根因类型(A/B/C/D),再决定改文档还是改代码
- 禁止凭记忆判断参数含义:特别是矩阵、变换等数学概念,必须查定义
- 禁止忽略标准版本差异:SVG 1.1 和 SVG 2 可能有差异,需确认文档引用的版本
- 禁止将竞品文档等同于标准:竞品文档也可能有错,仅作交叉参考
- Do not use the code implementation as the sole validation source for standard-specification claims: The code may contain bugs or deviations, while the standard is authoritative
- Do not classify an issue as a "documentation error" solely from the standard comparison: When a knowledge inconsistency is found, inspect the code to confirm the actual behavior, distinguish the root-cause type (A/B/C/D), and then decide whether to update the documentation or the code
- Do not determine parameter meanings from memory: In particular, mathematical concepts such as matrices and transformations must be checked against their definitions
- Do not ignore differences between standard versions: SVG 1.1 and SVG 2 may differ, so the version referenced by the documentation must be confirmed
- Do not treat competitor documentation as equivalent to a standard: Competitor documentation may also contain errors and should be used only as a cross-reference
Exceptions and Fallbacks
Exceptions and Fallbacks
- 找不到对应标准:扩展搜索范围,或使用竞品文档 + 数学定义交叉验证,并在报告中标注验证置信度
- 标准描述模糊:列出多种可能的理解,分别验证
- 标准版本冲突:以最新正式版标准为准
- 代码路径无法追踪:明确告知用户无法验证,并列出已搜索的路径;不要凭推测下结论
- 代码刻意扩展标准(D 类):文档应补充"OpenHarmony 相对标准的扩展说明",而非强制对齐标准
- No corresponding standard can be found: Expand the search scope or cross-validate against competitor documentation and mathematical definitions, and report the validation confidence level
- The standard description is ambiguous: List the possible interpretations and validate each one
- Standard versions conflict: Use the latest official version of the standard
- The code path cannot be traced: Clearly inform the user that validation was not possible and list the paths that were searched; do not draw conclusions based on speculation
- The code intentionally extends the standard (Type D): Add an "OpenHarmony extension relative to the standard" note to the documentation instead of requiring alignment with the standard
References
References
- references/common-errors.md — 高频文档错误模式库,当需要快速识别常见错误类型时读取
- references/common-errors.md — A library of common documentation error patterns; read it when you need to quickly identify common error types