Class: Aws::Resources::Documenter::HasOperationDocumenter

Inherits:
BaseOperationDocumenter show all
Defined in:
aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb

Instance Attribute Summary

Attributes inherited from BaseOperationDocumenter

#api_request, #api_request_name, #api_request_params, #builder, #called_operation, #operation_name, #resource_class, #resource_class_name, #source, #target_resource_class, #target_resource_class_name, #yard_class

Instance Method Summary collapse

Methods inherited from BaseOperationDocumenter

#initialize, #method_object

Constructor Details

This class inherits a constructor from Aws::Resources::Documenter::BaseOperationDocumenter

Instance Method Details

#argument?Boolean


76
77
78
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 76

def argument?
  @operation.arity > 0
end

#argument_nameObject


92
93
94
95
96
97
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 92

def argument_name
  argument = builder.sources.find do |source|
    BuilderSources::Argument === source
  end
  argument.target.to_s
end

#can_return_nil?Boolean


80
81
82
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 80

def can_return_nil?
  data_member
end

#data_memberObject


84
85
86
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 84

def data_member
  builder.sources.find { |s| BuilderSources::DataMember === s }
end

#data_member_sourceObject


88
89
90
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 88

def data_member_source
  data_member.source
end

#docstringObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 6

def docstring
  docs = []
  docs << super

  if can_return_nil?
    docs << return_message
  elsif argument?
    msg = "Returns a {#{target_resource_class}} resource with "
    msg << "the given `#{argument_name}`."
    docs << msg
  else
    docs << "Returns a {#{target_resource_class}} resource."
  end

  if data_member && resource_class.load_operation
    load_method = resource_class.load_operation.request.method_name
    msg = "Calling this method will call {Client##{load_method}} "
    msg << "unless the resource is already {#data_loaded? loaded}. "
    msg << "No additional API requests are made."
    docs << msg
  else
    msg = "Calling this method will **not** make an API request."
    docs << msg
  end

  docs.join(' ')
end

#parametersObject


53
54
55
56
57
58
59
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 53

def parameters
  if argument?
    [[argument_name, nil]]
  else
    []
  end
end

#plural?Boolean


72
73
74
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 72

def plural?
  @operation.builder.plural?
end

#return_messageObject


44
45
46
47
48
49
50
51
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 44

def return_message
  if can_return_nil?
    "Returns a {#{target_resource_class_name}} resource, or `nil` " +
    "if `#data.#{data_member_source}` is `nil`."
  else
    "Returns a {#{target_resource_class_name}} resource."
  end
end

#return_typeObject


34
35
36
37
38
39
40
41
42
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 34

def return_type
  if plural?
    type = ["Array<#{target_resource_class_name}>"]
  else
    type = [target_resource_class_name]
  end
  type << 'nil' if can_return_nil?
  type
end

#tagsObject


61
62
63
64
65
66
67
68
69
70
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_operation_documenter.rb', line 61

def tags
  tags = super
  if argument?
    tag = "@param [String] #{argument_name} "
    tag << "The {#{target_resource_class_name}##{argument_name}} "
    tag << "identifier."
    tags += YARD::DocstringParser.new.parse(tag).to_docstring.tags
  end
  tags
end