Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added file comments to the report

  • Loading branch information...
commit e31a1a4a2819a9539f3d3249a1f1ed32d3203642 1 parent 8931665
Eric Hodel drbrain authored
12 lib/rdoc/generator/spellcheck.rb
View
@@ -122,6 +122,10 @@ def generate files
end
end
+ RDoc::TopLevel.all_files.each do |file|
+ report.concat misspellings_for(nil, file.comment, file)
+ end
+
if @misspellings.zero? then
puts 'No misspellings found'
else
@@ -136,13 +140,19 @@ def generate files
def misspellings_for name, comment, location
out = []
+ return out if comment.empty?
+
misspelled = find_misspelled comment
return out if misspelled.empty?
@misspellings += misspelled.length
- out << "#{name} in #{location.full_name}:"
+ if name then
+ out << "#{name} in #{location.full_name}:"
+ else
+ out << "In #{location.full_name}:"
+ end
out << nil
out.concat misspelled.map { |word, offset|
suggestion_text comment.text, word, offset
46 test/test_rdoc_generator_spellcheck.rb
View
@@ -54,22 +54,6 @@ def test_find_misspelled
assert_equal 28, offset
end
- def test_generate
- klass = @top_level.add_class RDoc::NormalClass, 'Object'
-
- c = comment @text
- klass.add_comment c, @top_level
-
- out, err = capture_io do
- @sc.generate [@top_level]
- end
-
- assert_empty err
-
- assert_match %r%^class Object in file\.rb:%, out
- assert_match %r%^"gud"%, out
- end
-
def test_generate_alias
klass = @top_level.add_class RDoc::NormalClass, 'Object'
@@ -111,6 +95,22 @@ def test_generate_attribute
assert_match %r%^"gud"%, out
end
+ def test_generate_class
+ klass = @top_level.add_class RDoc::NormalClass, 'Object'
+
+ c = comment @text
+ klass.add_comment c, @top_level
+
+ out, err = capture_io do
+ @sc.generate [@top_level]
+ end
+
+ assert_empty err
+
+ assert_match %r%^class Object in file\.rb:%, out
+ assert_match %r%^"gud"%, out
+ end
+
def test_generate_constant
klass = @top_level.add_class RDoc::NormalClass, 'Object'
@@ -143,6 +143,20 @@ def test_generate_correct
assert_equal "No misspellings found\n", out
end
+ def test_generate_file
+ @top_level.comment = comment @text
+ @top_level.parser = RDoc::Parser::Text
+
+ out, err = capture_io do
+ @sc.generate [@top_level]
+ end
+
+ assert_empty err
+
+ assert_match %r%^In file\.rb:%, out # actual file name would be different
+ assert_match %r%^"gud"%, out
+ end
+
def test_generate_include
klass = @top_level.add_class RDoc::NormalClass, 'Object'
Please sign in to comment.
Something went wrong with that request. Please try again.