argsHtml property

String get argsHtml

Convenience method to generate html stubs when generating documentation.

Implementation

String get argsHtml {
  String html = '';
  int brackets = 0;
  for (final DeclArg arg in args) {
    final String lexeme = arg.lexeme;

    decorate(String s) {
      if (arg.isOptional) {
        brackets++;
        return '[$s';
      }
      return s;
    }

    html = switch (html.isEmpty) {
      true => decorate(lexeme),
      false => '$html ${decorate(', $lexeme')}',
    };
  }

  while (brackets-- > 0) {
    html = '$html]';
  }

  return '($html)';
}