Class: TodoAgent::Parsers::RegexBuilder
- Inherits:
-
Object
- Object
- TodoAgent::Parsers::RegexBuilder
- Defined in:
- lib/todo_agent/parsers/regex_builder.rb
Constant Summary collapse
- DEFAULT_TAGS =
[DefaultTags.todo, DefaultTags.fixme].freeze
Class Method Summary collapse
Class Method Details
.regex(custom_tags = []) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/todo_agent/parsers/regex_builder.rb', line 10 def self.regex( = []) = (DEFAULT_TAGS + ).uniq # Regex building taken from https://github.com/pgilad/leasot/blob/ffc68de48d91f6b0d4ba35d6a21b4fb3580b54f9/src/lib/utils/comments.ts # Optional space. '\\s*' + # Optional `@`. "@?" + # One of the keywords such as `TODO` and `FIXME`. "(" + .join("|") + ")" + # tag cannot be followed by an alpha-numeric character (strict tag match) '(?!\\w)' + # Optional space. '\\s*' + # Optional leading reference in parenthesis. '(?:\\(([^)]*)\\))?' + # Optional space. '\\s*' + # Optional colon `:`. ":?" + # Optional space. '\\s*' + # Comment text. "(.*?)" + # Optional trailing reference after a space and a slash, followed by an optional space. '(?:\\s+/([^\\s]+)\\s*)?' end |