moduleAwsmoduleApimoduleDocsclassOperationDocumenterincludeSeahorse::ModelincludeUtilsdefinitialize(service_name,namespace,uid)@service_name=service_name@namespace=namespace@optname='options'@uid=uidend# @param [Symbol] method_name# @param [Seahorse::Model::Opeation] operationdefdocument(method_name,operation)m=YARD::CodeObjects::MethodObject.new(@namespace,method_name)m.group='API Operations'm.scope=:instancem.parameters<<[@optname,'{}']m.docstring=operation.documentationtags(method_name,operation).eachdo|tag|m.add_tag(tag)endendprivatedeftags(method_name,operation)tags=[]tags+=param_tags(method_name,operation)tags+=option_tags(method_name,operation)tags+=return_tags(method_name,operation)tags+=example_tags(method_name,operation)tags+=see_also_tags(method_name,operation)enddefparam_tags(method_name,operation)[]enddefoption_tags(method_name,operation)operation_input_ref(operation).shape.members.mapdo|name,ref|req=ref.required?'required,':''type=input_type(ref)docstring="@option #{@optname} [#{req}#{type}] :#{name}\n"docstring<<"\n\n This parameter will be auto-filled on your behalf"\" with a random UUIDv4 when no value is provided.\n"ifref['idempotencyToken']docstring<<"\n\n SDK automatically handles json encoding and base64 encoding"\" for you when the required value (Hash, Array, etc.) is provided according to the description.\n"ifref['jsonvalue']docstring+=ref.documentation.to_s.lines.map{|line|" #{line}"}.jointag(docstring)endenddefreturn_tags(method_name,operation)resp='{Seahorse::Client::Response response}'ifoperation.output&&operation.output.shape.members.count>0rtype=output_type(operation.output)returns="[#{rtype}] Returns a #{resp} object which responds to "returns<<"the following methods:\n\n"operation.output.shape.members.eachdo|mname,mref|mtype=output_type(mref,true).gsub(/</,'<').gsub(/>/,'>')returns<<" * {#{rtype}##{mname} ##{mname}} => #{mtype}\n"endelsereturns="[Struct] Returns an empty #{resp}."end[tag("@return #{returns}")]enddefexample_tags(method_name,operation)shared_examples(method_name,operation)+examples_from_disk(method_name,operation)+[request_syntax_example(method_name,operation),response_structure_example(method_name,operation),].compactenddefshared_examples(method_name,operation)ifoperation['examples']operation['examples'].mapdo|example|shared_example(example,method_name,operation)end.compactelse[]endenddefshared_example(json_ex,method_name,operation)begin# disable broken examplesinput_comments=json_ex['comments']['input']input=SharedExample.new(json_ex['input'],method_name,operation,input_comments).to_str_inputparts=[]parts<<"@example Example: #{json_ex['title']}\n\n"parts<<" # #{json_ex['description']}\n\n"parts+=input.lines.map{|line|" "+line}ifjson_ex['output']output_comments=json_ex['comments']['output']output=SharedExample.new(json_ex['output'],method_name,operation,output_comments).to_str_outputparts<<"\n\n # resp.to_h outputs the following:\n"parts+=output.lines.map{|line|" "+line}endtag(parts.join)rescuenilendenddefexamples_from_disk(method_name,operation)dir="doc-src/examples/#{@service_name.downcase}/client/#{method_name}/*.rb"Dir.glob(dir).mapdo|path|title=File.basename(path).split(/\./).firsttitle=title.sub(/^\d+_/,'').gsub(/_/,' ')title=title[0].upcase+title[1..-1]tag("@example #{title}\n\n "+File.read(path).lines.join(' '))endenddefrequest_syntax_example(method_name,operation)example=RequestSyntaxExample.new(method_name,operation).to_strparts=[]parts<<"@example Request syntax with placeholder values\n\n"parts+=example.lines.map{|line|" "+line}tag(parts.join)enddefresponse_structure_example(method_name,operation)ifexample=ResponseStructureExample.new(method_name,operation).to_strparts=[]parts<<"@example Response structure\n\n"parts+=example.lines.map{|line|" "+line}tag(parts.join)endenddefsee_also_tags(method_name,operation)ifCrosslink.taggable?(@uid)[tag(Crosslink.tag_string(@uid,operation.name))]else[]endendendendendend