Class: YARD::CLI::Spellcheck
- Inherits:
-
Command
- Object
- Command
- YARD::CLI::Spellcheck
- Includes:
- Spellcheck::Printer
- Defined in:
- lib/yard/cli/spellcheck.rb
Overview
The yard-spellcheck
command.
Constant Summary
Constants included from Spellcheck::Printer
Spellcheck::Printer::HIGHLIGHT, Spellcheck::Printer::UNHIGHLIGHT
Instance Attribute Summary collapse
-
#checker ⇒ Object
readonly
The spellchecker.
Instance Method Summary collapse
-
#description ⇒ String
The command description.
-
#initialize ⇒ Spellcheck
constructor
Initializes the spellcheck command.
-
#optparse(*args) ⇒ Object
protected
Parses the command options.
-
#run(*args) ⇒ Object
Runs the spellcheck command.
Methods included from Spellcheck::Printer
#print_stats, #print_text, #print_typos
Constructor Details
#initialize ⇒ Spellcheck
Initializes the spellcheck command.
17 18 19 20 21 |
# File 'lib/yard/cli/spellcheck.rb', line 17 def initialize @checker = YARD::Spellcheck::Checker.new @names = [] @stats = false end |
Instance Attribute Details
#checker ⇒ Object (readonly)
The spellchecker.
12 13 14 |
# File 'lib/yard/cli/spellcheck.rb', line 12 def checker @checker end |
Instance Method Details
#description ⇒ String
The command description.
29 30 31 |
# File 'lib/yard/cli/spellcheck.rb', line 29 def description 'Spellchecks YARD documentation' end |
#optparse(*args) ⇒ Object (protected)
Parses the command options.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/yard/cli/spellcheck.rb', line 66 def optparse(*args) opts = OptionParser.new opts. = "Usage: yard spellcheck [options]" opts.separator "" opts.separator description opts.separator "" opts.on('-D','--dict-dir DIR','Dictionary directory') do |dir| FFI::Hunspell.directories << File.(dir) end opts.on('-c','--check [CLASS | MODULE]','Classes/Modules to spellcheck') do |name| @names << name end opts.on('-L','--lang LANG','Language to spellcheck for') do |lang| @checker.lang = lang end opts.on('-I','--ignore WORD','Words to ignore') do |word| @checker.ignore << word end opts.on('-a','--add WORD [...]','Adds a word') do |word| @checker.added << word end opts.on('-S','--statistics','Print statistics') do @stats = true end (opts) (opts,args) end |
#run(*args) ⇒ Object
Runs the spellcheck command.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/yard/cli/spellcheck.rb', line 39 def run(*args) optparse(*args) CLI::Yardoc.run('-c', '-n', '--no-stats') @checker.check!(@names) do |element,typos| print_typos element, typos end if @stats puts "Statistics" print_stats @checker end exit -1 unless @checker.misspelled.empty? end |