Skip to content

Standardize and robustify dartdoc directive parsing logic #4205

@szakarias

Description

@szakarias

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions