Skip to content

Commit 94ee8b6

Browse files
committed
Simplify/merge rake tasks
1 parent 8abcb18 commit 94ee8b6

File tree

4 files changed

+102
-101
lines changed

4 files changed

+102
-101
lines changed

Rakefile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,71 @@ begin
201201
rescue LoadError
202202
puts 'Error loading Rspec rake tasks, probably building the gem...'
203203
end
204+
205+
unless defined?(JRUBY_VERSION)
206+
207+
desc 'Display LOC (lines of code) report'
208+
task :loc do
209+
puts `countloc -r lib`
210+
end
211+
212+
desc 'Display code quality analysis report'
213+
task :critic do
214+
sh 'rubycritic lib --path critic'
215+
end
216+
end
217+
218+
require 'yard'
219+
require 'md_ruby_eval'
220+
require_relative 'support/yard_full_types'
221+
222+
root = File.expand_path File.dirname(__FILE__)
223+
224+
cmd = lambda do |command|
225+
puts ">> executing: #{command}"
226+
puts ">> in: #{Dir.pwd}"
227+
system command or raise "#{command} failed"
228+
end
229+
230+
yard_doc = YARD::Rake::YardocTask.new(:yard)
231+
yard_doc.before = -> do
232+
Dir.chdir File.join(root, 'doc') do
233+
cmd.call 'bundle exec md-ruby-eval --auto' or raise
234+
end
235+
end
236+
237+
namespace :yard do
238+
239+
desc 'Pushes generated documentation to github pages: http://ruby-concurrency.github.io/concurrent-ruby/'
240+
task :push => [:setup, :yard] do
241+
242+
message = Dir.chdir(root) do
243+
`git log -n 1 --oneline`.strip
244+
end
245+
puts "Generating commit: #{message}"
246+
247+
Dir.chdir "#{root}/yardoc" do
248+
cmd.call "git add -A"
249+
cmd.call "git commit -m '#{message}'"
250+
cmd.call 'git push origin gh-pages'
251+
end
252+
253+
end
254+
255+
desc 'Setups second clone in ./yardoc dir for pushing doc to github'
256+
task :setup do
257+
258+
unless File.exist? "#{root}/yardoc/.git"
259+
cmd.call "rm -rf #{root}/yardoc" if File.exist?("#{root}/yardoc")
260+
Dir.chdir "#{root}" do
261+
cmd.call 'git clone --single-branch --branch gh-pages [email protected]:ruby-concurrency/concurrent-ruby.git ./yardoc'
262+
end
263+
end
264+
Dir.chdir "#{root}/yardoc" do
265+
cmd.call 'git fetch origin'
266+
cmd.call 'git reset --hard origin/gh-pages'
267+
end
268+
269+
end
270+
271+
end

support/yard_full_types.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module YARD
2+
module Templates::Helpers
3+
# The helper module for HTML templates.
4+
module HtmlHelper
5+
def signature_types(meth, link = true)
6+
meth = convert_method_to_overload(meth)
7+
if meth.respond_to?(:object) && !meth.has_tag?(:return)
8+
meth = meth.object
9+
end
10+
11+
type = options.default_return || ""
12+
if meth.tag(:return) && meth.tag(:return).types
13+
types = meth.tags(:return).map { |t| t.types ? t.types : [] }.flatten.uniq
14+
first = link ? h(types.first) : format_types([types.first], false)
15+
# if types.size == 2 && types.last == 'nil'
16+
# type = first + '<sup>?</sup>'
17+
# elsif types.size == 2 && types.last =~ /^(Array)?<#{Regexp.quote types.first}>$/
18+
# type = first + '<sup>+</sup>'
19+
# elsif types.size > 2
20+
# type = [first, '...'].join(', ')
21+
if types == ['void'] && options.hide_void_return
22+
type = ""
23+
else
24+
type = link ? h(types.join(", ")) : format_types(types, false)
25+
end
26+
elsif !type.empty?
27+
type = link ? h(type) : format_types([type], false)
28+
end
29+
type = "(#{type}) " unless type.empty?
30+
type
31+
end
32+
end
33+
end
34+
end

tasks/metrics.rake

Lines changed: 0 additions & 12 deletions
This file was deleted.

tasks/update_doc.rake

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)