Currently, dartdoc directives are processed using a series of independent regular expressions on the raw documentation string. This "regex soup" approach lacks context awareness and leads to several robustness issues.
This issue tracks the work to unify the parsing logic and implement a standard set of rules for all directives. We should consider the following:
-
Context Awareness (Code Fences):
Directives could be ignored if they appear inside Markdown code blocks (fenced ``` or inline `).
-
Escaping Support:
Implement a standard escaping mechanism (e.g., \{@directive ...}) to allow users to document directives literally without executing them.
-
Line-Level Enforcement (for Block Directives):
Block-level directives could be required to appear on their own line .
-
Strict Argument Parsing:
The current shared _parseArgs utility (backed by package:args) accidentally allows flag-style arguments (e.g., --lang=dart) in addition to the documented key=value syntax. Decide on the canonical syntax (likely key=value) and update the parser to strictly enforce it.
-
Move Parsing to Analyzer:
Ideally, the parsing, resolution, and validation logic for these directives should live in the analyzer package. This would enable IDE features like hover previews, auto-completion, and real-time error reporting for directives.
Currently, dartdoc directives are processed using a series of independent regular expressions on the raw documentation string. This "regex soup" approach lacks context awareness and leads to several robustness issues.
This issue tracks the work to unify the parsing logic and implement a standard set of rules for all directives. We should consider the following:
Context Awareness (Code Fences):
Directives could be ignored if they appear inside Markdown code blocks (fenced ``` or inline `).
Escaping Support:
Implement a standard escaping mechanism (e.g.,
\{@directive ...}) to allow users to document directives literally without executing them.Line-Level Enforcement (for Block Directives):
Block-level directives could be required to appear on their own line .
Strict Argument Parsing:
The current shared
_parseArgsutility (backed bypackage:args) accidentally allows flag-style arguments (e.g.,--lang=dart) in addition to the documentedkey=valuesyntax. Decide on the canonical syntax (likelykey=value) and update the parser to strictly enforce it.Move Parsing to Analyzer:
Ideally, the parsing, resolution, and validation logic for these directives should live in the
analyzerpackage. This would enable IDE features like hover previews, auto-completion, and real-time error reporting for directives.