dart doc tool to extract metadata and descriptive text for API reference generation and IDE code intelligence.
Syntax Variants
Dart supports two syntactic forms for documentation comments. Both forms are parsed by the documentation generator and attached to the abstract syntax tree (AST) node immediately following the comment. Single-line Style (Preferred) Denoted by a triple slash///. This style is strictly recommended by the Dart style guide for all documentation.
/** to open and */ to close. While syntactically valid, this style is discouraged.
Note: The compiler treats /** as a documentation comment and will attach the enclosed text to the next declared symbol. To disable code without generating documentation, use the standard block comment /* ... */.
Content Parsing
The content within documentation comments is parsed as CommonMark (Markdown). The parser recognizes standard Markdown elements including:- Code blocks: Indented by 4 spaces or fenced with triple backticks.
- Inline code: Enclosed in single backticks.
- Lists: Ordered and unordered.
- Headers: Denoted by hash symbols (
#).
Symbol Reference Resolution
Dart documentation comments support in-scope symbol linking using square brackets[...]. The documentation generator resolves these references based on the lexical scope of the documented element.
- Parameters:
[a]resolves to the function parameter. - Members:
[Calculator.subtract]resolves to a specific method in a class. - Libraries:
[math.max]resolves to an imported library member. - Constructors:
[MyClass.new]or[MyClass.named]resolves to class constructors.
Directives
Documentation comments support specific inline directives enclosed in braces that alter the behavior of the documentation generator.{@nodoc}: Instructs the generator to exclude the documented element from the generated output.{@canonicalFor element}: Asserts that the current library is the canonical location for a specific element, overriding default location logic (e.g.,{@canonicalFor MyClass}).{@tool ...}/{@end-tool}: Allows the embedding of external tools or samples within the documentation.
@Deprecated metadata annotation applied to the code declaration, not via a documentation directive.
Library Documentation
To attach documentation to a library itself, the documentation comment must be placed immediately before alibrary directive.
If a documentation comment is placed at the top of a file without a library directive, the parser attaches the comment to the first import, export, or declaration it encounters, rather than the library.
Master Dart with Deep Grasping Methodology!Learn More





