-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathdocs.rake
48 lines (38 loc) · 1.38 KB
/
docs.rake
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
# frozen_string_literal: true
require 'fileutils'
task 'docs:clobber' do
FileUtils.remove_dir('api-docs') if Dir.exist?('api-docs')
end
task 'docs:set-env' do
ENV['DOCSTRINGS'] = '1'
ENV['SITEMAP_BASEURL'] = 'http://docs.aws.amazon.com/sdk-for-ruby/v3/api/'
ENV['BASEURL'] = 'http://docs.aws.amazon.com/'
end
# return a list of all of the other SDK gems this gem depends on
# sdk gems are only those in the /gems folder that are authored here
def sdk_dependencies(sdk_gem)
require 'rubygems'
all_gems = Dir.glob("gems/*").to_a
spec = Gem::Specification::load("gems/#{sdk_gem}/#{sdk_gem}.gemspec")
puts "Gemspec loaded"
spec.dependencies.select do |d|
all_gems.any? { |g| g.include? d.name }
end.map { |d| d.name }
end
desc 'Builds API documentation for a single gem (and its dependencies), e.g. docs:aws-sdk-s3'
task 'docs:*'
rule /^docs:.+$/ => %w[docs:clobber docs:set-env] do |task|
require 'yard'
gem = task.name.split(':').last
gems = sdk_dependencies(gem) + [gem]
yardoc = YARD::CLI::Yardoc.new
yardoc.parse_arguments
# overwrite the files to parse/generated api docs for
yardoc.files = gems.map { |g| "gems/#{g}/lib/**/*.rb" }
yardoc.run(nil) # ensure parse_arguments is not called again
end
desc 'Builds the API documentation for the AWS SDK for Ruby.'
task 'docs' => %w[docs:clobber docs:set-env] do
require 'yard'
YARD::CLI::Yardoc.new.run
end