-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
46 lines (35 loc) · 1.12 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
require "rubocop/rake_task"
RuboCop::RakeTask.new
require "rake/clean"
CLEAN.include ".yardoc/"
require "yard"
YARD::Rake::YardocTask.new do |t|
t.options = %w[--no-cache --fail-on-warning]
end
directory ".yard"
CLEAN.include ".yard/"
def normalize_yard_ref(str)
if str.start_with?("Cecil::")
str
else
"Cecil::#{str}"
end
end
def convert_markdown_yardoc_links_to_yardoc(str)
str.gsub(/\[(.+)\]\[\{([^\}\]]+)\}\]/) { "{#{normalize_yard_ref(Regexp.last_match(2))} #{Regexp.last_match(1)}}" }
end
file ".yard/README.md" => ["README.md", ".yard"] do |t|
File.write t.name, convert_markdown_yardoc_links_to_yardoc(File.read("README.md"))
end
desc "Generate yardoc documentation"
task yard: ".yard/README.md"
desc "Ensure yardoc documentation README is up-to-date"
task :ensure_yard_readme_is_up_to_date do
if File.read(".yard/README.md") != convert_markdown_yardoc_links_to_yardoc(File.read("README.md"))
raise ".yard/README.md is not up-to-date. Run `rake` before committing."
end
end
task default: %i[spec yard rubocop]