Agent Skillsflutter/agent-plugins › dart-write-documentation

dart-write-documentation

GitHub

提供 Dart API 文档编写规范,指导生成符合 Effective Dart 标准的 /// 注释,涵盖结构、语气及反模式禁令。

skills/dart-write-documentation/SKILL.md flutter/agent-plugins

Trigger Scenarios

需要为 Dart 代码编写或更新文档时 要求遵循 Effective Dart 文档指南时

Install

npx skills add flutter/agent-plugins --skill dart-write-documentation -g -y
More Options

Use without installing

npx skills use flutter/agent-plugins@dart-write-documentation

指定 Agent (Claude Code)

npx skills add flutter/agent-plugins --skill dart-write-documentation -a claude-code -g -y

安装 repo 全部 skill

npx skills add flutter/agent-plugins --all -g -y

预览 repo 内 skill

npx skills add flutter/agent-plugins --list

SKILL.md

Frontmatter
{
    "name": "dart-write-documentation",
    "description": "Rules and formatting guidelines for writing Dart \/\/\/ API documentation and doc comments. Use when documenting Dart code, writing doc comments for any Dart declaration (libraries, classes, methods, variables, etc.), or when instructed to follow the Effective Dart documentation guidelines."
}

Writing Dart API Documentation

Contents

When asked to write or update documentation for Dart code, you must strictly follow these formatting rules based on the "Effective Dart: Documentation" guidelines.

1. Scope and Structure

  • Target Public APIs: Focus your documentation efforts on public declarations. Do not document private members (those starting with an underscore _) unless explicitly instructed, as they do not appear in generated API reference sites.
  • Always use ///: Use /// consecutive line comments for all API documentation. Never use /** ... */ block comments.
  • Proper Sentences: Format all comments like proper sentences. Capitalize the first word (unless it's a lowercase identifier) and end with a period.
  • The First Paragraph: The first paragraph of a doc comment must be a single, concise sentence that summarizes the element. End it with a period. Dartdoc extracts this verbatim for list views.
  • Separation: Always separate the first sentence summary from the rest of the documentation with a blank line containing ///. Never output a completely empty newline (e.g., a \n without ///), as this terminates the doc comment block.

2. Tone and Openers

  • Noun phrases for properties: Start descriptions of variables, getters, or setters with a noun phrase. /// The radius of the sphere. (Not "Gets the radius...")
  • "Whether" for booleans: Start documentation for boolean properties with "Whether". /// Whether the connection is active.
  • Third-person verbs for methods: Start descriptions of methods or functions with a third-person verb that describes what it does. /// Initializes the database. (Not "Initialize" or "This method initializes").
  • Avoid redundancy: Do not restate the signature or the element name. Do not say "This class is a..." or "The foo method does...".

3. Strict Anti-Patterns (Banned)

  • No Javadoc/TSDoc Tags (@param, @return, @throws, etc.): Never use Javadoc-style tags (@param, @return, @returns, @throws, @exception, @see, @type). Instead, weave parameter names, return behavior, and exceptions into the prose.

4. Technical Placement & Resolution

  • Annotations (@override, etc.): Doc comments must be placed before metadata annotations.
  • Inherited Documentation: Avoid duplicating doc comments on @override members if the behavior does not differ from the superclass or interface. Dartdoc automatically inherits the base documentation.
  • Getter/Setter Pairs: If a property has both a getter and a setter, place the documentation only on the getter. Tooling will emit a warning if both are documented.
  • Default Constructors: To link to a default, unnamed constructor in doc comments, you must use the .new syntax (e.g., [ClassName.new]).

5. Linking and Markdown

  • Square brackets ([identifier]) for in-scope symbols: Use square brackets to link to any in-scope identifier (parameters, classes, methods, fields, and top-level functions) so dartdoc can resolve them. Never use backticks for parameters.
  • No parentheses in method links: Avoid parentheses in links (e.g., use [String.contains], not [String.contains()]).
  • Backticks for keywords & literals: Use backticks for keywords, literals, and arbitrary expressions (e.g. `null`, `true`, `void`). Never put keywords in square brackets (avoid [null] or [true]).
  • Out-of-Scope Links: If you need to link to a symbol that is not imported by the current library, use the @docImport directive at the top of the file (on the library; declaration) rather than adding a standard import.
  • Code Blocks: For code samples, always label the language fence. Use ```dart for Dart, or ```sh for shell commands. Do not leave code blocks unlabelled, as Dartdoc will attempt to auto-detect the language and frequently guesses wrong.
  • Formatting: Use standard Markdown (bold, lists, etc.) after the first paragraph to fully explain edge cases, exceptions thrown, and internal behavior the caller cannot see.

6. Verification

After writing or updating doc comments:

  1. Run dart analyze to ensure all bracketed references resolve properly without triggering comment_references warnings.
  2. (Optional) Run dart doc to verify the generated documentation renders cleanly.

Examples

1. Banned Tags vs. Prose

Bad:

/// This method fetches data.
/// @param force true to force reload.
/// @return the data
/// @throws NetworkException if host is unreachable.
Data load(bool force) { ... }

Good:

/// Fetches the remote data.
///
/// If [force] is true, this bypasses the local cache and forces a
/// network request.
///
/// Throws a [NetworkException] if the host is unreachable.
Data load(bool force) { ... }

2. The Annotation Placement Trap

Bad:

@override
/// Renders the widget to the screen.
Widget build(BuildContext context) { ... }

Good:

/// Renders the widget to the screen.
@override
Widget build(BuildContext context) { ... }

3. Openers and Tone

Bad:

/// Gets if the connection is active.
bool get isActive => _active;

/// This method initializes the connection.
void init() { ... }

Good:

/// Whether the connection is active.
bool get isActive => _active;

/// Initializes the connection.
void init() { ... }

4. Constructor Linking

Bad:

/// Creates a new user. Similar to calling [User()].
User.create() { ... }

Good:

/// Creates a new user. Similar to calling [User.new].
User.create() { ... }

5. Out-of-Scope Links (@docImport)

Bad:

import 'package:http/http.dart'; // Adds unnecessary runtime dependency just for docs

/// To use this, you must pass a [Client].

Good:

/// @docImport 'package:http/http.dart';
library;

/// To use this, you must pass a [Client].

Version History

  • 864cf87 Current 2026-08-28 17:45

Same Skill Collection

.agents/agents/reidbaker-agent/skills/api-review/SKILL.md
.agents/agents/reidbaker-agent/skills/code-documentation/SKILL.md
.agents/agents/reidbaker-agent/skills/code-review/SKILL.md
.agents/agents/reidbaker-agent/skills/grill-with-docs/SKILL.md
.agents/agents/reidbaker-agent/skills/natural-writing/SKILL.md
.agents/agents/reidbaker-agent/skills/unix-cli-best-practices/SKILL.md
skills/dart-add-unit-test/SKILL.md
skills/dart-build-cli-app/SKILL.md
skills/dart-collect-coverage/SKILL.md
skills/dart-fix-runtime-errors/SKILL.md
skills/dart-generate-test-mocks/SKILL.md
skills/dart-migrate-to-checks-package/SKILL.md
skills/dart-resolve-package-conflicts/SKILL.md
skills/dart-run-static-analysis/SKILL.md
skills/dart-use-ffigen/SKILL.md
skills/dart-use-pattern-matching/SKILL.md
skills/dart-use-primary-constructors/SKILL.md
skills/flutter-add-integration-test/SKILL.md
skills/flutter-add-widget-preview/SKILL.md
skills/flutter-add-widget-test/SKILL.md
skills/flutter-apply-architecture-best-practices/SKILL.md
skills/flutter-build-responsive-layout/SKILL.md
skills/flutter-fix-layout-issues/SKILL.md
skills/flutter-implement-json-serialization/SKILL.md
skills/flutter-setup-declarative-routing/SKILL.md
skills/flutter-setup-localization/SKILL.md
skills/flutter-use-http-package/SKILL.md
tool/dart_skills_lint/.agents/skills/add-dart-lint-validation-rule/SKILL.md
tool/dart_skills_lint/.agents/skills/check-downstream-consumers/SKILL.md
tool/dart_skills_lint/.agents/skills/contributor-pr-description/SKILL.md
tool/dart_skills_lint/.agents/skills/dart-skills-lint-integration/SKILL.md
tool/dart_skills_lint/.agents/skills/definition-of-done/SKILL.md
tool/dart_skills_lint/.agents/skills/run-evals/SKILL.md
tool/dart_skills_lint/example/skills/invalid/SKILL.md
tool/dart_skills_lint/example/skills/valid/SKILL.md
tool/dart_skills_lint/skills/dart-skills-lint-setup/SKILL.md
tool/dart_skills_lint/skills/dart-skills-lint-validation/SKILL.md
skills/dart-setup-ffi-assets/SKILL.md

Metadata

Files
0
Version
864cf87
Hash
0629abbb
Indexed
2026-08-28 17:45

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-02 03:02
浙ICP备14020137号-1 $bản đồ khách truy cập$