mcpField
D
dart-doc-validation

dart-doc-validation

github.com/kevmoo测试与质量148286 次安装2 周前更新
代码仓库

关于 dart-doc-validation

该 Skill 面向维护 Dart 文档注释或准备发布到 pub.dev 的开发者,指导配置 lint、运行本地文档生成检查,并识别未解析引用和宏,同时说明不应修改的内容。

主要功能

  1. 01检查 Dart 文档引用
  2. 02启用 comment_references lint
  3. 03运行 dart doc 验证
  4. 04识别未定义宏
  5. 05避免修改排除的注释

适用场景

  1. 01发布前检查 Dart 文档注释
  2. 02查找包文档中的失效引用
  3. 03准备将包发布到 pub.dev

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/kevmoo/dash_skills --skill dart-doc-validation

安装后在 Claude Code 中输入/dart-doc-validation确认已加载。

附带文件evals/evals.json

详细介绍

Dart 文档验证

1. 何时使用此技能

在以下情况下使用此技能:

  • 在 Dart 代码中编写或更新文档注释(///)。
  • 检查文档链接、引用或宏是否失效。
  • 为发布到 pub.dev 做好软件包准备。
何时不应使用(弃用防护)

在以下情况下,不要应用此技能,也不要重构文档注释:

  • 示例伪代码和非 Dart 代码围栏:注释中包含 伪代码、非 Dart 语言标识符(例如 yaml`、json、````bash, ````text`), or abstract conceptual fragments intentionally not designed to compile as valid Dart.
  • Generated Code: Files generated by tools (e.g. *.g.dart, *.mocks.dart, *.freezed.dart) where comments are synthesized.
  • External Markdown Hyperlinks: Text in square brackets followed by a link target (e.g. [External Guide](https://...)), which is standard Markdown hyperlink syntax rather than an unresolved Dart doc reference.

Discovery

To find documentation issues:

Missing Lint

Verify if the comment_references lint is enabled:

  • Target: analysis_options.yaml
  • Search Query: comment_references
Automated Validation

Run the documentation generator to surface warnings:

  • Command: dart doc -o $(mktemp -d)
  • Keywords to look for: warning:, unresolved doc reference, undefined macro

2. Best Practices

Enable the doc validation lint

In your analysis_options.yaml, enable the comment_references lint.

linter:
  rules:
    - comment_references
Validating Documentation Locally

Use the dart doc command with a temporary output directory to validate documentation comments without polluting the local project workspace.

This command parses all documentation comments and reports warnings such as:

  • warning: unresolved doc reference
  • warning: undefined macro

Command to run:

dart doc -o $(mktemp -d)

This will work on Mac and Linux.

This ensures that the generated HTML files are stored in a temporary location and don't clutter the package directory, while still surfacing all validation warnings in the terminal output.

Browsing the docs:

Our docs use features designed to be run on a web server. If you want to browse the generated docs locally, install the dhttpd package.

dart install dhttpd
TMP_DIR=$(mktemp -d) && dart doc -o "$TMP_DIR" &&  dhttpd --path "$TMP_DIR"

(Or use another HTTP server, such as python3 -m http.server.)

Fixing Common Warnings
  • Unresolved doc reference: Ensure that any identifier wrapped in square brackets ([Identifier]) correctly points to an existing class, method, property, or parameter in the current scope or imported libraries.
  • Undefined macro: If using {@macro macro_name}, ensure that the template {@template macro_name} is defined in the same file or a file that is imported and visible to the documentation generator.

评论

支持 Markdown