diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 4cd60fdc39672e0309c4e5874553fd18f1e0de6d..a443c7396260b5939c3b506ed5d842ad7e26d2c0 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -30,8 +30,9 @@ def to_s(options={}) # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+, # +script+, and +test+ (recursively). Only filenames with extension - # +.builder+, +.rb+, and +.erb+ are taken into account. The +options+ - # hash is passed to each annotation's +to_s+. + # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, and + # +.coffee+ are taken into account. The +options+ hash is passed to each + # annotation's +to_s+. # # This class method is the single entry point for the rake tasks. def self.enumerate(tag, options={}) @@ -53,7 +54,8 @@ def find(dirs=%w(app config lib script test)) # Returns a hash that maps filenames under +dir+ (recursively) to arrays # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+ and +.coffee+ + # those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, + # +.scss+, +.js+, and +.coffee+ # are taken into account. def find_in(dir) results = {} @@ -65,6 +67,8 @@ def find_in(dir) results.update(find_in(item)) elsif item =~ /\.(builder|rb|coffee)$/ results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/)) + elsif item =~ /\.(css|scss|js)$/ + results.update(extract_annotations_from(item, /\/\/\s*(#{tag}):?\s*(.*)$/)) elsif item =~ /\.erb$/ results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)) elsif item =~ /\.haml$/ diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index 04abf9e3a181a48d5a51aca248092850efee79e2..d069703d3043c26835be22e8bd5552b2731ed1ab 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -17,6 +17,9 @@ def teardown app_file "app/views/home/index.html.haml", "-# TODO: note in haml" app_file "app/views/home/index.html.slim", "/ TODO: note in slim" app_file "app/assets/javascripts/application.js.coffee", "# TODO: note in coffee" + app_file "app/assets/javascripts/application.js", "// TODO: note in js" + app_file "app/assets/stylesheets/application.css", "// TODO: note in css" + app_file "app/assets/stylesheets/application.css.scss", "// TODO: note in scss" app_file "app/controllers/application_controller.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in ruby" boot_rails @@ -35,8 +38,11 @@ def teardown assert_match /note in slim/, output assert_match /note in ruby/, output assert_match /note in coffee/, output + assert_match /note in js/, output + assert_match /note in css/, output + assert_match /note in scss/, output - assert_equal 5, lines.size + assert_equal 8, lines.size lines.each do |line| assert_equal 4, line[0].size