Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bugs in documentation tool #1140

Merged
merged 1 commit into from
Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc-src/templates/api-versions/model_documentor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def example
if operation_input
input_shape_name = operation_input['shape']
input_shape = @api['shapes'][input_shape_name]
input = visit(input_shape, @example['input'], "", [], @comments['input'])
input = visit(input_shape, @example['input'] || {}, "", [], @comments['input'])
else
input = "{}"
end
Expand All @@ -214,7 +214,7 @@ def example
if operation_output
output_shape_name = operation_output['shape']
output_shape = @api['shapes'][output_shape_name]
if output = visit(output_shape, @example['output'], " ", [], @comments['output'])
if output = visit(output_shape, @example['output'] || {}, " ", [], @comments['output'])
lines << " /*"
lines << " data = #{output}"
lines << " */"
Expand Down
10 changes: 5 additions & 5 deletions doc-src/templates/api-versions/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def generate_api(file, version_suffix = true)
model = load_model(file)
$dynamodb_model = model if klass == 'DynamoDB' && version == '2012-08-10'
add_class_documentation(svc, klass, model, version, dualstack)
add_methods(svc, klass, model)
add_methods(svc, klass, version, model)
add_waiters(svc, klass, model)
add_config(svc, identifier, dualstack)

Expand Down Expand Up @@ -167,8 +167,8 @@ def add_class_documentation(service, klass, model, api_version, dualstack)

end

def add_methods(service, klass, model)
examples = load_examples(klass.downcase) || {}
def add_methods(service, klass, version, model)
examples = load_examples(klass.downcase, version) || {}
model['operations'].each_pair do |name, operation|
meth = YARDJS::CodeObjects::PropertyObject.new(service, name[0].downcase + name[1..-1])
docs = MethodDocumentor.new(name, operation, model, klass, {}, examples[name]).lines.join("\n")
Expand Down Expand Up @@ -275,8 +275,8 @@ def class_info_for(prefix)
raise "Unknown class name for #{prefix}"
end

def load_examples(name)
paths = Dir[File.join($APIS_DIR, "#{name}-*.examples.json")]
def load_examples(name, version)
paths = Dir[File.join($APIS_DIR, "#{name}-#{version}.examples.json")]
unless paths.empty?
json = JSON.parse(File.read(paths[0]))
json['examples']
Expand Down