Home > Software design >  Dart doc comment escape square brackets
Dart doc comment escape square brackets

Time:12-07

I have a simple enum with a doc comment wanting to display [] inside the comment:

/// Define the brackets used when displaying a `List` in a cell.
///
/// Supported bracket types are:
/// * parentheses: ()
/// * curly: {}
/// * square: []
enum ListBrackets {
  /// Use parentheses
  parentheses,
  /// Use curly brackets
  curly,
  /// Use square brackets
  square;
}

However all i get is: Define the brackets used when displaying a List in a cell. Supported bracket types are: parentheses: () curly: {} square:

Any help is appreciated

CodePudding user response:

Escape the square brackets with a \:

/// Define the brackets used when displaying a `List` in a cell.
///
/// Supported bracket types are:
/// * parentheses: ()
/// * curly: {}
/// * square: \[\]
enum ListBrackets {
  /// Use parentheses
  parentheses,
  /// Use curly brackets
  curly,
  /// Use square brackets
  square;
}

(You could also only escape the first one: \[] but I prefer to escape both!)

  • Related