Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

fix: correctly support dartdoc tags for format-comment #1182

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* fix: correctly support dartdoc tags for [`format-comment`](https://dcm.dev/docs/individuals/rules/common/format-comment).

## 5.6.0-dev.1

* docs: remove old website
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ part of 'format_comment_rule.dart';
const _punctuation = ['.', '!', '?', ':'];

final _sentencesRegExp = RegExp(r'(?<=([\.|:](?=\s|\n|$)))');
final _regMacrosExp = RegExp('{@(template|macro) .+}');
const _macrosEndExp = '{@endtemplate}';
final _regMacrosExp = RegExp('{@.+}');
const _ignoreExp = 'ignore:';
const _ignoreForFileExp = 'ignore_for_file:';

Expand Down Expand Up @@ -141,16 +140,14 @@ class _Visitor extends RecursiveAstVisitor<void> {
final trimmed = text.trim();

return _regMacrosExp.hasMatch(text) ||
text.contains(_macrosEndExp) ||
_isIgnoreComment(trimmed) ||
_isIgnoredPattern(trimmed);
}

bool _isIgnoreComment(String text) =>
text.startsWith(_ignoreExp) || text.startsWith(_ignoreForFileExp);

bool _isMacros(String text) =>
_regMacrosExp.hasMatch(text) || text == _macrosEndExp;
bool _isMacros(String text) => _regMacrosExp.hasMatch(text);

bool _isIgnoredPattern(String text) =>
_ignoredPatterns.any((regExp) => regExp.hasMatch(text));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ void f3() {}

/// {@template my_project.my_class.my_method}
void f4() {}

/// {@nodoc}
void f5() {}