in doc-src/templates/api-versions/model_documentor.rb [259:345]
def initialize(operation_name, operation, api, klass, options = {}, examples = {})
desc = documentation(operation)
desc ||= "Calls the #{method_name(operation_name, false)} API operation."
desc = desc.gsub(/^\s+/, '').strip
if klass === 'S3' && (['CreateBucket', 'ListBuckets', 'DeleteBucket'].include? operation_name)
desc = desc + '<p>Note: This operation cannot be used in a browser. S3 does not support CORS on this operation.</p>'
end
event_stream_output(operation, api)
if options[:flatten_dynamodb_attrs]
desc = ""
end
@lines = [desc, '']
@lines << "@param params [Object]"
@lines += shapes(api, operation['input'], {:in_output => false}.merge(options)).map {|line| " " + line }
if examples
examples.each do |example|
begin
sharedExample = generate_shared_example(api, example, klass, method_name(operation_name)).split("\n").map {|line| " " + line}
@lines << "@example #{example['title']}"
@lines << ""
@lines << " /* #{example['description']} */"
@lines << ""
@lines << sharedExample
rescue => exception
puts "[warn]: Error encountered generating example for #{klass}.#{operation_name}: #{exception}"
end
end
end
if @eventStreamOutputShape
@lines << event_stream_output_examples(klass, operation_name, operation, api)
end
@lines << "@example Calling the #{method_name(operation_name)} operation"
@lines << generate_example(api, klass, method_name(operation_name),
operation['input'], options).split("\n").map {|line| " " + line }
@lines << ""
@lines << "@callback callback function(err, data)"
@lines << " Called when a response from the service is returned. If a"
@lines << " callback is not supplied, you must call {AWS.Request.send}"
@lines << " on the returned request object to initiate the request."
@lines << " @context [AWS.Response] the response object containing error, " +
"data properties, and the original request object."
@lines << " @param err [Error] the error object returned from the request."
@lines << " Set to `null` if the request is successful."
@lines << " @param data [Object] the de-serialized data returned from"
@lines << " the request. Set to `null` if a request error occurs."
output = shapes(api, operation['output'], {:in_output => true}.merge(options))
output = output.map {|line| " " + line }
if output.size > 0
@lines << " The `data` object has the following properties:"
@lines << ""
@lines += output
end
@lines << "@return [AWS.Request] a handle to the operation request for"
@lines << " subsequent event callback registration."
if operation['documentation_url']
@lines << "@see #{operation['documentation_url']}"
@lines << " #{api['serviceAbbreviation']} Documentation for #{operation_name}"
end
if api['metadata']['uid']
@lines << '<div class="tags">'
@lines << '<p class="tag_title">Service Reference:</p>'
@lines << '<ul class="see">'
@lines << '<li><a href="/goto/WebAPI/' + api['metadata']['uid'] + '/' + operation_name + '">' + operation_name + '</a></li>'
@lines << '</ul>'
@lines << '</div>'
end
end