Class: Yard::Lint::Validators::Documentation::LineLength::Validator
- Defined in:
- lib/yard/lint/validators/documentation/line_length/validator.rb
Overview
Validates that documentation comment lines do not exceed the configured maximum length.
Uses YARD’s ‘docstring.line_range` to locate the exact source lines belonging to each docstring block. This handles block comments, wrapped tag descriptions, and macro expansion correctly — no arithmetic reconstruction needed.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#in_process_query(object, collector) ⇒ void
Execute query for a single object during in-process execution.
Methods inherited from Base
in_process, in_process?, in_process_visibility, #initialize, validator_name
Constructor Details
This class inherits a constructor from Yard::Lint::Validators::Base
Instance Method Details
#in_process_query(object, collector) ⇒ void
This method returns an undefined value.
Execute query for a single object during in-process execution.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yard/lint/validators/documentation/line_length/validator.rb', line 20 def in_process_query(object, collector) return unless object.file && File.exist?(object.file) return if object.docstring.all.empty? line_range = object.docstring.line_range return unless line_range max_length = config_or_default('MaxLength').to_i source_lines = cached_lines(object.file) violations = [] line_range.each do |line_no| raw_line = source_lines[line_no - 1].to_s.rstrip next if raw_line.length <= max_length violations << "#{line_no}:#{raw_line.length}" end return if violations.empty? collector.puts "#{object.file}:#{object.line}: #{object.title}" collector.puts "#{max_length}|#{violations.join('|')}" end |