Created
February 1, 2024 15:40
-
-
Save andynu/29e55ee95d44a8b085aef5508009e0b3 to your computer and use it in GitHub Desktop.
Run annotate and erd automatically when you db:migrate (rails)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :doc do | |
desc 'generate yardoc docs in doc/app/index.html' | |
task :app do | |
`yard doc -o doc/app` | |
puts "see doc/app/index.html" | |
end | |
desc 'annotate models' | |
task :annotate do | |
run = ->(cmd){ | |
print "Running `#{cmd}` "; | |
`#{cmd} 2>&1` | |
puts $?.success? ? Rainbow('[OK]').green : Rainbow('[FAILED]').red | |
} | |
if Rails.env.development? && ENV['USER']!='jane' | |
run.call('annotate --models --position bottom') | |
run.call('annotate --routes --position bottom') | |
end | |
end | |
end | |
namespace :db do | |
task :migrate do | |
# This appends, it does not redefine. | |
# Always run doc:annotate after db:migrate | |
Rake::Task['doc:annotate'].invoke | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment