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 +8 -0
- data/gemspec.yml +1 -1
- data/lib/yard/cli/spellcheck.rb +4 -0
- data/lib/yard/spellcheck/checker.rb +12 -13
- metadata +2 -2
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
data/lib/yard/cli/spellcheck.rb
CHANGED
@@ -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_][
|
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
|
-
|
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
|