Merge remote branch 'remotes/upstream/master'
[arvados.git] / tasks / wiki.rake
1 require 'google/api_client'
2
3 CACHE_PREFIX =
4   "http://www.gmodules.com/gadgets/proxy/container=default&debug=0&nocache=0/"
5
6 namespace :wiki do
7   desc 'Autogenerate wiki pages'
8   task :generate do
9     output = <<-WIKI
10 #summary The list of supported APIs
11
12 The Google API Client for Ruby is a small flexible client library for accessing
13 the following Google APIs.
14
15 WIKI
16     preferred_apis = {}
17     client = Google::APIClient.new
18     for api in client.discovered_apis
19       if !preferred_apis.has_key?(api.name)
20         preferred_apis[api.name] = api
21       elsif api.preferred
22         preferred_apis[api.name] = api
23       end
24     end
25     for api_name, api in preferred_apis
26       output += (
27         "||#{CACHE_PREFIX}#{api['icons']['x16']}||" +
28         "[#{api.documentation} #{api.title}]||" +
29         "#{api.description}||\n"
30       )
31     end
32     wiki_path = File.expand_path(
33       File.join(File.dirname(__FILE__), '../wiki/'))
34     Dir.mkdir(wiki_path) if !File.exist?(wiki_path)
35     File.open(File.join(wiki_path, 'SupportedAPIs.wiki'), 'w') do |file|
36       file.write(output)
37     end
38   end
39 end
40
41 # task 'clobber' => ['wiki:clobber_wiki']