1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/Rakefile
Akira Matsuda 7727346a49
Bring back :doc task
which has been removed at 11bb81149f
but still in need for generating a complete set of haml.info docs
2022-09-25 15:26:48 +09:00

141 lines
3.3 KiB
Ruby

require 'bundler/gem_tasks'
#
# Prepend DevKit into compilation phase
#
if Gem.win_platform?
desc 'Activates DevKit'
task :devkit do
begin
require 'devkit'
rescue LoadError
abort 'Failed to load DevKit required for compilation'
end
end
task compile: :devkit
end
require 'rake/testtask'
if /java/ === RUBY_PLATFORM
# require 'rake/javaextensiontask'
# Rake::JavaExtensionTask.new(:haml) do |ext|
# ext.ext_dir = 'ext/java'
# ext.lib_dir = 'lib/haml'
# end
task :compile do
# dummy for now
end
else
require 'rake/extensiontask'
Rake::ExtensionTask.new(:haml) do |ext|
ext.lib_dir = 'lib/haml'
end
end
Dir['benchmark/*.rake'].each { |b| import(b) }
namespace :haml do
Rake::TestTask.new do |t|
t.libs << 'lib' << 'test'
files = Dir['test/haml/*_test.rb']
files << 'test/haml/haml-spec/*_test.rb'
t.ruby_opts = %w[-rtest_helper]
t.test_files = files
t.verbose = true
end
end
namespace :hamlit do
Rake::TestTask.new do |t|
t.libs << 'lib' << 'test'
t.ruby_opts = %w[-rtest_helper]
t.test_files = Dir['test/hamlit/**/*_test.rb']
t.verbose = true
end
end
namespace :test do
Rake::TestTask.new(:all) do |t|
t.libs << 'lib' << 'test'
files = Dir['test/hamlit/**/*_test.rb']
files += Dir['test/haml/*_test.rb']
files << 'test/haml/haml-spec/*_test.rb'
t.ruby_opts = %w[-rtest_helper]
t.test_files = files
t.verbose = true
end
Rake::TestTask.new(:spec) do |t|
t.libs << 'lib' << 'test'
t.ruby_opts = %w[-rtest_helper]
t.test_files = %w[test/haml/haml-spec/ugly_test.rb test/haml/haml-spec/pretty_test.rb]
t.verbose = true
end
Rake::TestTask.new(:engine) do |t|
t.libs << 'lib' << 'test'
t.ruby_opts = %w[-rtest_helper]
t.test_files = %w[test/haml/engine_test.rb]
t.verbose = true
end
Rake::TestTask.new(:filters) do |t|
t.libs << 'lib' << 'test'
t.ruby_opts = %w[-rtest_helper]
t.test_files = %w[test/haml/filters_test.rb]
t.verbose = true
end
Rake::TestTask.new(:helper) do |t|
t.libs << 'lib' << 'test'
t.ruby_opts = %w[-rtest_helper]
t.test_files = %w[test/haml/helper_test.rb]
t.verbose = true
end
Rake::TestTask.new(:template) do |t|
t.libs << 'lib' << 'test'
t.ruby_opts = %w[-rtest_helper]
t.test_files = %w[test/haml/template_test.rb]
t.verbose = true
end
end
desc 'bench task for CI'
task bench: :compile do
if ENV['SLIM_BENCH'] == '1'
cmd = %w[bundle exec ruby benchmark/slim/run-benchmarks.rb]
else
cmd = ['bin/bench', 'bench', ('-c' if ENV['COMPILE'] == '1'), *ENV['TEMPLATE'].split(',')].compact
end
exit system(*cmd)
end
namespace :doc do
task :sass do
require 'sass'
Dir["yard/default/**/*.sass"].each do |sass|
File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
f.write(Sass::Engine.new(File.read(sass)).render)
end
end
end
desc "List all undocumented methods and classes."
task :undocumented do
command = 'yard --list --query '
command << '"object.docstring.blank? && '
command << '!(object.type == :method && object.is_alias?)"'
sh command
end
end
desc "Generate documentation"
task(:doc => 'doc:sass') {sh "yard"}
desc "Generate documentation incrementally"
task(:redoc) {sh "yard -c"}
task default: %w[compile hamlit:test]
task test: %w[compile test:all]