mirror of https://github.com/rails/rails
Port Annotations rake task to use Rails::NotesCommand
* Invokes the notes Rails::Command and passes the rake task ENV variables as annotations options to it * Adds a deprecation warning for unsupported commands * Gets rid of reference to ENV["SOURCE_ANNOTATION_DIRECTORIES"] in SourceAnnotationExtractor since its now dealt with in the NotesCommand * Gets rid of rake desc for each rake notes task so they are not documented while using `rails -T` or `rails --help`
This commit is contained in:
parent
21f7dadbff
commit
edf5da4b6c
|
@ -20,7 +20,7 @@ module Rails
|
|||
class SourceAnnotationExtractor
|
||||
class Annotation < Struct.new(:line, :tag, :text)
|
||||
def self.directories
|
||||
@@directories ||= %w(app config db lib test) + (ENV["SOURCE_ANNOTATION_DIRECTORIES"] || "").split(",")
|
||||
@@directories ||= %w(app config db lib test)
|
||||
end
|
||||
|
||||
# Registers additional directories to be included
|
||||
|
@ -54,6 +54,13 @@ module Rails
|
|||
s << "[#{tag}] " if options[:tag]
|
||||
s << text
|
||||
end
|
||||
|
||||
# Used in annotations.rake
|
||||
#:nodoc:
|
||||
def self.notes_task_deprecation_warning
|
||||
ActiveSupport::Deprecation.warn("This rake task is deprecated and will be removed in Rails 6.1. \nRefer to `rails notes --help` for more information.\n")
|
||||
puts "\n"
|
||||
end
|
||||
end
|
||||
|
||||
# Prints all annotations with tag +tag+ under the root directories +app+,
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
require "rails/source_annotation_extractor"
|
||||
|
||||
desc "Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)"
|
||||
task :notes do
|
||||
Rails::SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", tag: true
|
||||
Rails::SourceAnnotationExtractor::Annotation.notes_task_deprecation_warning
|
||||
Rails::Command.invoke :notes
|
||||
end
|
||||
|
||||
namespace :notes do
|
||||
["OPTIMIZE", "FIXME", "TODO"].each do |annotation|
|
||||
# desc "Enumerate all #{annotation} annotations"
|
||||
task annotation.downcase.intern do
|
||||
Rails::SourceAnnotationExtractor.enumerate annotation
|
||||
Rails::SourceAnnotationExtractor::Annotation.notes_task_deprecation_warning
|
||||
Rails::Command.invoke :notes, ["--annotations", annotation]
|
||||
end
|
||||
end
|
||||
|
||||
desc "Enumerate a custom annotation, specify with ANNOTATION=CUSTOM"
|
||||
task :custom do
|
||||
Rails::SourceAnnotationExtractor.enumerate ENV["ANNOTATION"]
|
||||
Rails::SourceAnnotationExtractor::Annotation.notes_task_deprecation_warning
|
||||
Rails::Command.invoke :notes, ["--annotations", ENV["ANNOTATION"]]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue