code-documentation

Leitfaden für das Schreiben effektiver Code-Dokumentation, einschließlich Docstrings, JSDoc, dartdoc und Implementierungskommentaren. Verwenden Sie diese Fähigkeit beim Schreiben von neuem Code, beim Hinzufügen…

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:

Mehr Skills von flutter

dart-modern-features
flutter
Um Kandidaten für die Modernisierung zu finden:
flutter-fix-layout-issues
flutter
Behebt Flutter-Layout-Fehler (Überläufe, unbegrenzte Constraints) mit Dart und Flutter MCP Tools. Verwenden bei der Behebung von "RenderFlex overflowed", "Vertical…
adding-release-notes
flutter
Fügt benutzerseitige Änderungsbeschreibungen zu den DevTools-Versionshinweisen hinzu. Verwenden Sie dies, wenn Sie Verbesserungen, Fehlerbehebungen oder neue Funktionen in der Datei NEXT_RELEASE_NOTES.md dokumentieren.
reviewing-devtools-prs
flutter
DevTools-repositoriumspezifischer PR-Review-Workflow, der die DevTools-Stilrichtlinien und gängige Review-Muster durchsetzt. Verwenden Sie dies beim Überprüfen von Pull Requests im…
dart-use-primary-constructors
flutter
Helfen Sie Benutzern, syntaktisch und semantisch korrekte primäre Konstruktoren in Dart zu schreiben, und migrieren/verwenden Sie die neue Konstruktorsyntax, die Semikolon-Syntax mit leerem Körper, …
api-review
flutter
Überprüft den angegebenen Code gegen die kanonischen API-Design-Richtlinien. Verwenden Sie dieses Skill, wenn der Benutzer eine API-Überprüfung anfordert oder Code gegen API-Design…
flutter-accessibility
flutter
Implementiert WCAG 2- und EN 301 549-Barrierefreiheitsstandards sowie adaptive Layouts in Flutter-Apps. Erzwingt semantische Annotationen, Mindestgrößen für Antippziele (48x48 dp) und Textkontrastverhältnisse (4,5:1 für kleinen Text, 3:1 für großen Text) auf mobilen, Web- und Desktop-Plattformen. Bietet Entscheidungslogik für die Initialisierung von Websemantik, das Umschließen interaktiver Widgets, bildschirmgrößenbasiertes Layout-Switching sowie Tastatur-/Mauseingabe-Handling. Enthält Fokus-Traversal-Management über FocusTraversalGroup und...
flutter-accessibility-audit
flutter
Löst einen Barrierefreiheitsscan über den widget_inspector aus und fügt automatisch Semantics-Widgets oder fehlende Labels zum Quellcode hinzu.