code-documentation

作成者: flutter

効果的なコードドキュメントを書くためのガイド。docstring、JSDoc、dartdoc、実装コメントを含む。新しいコードを書く際や追加する際にこのスキルを使用する。

npx skills add https://github.com/flutter/agent-plugins --skill code-documentation

Code Documentation Skill

This skill provides comprehensive guidelines for documenting code, prioritizing user-centric writing, clarity, and consistency.

1. General Philosophy

  • User-Centric: Write for the person using your API. If you had to look up how to use something, document it so others don't have to.
  • Explain "Why": Explain why code exists and how to use it effectively, since the code signature already tells what it does.
  • Be Concise: Omit fluff. Avoid merely restating the code name, as it is not helpful.
  • Consistency: Use standard terminology and consistent formatting.
  • Public APIs: Document all public APIs (classes, members, top-level functions) without exception.
  • Code Samples: Strongly consider adding code samples to explain usage.

2. General Structure

Follow this general structure for documentation comments across languages:

  1. Summary Sentence: Start with a single-sentence summary on the first line, ending with a period.
  2. Blank Line: Follow the summary with a blank line.
  3. Details: Add paragraphs, code samples, or lists as needed to explain parameters, return values, exceptions, and behavior.
  4. Annotations: Place doc comments before any metadata annotations.

3. Writing Guidelines

Brevity & Style

  • Avoid Fluff: Omit "This class...", "This method...", "Is used to...", "Note that...".
    • Bad: "This method is used to calculate the total."
    • Good: "Calculates the total."
  • Third-Person Verbs: Start function/method docs with a third-person singular verb.
    • Examples: "Returns...", "Calculates...", "Updates...", "Creates...".
  • Noun Phrases: Start variable/property docs with a noun phrase.
    • Examples: "The current color.", "A list of active users.".
  • Booleans: Always start with "Whether" (or similar clear indicator).
    • Good: "Whether this widget is enabled."
    • Bad: "If this widget is enabled...", "True if...", "Flag to indicate...".
  • Avoid Jargon: Use plain English unless the term is a widely accepted standard (e.g., "HTTP", "URL").

Formatting

  • Sparingly: Use Markdown features (bold, lists) sparingly.
  • No HTML: Avoid HTML unless strictly necessary and supported by the documentation tool.
  • Parameters/Returns/Exceptions: Use prose to describe parameters, return values, and thrown exceptions. Do not rely solely on tags like @param unless mandated by the language standard (e.g., Javadoc).

4. Implementation Comments

Ensure implementation comments (//) are accurate, relevant, factual, and provide information that is not readily understandable from the code. Remove or reword comments that do not meet these criteria. If an implementation comment provides information useful to an API consumer that is not already in the documentation comments, move it to the documentation comments.

5. Review Checklist

Use this checklist to verify your documentation:

  1. Summary: Ensure every public member starts with a one-sentence summary ending in a period.
  2. Brevity: Remove "This class..." or "This function..." fluff.
  3. Completeness: Document strict constraints (e.g., "must not be null") and exceptions.
  4. Examples: Consider adding a code sample for complex widgets or methods.

6. Language Specific Instructions

Refer to the language guides for detailed instructions on structure, linking, and framework-specific patterns:

flutterのその他のスキル

adding-release-notes
flutter
DevToolsのリリースノートにユーザー向けの変更説明を追加します。NEXT_RELEASE_NOTES.mdファイルに改善点、修正、新機能を文書化する際に使用します。
official
dart-modern-features
flutter
モダナイゼーションの候補を見つけるには:
official
api-review
flutter
指定されたコードを標準的なAPI設計ガイドラインに照らしてレビューします。ユーザーがAPIレビューを依頼した場合や、コードをAPI設計に照らして確認したい場合にこのスキルを使用します。
official
dart-add-unit-test
flutter
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains…
official
dart-build-cli-app
flutter
エントリポイント構造、終了コード、クロスプラットフォームのスクリプト。コマンドラインユーティリティ、スクリプト、またはアプリケーションを構築する際に使用します。
official
dart-collect-coverage
flutter
coverageパッケージを使用してカバレッジを収集し、LCOVレポートを作成します
official
dart-fix-runtime-errors
flutter
get_runtime_errors と lsp を使用してアクティブなスタックトレースを取得し、失敗している行を特定して修正を適用し、hot_reload で解決を確認します。
official
dart-generate-test-mocks
flutter
Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex…
official