Added task for wiki autogeneration.
This commit is contained in:
parent
2dcdec1191
commit
4db326a3ed
|
@ -6,4 +6,5 @@ doc
|
||||||
heckling
|
heckling
|
||||||
pkg
|
pkg
|
||||||
specdoc
|
specdoc
|
||||||
|
wiki
|
||||||
.google-api.yaml
|
.google-api.yaml
|
||||||
|
|
|
@ -85,14 +85,29 @@ module Google
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns the parsed section of the discovery document that applies to
|
# Returns a human-readable title for the API.
|
||||||
# this version of the service.
|
|
||||||
#
|
#
|
||||||
# @return [Hash] The service description.
|
# @return [Hash] The API title.
|
||||||
|
def title
|
||||||
|
return @discovery_document['title']
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a human-readable description of the API.
|
||||||
|
#
|
||||||
|
# @return [Hash] The API description.
|
||||||
def description
|
def description
|
||||||
return @discovery_document['description']
|
return @discovery_document['description']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a URI for the API documentation.
|
||||||
|
#
|
||||||
|
# @return [Hash] The API documentation.
|
||||||
|
def documentation
|
||||||
|
return Addressable::URI.parse(@discovery_document['documentationLink'])
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns true if this is the preferred version of this API.
|
# Returns true if this is the preferred version of this API.
|
||||||
#
|
#
|
||||||
|
@ -216,6 +231,12 @@ module Google
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Allows deep inspection of the discovery document.
|
||||||
|
def [](key)
|
||||||
|
return @discovery_document[key]
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Converts the service to a flat mapping of RPC names and method objects.
|
# Converts the service to a flat mapping of RPC names and method objects.
|
||||||
#
|
#
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
require 'google/api_client'
|
||||||
|
|
||||||
|
CACHE_PREFIX =
|
||||||
|
"http://www.gmodules.com/gadgets/proxy/container=default&debug=0&nocache=0/"
|
||||||
|
|
||||||
|
namespace :wiki do
|
||||||
|
desc 'Autogenerate wiki pages'
|
||||||
|
task :generate do
|
||||||
|
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 = {}
|
||||||
|
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
|
||||||
|
output += (
|
||||||
|
"||#{CACHE_PREFIX}#{api['icons']['x16']}||" +
|
||||||
|
"[#{api.documentation} #{api.title}]||" +
|
||||||
|
"#{api.description}||\n"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
wiki_path = File.expand_path(
|
||||||
|
File.join(File.dirname(__FILE__), '../wiki/'))
|
||||||
|
Dir.mkdir(wiki_path) if !File.exist?(wiki_path)
|
||||||
|
File.open(File.join(wiki_path, 'SupportedAPIs.wiki'), 'w') do |file|
|
||||||
|
file.write(output)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# task 'clobber' => ['wiki:clobber_wiki']
|
Loading…
Reference in New Issue