Commit 7e391972 authored by Marius Rackwitz's avatar Marius Rackwitz

[Rakefile] Improve inch:spec task

parent a5fb5466
......@@ -303,9 +303,51 @@ begin
namespace :inch do
desc 'Lint the completeness of the documentation with Inch'
task :spec do
sh "inch --all --no-undocumented list | tee tmp/inch.txt"
sh "grep -q 'Nothing to suggest.' tmp/inch.txt" do |ok, _|
fail red('✗ Improve above suggestions.') unless ok
require 'inch'
require 'inch/cli'
puts 'Parse docs …'
YARD::Parser::SourceParser.before_parse_file do |_|
print green('.') # Visualize progress
end
class ProgressEnumerable
include Enumerable
def initialize(array)
@array = array
end
def each
@array.each do |e|
print '.'
yield e
end
end
end
Inch::Codebase::Objects.class_eval do
alias_method :old_init, :initialize
def initialize(language, objects)
puts "\n\nEvaluating …"
old_init(language, ProgressEnumerable.new(objects))
end
end
codebase = Inch::Codebase.parse(Dir.pwd, Inch::Config.codebase)
context = Inch::API::List.new(codebase, {})
options = Inch::CLI::Command::Options::List.new
options.show_all = true
options.ui = Inch::Utils::UI.new
failing_grade_symbols = [:B, :C] # add :U for undocumented
failing_grade_list = context.grade_lists.select { |g| failing_grade_symbols.include?(g.to_sym) }
Inch::CLI::Command::Output::List.new(options, context.objects, failing_grade_list)
puts
if context.objects.any? { |o| failing_grade_symbols.include?(o.grade.to_sym) }
puts red('✗ Lint of Documentation failed: Please improve above suggestions.')
exit 1
else
puts green('✓ Nothing to improve detected.')
end
end
end
......@@ -348,6 +390,10 @@ def title(title)
puts
end
def green(string)
"\033[0;32m#{string}\e[0m"
end
def red(string)
"\033[0;31m#{string}\e[0m"
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment