yard-spellcheck 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.1.1 / 2011-01-25
2
+
3
+ * Do not load `yard` within the plugin.
4
+ * Ignore all Acronyms and CamelCase words.
5
+ * Ignore all words containing underscores.
6
+ * Perform a soft-update of the YARD Cache when running `yard-spellcheck`.
7
+ * Exit with status `-1` if the `yard-spellcheck` command found any typos.
8
+
1
9
  ### 0.1.0 / 2011-01-25
2
10
 
3
11
  * Initial release:
data/gemspec.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  name: yard-spellcheck
2
- version: 0.1.0
2
+ version: 0.1.1
3
3
  summary: Spellcheck your YARD documentat
4
4
  description:
5
5
  Adds the 'spellcheck' command to YARD, which will spellcheck every
@@ -39,6 +39,8 @@ module YARD
39
39
  def run(*args)
40
40
  optparse(*args)
41
41
 
42
+ CLI::Yardoc.run('-c', '-n', '--no-stats')
43
+
42
44
  @checker.check!(@names) do |element,typos|
43
45
  print_typos element, typos
44
46
  end
@@ -47,6 +49,8 @@ module YARD
47
49
  puts "Statistics"
48
50
  print_stats @checker
49
51
  end
52
+
53
+ exit -1 unless @checker.misspelled.empty?
50
54
  end
51
55
 
52
56
  protected
@@ -1,6 +1,5 @@
1
1
  require 'ffi/hunspell'
2
2
  require 'set'
3
- require 'yard'
4
3
 
5
4
  module YARD
6
5
  module Spellcheck
@@ -13,7 +12,13 @@ module YARD
13
12
  SKIP_TAGS = Set['example', 'since', 'see', 'api']
14
13
 
15
14
  # The Regexp to use for scanning in words.
16
- WORD_REGEXP = /[^\W_][[^\W_]'-]*[^\W_]/
15
+ WORD_REGEXP = /[^\W_][\w'-]*[^\W_]/
16
+
17
+ # The Regexp to filter out Acronyms.
18
+ ACRONYM_REGEXP = /(([A-Z]\.){2,}|[A-Z]{2,})/
19
+
20
+ # The Regexp to filter out CamelCase words.
21
+ CAMEL_CASE_REGEXP = /([A-Z][a-z]+){2,}/
17
22
 
18
23
  # The language to spellcheck against.
19
24
  attr_accessor :lang
@@ -24,9 +29,6 @@ module YARD
24
29
  # The words to add to the dictionary.
25
30
  attr_reader :added
26
31
 
27
- # The known words from the documentation.
28
- attr_reader :known
29
-
30
32
  # The misspelled words.
31
33
  attr_reader :misspelled
32
34
 
@@ -58,7 +60,6 @@ module YARD
58
60
  @added += options[:add]
59
61
  end
60
62
 
61
- @known = Set[]
62
63
  @misspelled = Hash.new { |hash,key| hash[key] = 0 }
63
64
  end
64
65
 
@@ -87,14 +88,8 @@ module YARD
87
88
  YARD::Registry.load!
88
89
 
89
90
  # clear any statistics from last run
90
- @known.clear
91
91
  @misspelled.clear
92
92
 
93
- # load known Class and Module names
94
- YARD::Registry.all(:class, :module).each do |obj|
95
- obj.path.split('::').each { |name| @known << name }
96
- end
97
-
98
93
  FFI::Hunspell.dict(@lang) do |dict|
99
94
  # add user specified words
100
95
  @added.each { |word| dict.add(word) }
@@ -167,7 +162,11 @@ module YARD
167
162
  typos = Set[]
168
163
 
169
164
  text.scan(WORD_REGEXP).each do |word|
170
- next if (@known.include?(word) || @ignore.include?(word))
165
+ # ignore all underscored names
166
+ next if word.include?('_')
167
+
168
+ # ignore all acronyms and CamelCase words
169
+ next if (word =~ ACRONYM_REGEXP || word =~ CAMEL_CASE_REGEXP)
171
170
 
172
171
  if (@misspelled.has_key?(word) || !dict.valid?(word))
173
172
  @misspelled[word] += 1
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Postmodern