Module: DocOpsLab::Dev::SpellCheck

Defined in:
lib/docopslab/dev/spell_check.rb

Overview

SpellCheck functionality for parsing Vale logs and managing spelling corrections

Class Method Summary collapse

Class Method Details

.generate_spellcheck_report(file_path = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/docopslab/dev/spell_check.rb', line 16

def generate_spellcheck_report file_path=nil
  puts '📝 Generating spellcheck report from Vale output...'

  manifest = DocOpsLab::Dev.load_manifest
  spellcheck_config = manifest['spellcheck'] || {}
  output_dir = spellcheck_config['output_dir'] || '.agent/reports/'
  FileUtils.mkdir_p(output_dir)
  output_file = spellcheck_config['output_file'] || nil
  prompt = spellcheck_config['prompt'] || nil

  unless defined?(output_file) && output_file
    timestamp = Time.now.strftime('%Y%m%d_%H%M%S')
    output_file = "spellcheck-#{timestamp}.yml"
  end

  output_path = File.join(output_dir, output_file)

  # Run Vale with JSON output and spelling filter
  # Pass just the rule name; filter builder will add .Name== wrapper
  # If file_path specified, only check that file
  vale_json = DocOpsLab::Dev.run_vale(
    file_path,
    '',
    output_format: :json,
    filter: 'DocOpsLab-Authoring.Spelling')
  return false if vale_json.nil?

  # Parse JSON output for spelling issues
  spelling_issues = parse_vale_json_output(vale_json)

  if spelling_issues.empty?
    puts '✅ No spelling issues found!'
    return true
  end

  # Generate YAML report
  generate_yaml_report(spelling_issues, output_path, prompt)

  puts "📄 SpellCheck report generated: #{output_path}"
  puts "Found #{spelling_issues.length} spelling issues to review"
  true
end

.spelling_config_pathObject



11
12
13
# File 'lib/docopslab/dev/spell_check.rb', line 11

def self.spelling_config_path
  File.join(GEM_ROOT, 'assets', 'config-packs', 'vale', 'authoring', 'Spelling.yml')
end