Class: Ace::Lint::Atoms::CommentValidator
- Inherits:
-
Object
- Object
- Ace::Lint::Atoms::CommentValidator
- Defined in:
- lib/ace/lint/atoms/comment_validator.rb
Overview
Validates presence of required YAML comments in frontmatter Used for SKILL.md files that require documentation comments
Class Method Summary collapse
-
.frontmatter_start_line ⇒ Integer
Find the line number where a comment should be added.
-
.validate(content, required_comments:) ⇒ Array<String>
Validate that required comments are present in the raw content.
Class Method Details
.frontmatter_start_line ⇒ Integer
Find the line number where a comment should be added
38 39 40 |
# File 'lib/ace/lint/atoms/comment_validator.rb', line 38 def frontmatter_start_line 1 end |
.validate(content, required_comments:) ⇒ Array<String>
Validate that required comments are present in the raw content
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ace/lint/atoms/comment_validator.rb', line 14 def validate(content, required_comments:) return [] if required_comments.nil? || required_comments.empty? return required_comments if content.nil? || content.empty? # Extract frontmatter section (between --- markers) frontmatter = extract_frontmatter_raw(content) return required_comments if frontmatter.nil? missing = [] required_comments.each do |comment_pattern| # Check if the comment pattern exists in frontmatter # The pattern is like "# context:" - we check if it appears in the YAML section unless frontmatter.include?(comment_pattern) missing << comment_pattern end end missing end |