2011-12-02 14:24:56 +00:00
|
|
|
require 'rake'
|
|
|
|
require 'rake/clean'
|
|
|
|
|
|
|
|
CLOBBER.include('wiki')
|
2011-10-15 08:22:36 +00:00
|
|
|
|
|
|
|
CACHE_PREFIX =
|
|
|
|
"http://www.gmodules.com/gadgets/proxy/container=default&debug=0&nocache=0/"
|
|
|
|
|
|
|
|
namespace :wiki do
|
|
|
|
desc 'Autogenerate wiki pages'
|
2011-12-02 14:24:56 +00:00
|
|
|
task :supported_apis do
|
2011-10-15 08:22:36 +00:00
|
|
|
output = <<-WIKI
|
|
|
|
#summary The list of supported APIs
|
|
|
|
|
|
|
|
The Google API Client for Ruby is a small flexible client library for accessing
|
|
|
|
the following Google APIs.
|
|
|
|
|
|
|
|
WIKI
|
|
|
|
preferred_apis = {}
|
2012-05-24 12:29:58 +00:00
|
|
|
require 'google/api_client'
|
2011-10-15 08:22:36 +00:00
|
|
|
client = Google::APIClient.new
|
|
|
|
for api in client.discovered_apis
|
|
|
|
if !preferred_apis.has_key?(api.name)
|
|
|
|
preferred_apis[api.name] = api
|
|
|
|
elsif api.preferred
|
|
|
|
preferred_apis[api.name] = api
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for api_name, api in preferred_apis
|
2011-12-02 14:24:56 +00:00
|
|
|
if api.documentation.to_s != "" && api.title != ""
|
|
|
|
output += (
|
|
|
|
"||#{CACHE_PREFIX}#{api['icons']['x16']}||" +
|
|
|
|
"[#{api.documentation} #{api.title}]||" +
|
|
|
|
"#{api.description}||\n"
|
|
|
|
)
|
|
|
|
end
|
2011-10-15 08:22:36 +00:00
|
|
|
end
|
2011-12-02 14:24:56 +00:00
|
|
|
output.gsub!(/-32\./, "-16.")
|
2011-10-15 08:22:36 +00:00
|
|
|
wiki_path = File.expand_path(
|
|
|
|
File.join(File.dirname(__FILE__), '../wiki/'))
|
2014-09-17 14:55:52 +00:00
|
|
|
Dir.mkdir(wiki_path) unless File.exists?(wiki_path)
|
2011-10-15 08:22:36 +00:00
|
|
|
File.open(File.join(wiki_path, 'SupportedAPIs.wiki'), 'w') do |file|
|
|
|
|
file.write(output)
|
|
|
|
end
|
|
|
|
end
|
2011-12-02 14:24:56 +00:00
|
|
|
|
|
|
|
task 'generate' => ['wiki:supported_apis']
|
2011-10-15 08:22:36 +00:00
|
|
|
end
|
|
|
|
|
2011-12-02 14:24:56 +00:00
|
|
|
begin
|
2012-01-27 14:57:57 +00:00
|
|
|
$LOAD_PATH.unshift(
|
|
|
|
File.expand_path(File.join(File.dirname(__FILE__), '../yard/lib'))
|
|
|
|
)
|
|
|
|
$LOAD_PATH.unshift(File.expand_path('.'))
|
|
|
|
$LOAD_PATH.uniq!
|
|
|
|
|
2011-12-02 14:24:56 +00:00
|
|
|
require 'yard'
|
|
|
|
require 'yard/rake/wikidoc_task'
|
|
|
|
|
|
|
|
namespace :wiki do
|
|
|
|
desc 'Generate Wiki Documentation with YARD'
|
|
|
|
YARD::Rake::WikidocTask.new do |yardoc|
|
|
|
|
yardoc.name = 'reference'
|
|
|
|
yardoc.options = [
|
|
|
|
'--verbose',
|
2012-01-27 14:57:57 +00:00
|
|
|
'--markup', 'markdown',
|
2011-12-02 14:24:56 +00:00
|
|
|
'-e', 'yard/lib/yard-google-code.rb',
|
|
|
|
'-p', 'yard/templates',
|
|
|
|
'-f', 'wiki',
|
|
|
|
'-o', 'wiki'
|
|
|
|
]
|
|
|
|
yardoc.files = [
|
|
|
|
'lib/**/*.rb', 'ext/**/*.c', '-', 'README.md', 'CHANGELOG.md'
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
task 'generate' => ['wiki:reference', 'wiki:supported_apis']
|
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
# If yard isn't available, it's not the end of the world
|
|
|
|
warn('YARD unavailable. Cannot fully generate wiki.')
|
|
|
|
end
|