-
Notifications
You must be signed in to change notification settings - Fork 132
/
Rakefile
109 lines (86 loc) · 2.38 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "spec/*_spec.rb"
t.libs << "spec"
end
task :default => :test
task :spec => :test
require 'sdoc'
require 'rdoc/task'
require 'rails/api/task'
rails = File.expand_path "rails"
ruby = File.expand_path "ruby"
directory rails do
sh "git clone --depth=1 https://github.com/rails/rails"
end
directory ruby do
sh "git clone --depth=1 https://github.com/ruby/ruby"
end
class RailsTask < Rails::API::EdgeTask
def configure_sdoc
options << "--root" << "rails"
super
self.title = nil # Use default title for local testing.
end
def rails_version
Dir.chdir "rails" do
super
end
end
def api_dir
"doc/rails"
end
def component_root_dir(component)
File.join("rails", component)
end
def setup_horo_variables
super
ENV["HORO_BADGE_VERSION"] ||= "edge" if ENV["HORO_PROJECT_VERSION"]&.include?("@")
if ENV['NETLIFY']
ENV['HORO_CANONICAL_URL'] = ENV.fetch('DEPLOY_PRIME_URL', 'https://edgeapi.rubyonrails.org')
end
end
end
namespace :test do
desc 'Deletes all generated test documentation'
task :reset_docs do
FileUtils.remove_dir(File.expand_path('doc'), force: true)
end
desc 'Generates test rails documentation'
task :rails => [rails, :generate_rails] do
FileUtils.mv(
File.expand_path('rails/doc/rails'),
File.expand_path('doc/public')
)
end
RailsTask.new(:generate_rails)
desc 'Generates test ruby documentation'
task :ruby => [ruby, :generate_ruby] do
FileUtils.mv(
File.expand_path('doc/ruby'),
File.expand_path('doc/public')
)
end
RDoc::Task.new(:generate_ruby) do |rdoc|
rdoc.rdoc_dir = 'doc/ruby'
rdoc.generator = 'sdoc'
rdoc.template = 'rails'
rdoc.title = 'Ruby'
rdoc.main = 'ruby/README.md'
rdoc.rdoc_files.include("ruby/")
end
end
ASSETS_PATH = "lib/rdoc/generator/template/rails/resources"
desc "Download and vendor JavaScript assets"
task :vendor_javascript do
module Importmap; end
require "importmap/packager"
packager = Importmap::Packager.new(vendor_path: "#{ASSETS_PATH}/js")
imports = packager.import("@hotwired/turbo", from: "unpkg")
imports.each do |package, url|
puts %(Vendoring "#{package}" to #{packager.vendor_path}/#{package}.js via download from #{url})
packager.download(package, url)
end
end