aws-sdk-code-generator 0.1.0.pre → 0.2.4.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/lib/aws-sdk-code-generator/api.rb +150 -0
  3. data/lib/aws-sdk-code-generator/apply_docs.rb +15 -2
  4. data/lib/aws-sdk-code-generator/client_constructor.rb +39 -0
  5. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +282 -0
  6. data/lib/aws-sdk-code-generator/client_operation_list.rb +148 -0
  7. data/lib/aws-sdk-code-generator/client_response_structure_example.rb +115 -0
  8. data/lib/aws-sdk-code-generator/code_builder.rb +146 -133
  9. data/lib/aws-sdk-code-generator/crosslink.rb +42 -0
  10. data/lib/aws-sdk-code-generator/docstring.rb +199 -0
  11. data/lib/aws-sdk-code-generator/error_list.rb +77 -0
  12. data/lib/aws-sdk-code-generator/errors.rb +2 -0
  13. data/lib/aws-sdk-code-generator/eventstream_example.rb +220 -0
  14. data/lib/aws-sdk-code-generator/gem_builder.rb +42 -25
  15. data/lib/aws-sdk-code-generator/hash_formatter.rb +5 -2
  16. data/lib/aws-sdk-code-generator/helper.rb +86 -119
  17. data/lib/aws-sdk-code-generator/plugin_list.rb +147 -0
  18. data/lib/aws-sdk-code-generator/resource_action.rb +69 -0
  19. data/lib/aws-sdk-code-generator/resource_action_code.rb +57 -0
  20. data/lib/aws-sdk-code-generator/resource_association.rb +37 -0
  21. data/lib/aws-sdk-code-generator/resource_attribute.rb +76 -0
  22. data/lib/aws-sdk-code-generator/resource_batch_action.rb +56 -0
  23. data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +136 -0
  24. data/lib/aws-sdk-code-generator/resource_batch_action_documentation.rb +108 -0
  25. data/lib/aws-sdk-code-generator/resource_batch_builder.rb +212 -0
  26. data/lib/aws-sdk-code-generator/resource_builder.rb +48 -0
  27. data/lib/aws-sdk-code-generator/resource_client_request.rb +62 -0
  28. data/lib/aws-sdk-code-generator/resource_client_request_documentation.rb +81 -0
  29. data/lib/aws-sdk-code-generator/resource_client_request_params.rb +86 -0
  30. data/lib/aws-sdk-code-generator/resource_data_method.rb +60 -0
  31. data/lib/aws-sdk-code-generator/resource_has_association.rb +117 -0
  32. data/lib/aws-sdk-code-generator/resource_has_many_association.rb +52 -0
  33. data/lib/aws-sdk-code-generator/resource_has_many_association_code.rb +76 -0
  34. data/lib/aws-sdk-code-generator/resource_identifier.rb +44 -0
  35. data/lib/aws-sdk-code-generator/resource_identifiers_method.rb +29 -0
  36. data/lib/aws-sdk-code-generator/resource_load_method.rb +68 -0
  37. data/lib/aws-sdk-code-generator/resource_method.rb +22 -0
  38. data/lib/aws-sdk-code-generator/resource_skip_params.rb +36 -0
  39. data/lib/aws-sdk-code-generator/resource_value_source.rb +68 -0
  40. data/lib/aws-sdk-code-generator/resource_waiter.rb +80 -0
  41. data/lib/aws-sdk-code-generator/service.rb +30 -7
  42. data/lib/aws-sdk-code-generator/shared_example.rb +131 -0
  43. data/lib/aws-sdk-code-generator/syntax_example.rb +60 -0
  44. data/lib/aws-sdk-code-generator/syntax_example_hash.rb +174 -0
  45. data/lib/aws-sdk-code-generator/underscore.rb +10 -5
  46. data/lib/aws-sdk-code-generator/view.rb +33 -0
  47. data/lib/aws-sdk-code-generator/views/apig_endpoint_class.rb +25 -0
  48. data/lib/aws-sdk-code-generator/views/apig_readme.rb +32 -0
  49. data/lib/aws-sdk-code-generator/views/async_client_class.rb +68 -0
  50. data/lib/aws-sdk-code-generator/views/authorizer_class.rb +17 -0
  51. data/lib/aws-sdk-code-generator/views/client_api_module.rb +602 -0
  52. data/lib/aws-sdk-code-generator/views/client_class.rb +93 -0
  53. data/lib/aws-sdk-code-generator/views/docstring.rb +27 -0
  54. data/lib/aws-sdk-code-generator/views/errors_module.rb +32 -0
  55. data/lib/aws-sdk-code-generator/views/event_streams_module.rb +149 -0
  56. data/lib/aws-sdk-code-generator/views/features/env.rb +9 -0
  57. data/lib/aws-sdk-code-generator/views/features/smoke.rb +52 -0
  58. data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +26 -0
  59. data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +6 -2
  60. data/lib/aws-sdk-code-generator/views/gemspec.rb +39 -5
  61. data/lib/aws-sdk-code-generator/views/resource_class.rb +122 -0
  62. data/lib/aws-sdk-code-generator/views/root_resource_class.rb +58 -0
  63. data/lib/aws-sdk-code-generator/views/service_module.rb +38 -14
  64. data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -0
  65. data/lib/aws-sdk-code-generator/views/types_module.rb +329 -0
  66. data/lib/aws-sdk-code-generator/views/version.rb +2 -0
  67. data/lib/aws-sdk-code-generator/views/waiters_module.rb +37 -0
  68. data/lib/aws-sdk-code-generator/views.rb +2 -0
  69. data/lib/aws-sdk-code-generator/waiter.rb +95 -0
  70. data/lib/aws-sdk-code-generator/yard_option_tag.rb +43 -0
  71. data/lib/aws-sdk-code-generator.rb +68 -75
  72. data/templates/apig_endpoint_class.mustache +16 -0
  73. data/templates/apig_readme.mustache +62 -0
  74. data/templates/async_client_class.mustache +125 -0
  75. data/templates/authorizer_class.mustache +37 -0
  76. data/templates/client_api_module.mustache +106 -0
  77. data/templates/client_class.mustache +295 -0
  78. data/templates/code.mustache +4 -0
  79. data/templates/documentation.mustache +4 -0
  80. data/templates/errors_module.mustache +70 -0
  81. data/templates/event_streams_module.mustache +76 -0
  82. data/templates/features/env.mustache +15 -0
  83. data/templates/features/smoke.mustache +22 -0
  84. data/templates/features/smoke_step_definitions.mustache +31 -0
  85. data/templates/features/step_definitions.mustache +13 -0
  86. data/templates/gemspec.mustache +31 -0
  87. data/templates/license.txt +202 -0
  88. data/templates/method.mustache +7 -0
  89. data/templates/resource_class.mustache +304 -0
  90. data/templates/root_resource_class.mustache +51 -0
  91. data/templates/service_module.mustache +58 -0
  92. data/templates/spec/spec_helper.mustache +15 -0
  93. data/templates/types_module.mustache +53 -0
  94. data/templates/version.mustache +1 -0
  95. data/templates/waiters_module.mustache +112 -0
  96. metadata +115 -70
  97. data/lib/aws-sdk-code-generator/dsl/access_control_statement.rb +0 -23
  98. data/lib/aws-sdk-code-generator/dsl/attribute_accessor.rb +0 -43
  99. data/lib/aws-sdk-code-generator/dsl/attribute_reader.rb +0 -11
  100. data/lib/aws-sdk-code-generator/dsl/attribute_writer.rb +0 -11
  101. data/lib/aws-sdk-code-generator/dsl/autoload_statement.rb +0 -15
  102. data/lib/aws-sdk-code-generator/dsl/block_param.rb +0 -11
  103. data/lib/aws-sdk-code-generator/dsl/class.rb +0 -27
  104. data/lib/aws-sdk-code-generator/dsl/code_literal.rb +0 -66
  105. data/lib/aws-sdk-code-generator/dsl/code_object.rb +0 -33
  106. data/lib/aws-sdk-code-generator/dsl/docstring.rb +0 -36
  107. data/lib/aws-sdk-code-generator/dsl/eigenclass.rb +0 -15
  108. data/lib/aws-sdk-code-generator/dsl/extend_statement.rb +0 -12
  109. data/lib/aws-sdk-code-generator/dsl/formatter.rb +0 -25
  110. data/lib/aws-sdk-code-generator/dsl/include_statement.rb +0 -17
  111. data/lib/aws-sdk-code-generator/dsl/main.rb +0 -105
  112. data/lib/aws-sdk-code-generator/dsl/method.rb +0 -108
  113. data/lib/aws-sdk-code-generator/dsl/module.rb +0 -167
  114. data/lib/aws-sdk-code-generator/dsl/option_tag.rb +0 -36
  115. data/lib/aws-sdk-code-generator/dsl/param.rb +0 -43
  116. data/lib/aws-sdk-code-generator/dsl/param_list.rb +0 -38
  117. data/lib/aws-sdk-code-generator/dsl/return_tag.rb +0 -19
  118. data/lib/aws-sdk-code-generator/dsl/tag_default.rb +0 -20
  119. data/lib/aws-sdk-code-generator/dsl/tag_docstring.rb +0 -27
  120. data/lib/aws-sdk-code-generator/dsl/tag_type.rb +0 -18
  121. data/lib/aws-sdk-code-generator/generators/client_api_module.rb +0 -334
  122. data/lib/aws-sdk-code-generator/generators/client_class.rb +0 -389
  123. data/lib/aws-sdk-code-generator/generators/client_operation_documentation.rb +0 -166
  124. data/lib/aws-sdk-code-generator/generators/errors_module.rb +0 -25
  125. data/lib/aws-sdk-code-generator/generators/resource/action.rb +0 -88
  126. data/lib/aws-sdk-code-generator/generators/resource/batch_builder.rb +0 -211
  127. data/lib/aws-sdk-code-generator/generators/resource/builder.rb +0 -50
  128. data/lib/aws-sdk-code-generator/generators/resource/client_getter.rb +0 -15
  129. data/lib/aws-sdk-code-generator/generators/resource/client_request.rb +0 -49
  130. data/lib/aws-sdk-code-generator/generators/resource/client_request_docs.rb +0 -97
  131. data/lib/aws-sdk-code-generator/generators/resource/client_request_params.rb +0 -88
  132. data/lib/aws-sdk-code-generator/generators/resource/collection_class.rb +0 -180
  133. data/lib/aws-sdk-code-generator/generators/resource/data_attribute_getter.rb +0 -24
  134. data/lib/aws-sdk-code-generator/generators/resource/data_loaded_method.rb +0 -18
  135. data/lib/aws-sdk-code-generator/generators/resource/data_method.rb +0 -49
  136. data/lib/aws-sdk-code-generator/generators/resource/exists_method.rb +0 -29
  137. data/lib/aws-sdk-code-generator/generators/resource/extract_identifier_method.rb +0 -32
  138. data/lib/aws-sdk-code-generator/generators/resource/has_association.rb +0 -101
  139. data/lib/aws-sdk-code-generator/generators/resource/has_many_association.rb +0 -108
  140. data/lib/aws-sdk-code-generator/generators/resource/identifier_getter.rb +0 -26
  141. data/lib/aws-sdk-code-generator/generators/resource/identifiers_method.rb +0 -28
  142. data/lib/aws-sdk-code-generator/generators/resource/initialize_method.rb +0 -67
  143. data/lib/aws-sdk-code-generator/generators/resource/load_method.rb +0 -65
  144. data/lib/aws-sdk-code-generator/generators/resource/value_source.rb +0 -68
  145. data/lib/aws-sdk-code-generator/generators/resource/waiter_method.rb +0 -61
  146. data/lib/aws-sdk-code-generator/generators/resource_class.rb +0 -325
  147. data/lib/aws-sdk-code-generator/generators/response_structure_example.rb +0 -83
  148. data/lib/aws-sdk-code-generator/generators/root_resource_class.rb +0 -42
  149. data/lib/aws-sdk-code-generator/generators/service_documentation.rb +0 -64
  150. data/lib/aws-sdk-code-generator/generators/shared_example.rb +0 -132
  151. data/lib/aws-sdk-code-generator/generators/structure_type_class.rb +0 -95
  152. data/lib/aws-sdk-code-generator/generators/syntax_example.rb +0 -169
  153. data/lib/aws-sdk-code-generator/generators/types_module.rb +0 -52
  154. data/lib/aws-sdk-code-generator/generators/waiter_class.rb +0 -62
  155. data/lib/aws-sdk-code-generator/generators/waiters_module.rb +0 -20
@@ -1,17 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class IncludeStatement
4
-
5
- include Dsl::CodeObject
6
-
7
- def initialize(module_name)
8
- @module_name = module_name
9
- end
10
-
11
- def lines
12
- ["include #{@module_name}"]
13
- end
14
-
15
- end
16
- end
17
- end
@@ -1,105 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Main
4
-
5
- include Dsl::CodeObject
6
-
7
- # @option options [Main, Module] :parent (nil)
8
- def initialize(options = {}, &block)
9
- @comments = Docstring.new(nil)
10
- @top_content = []
11
- @code_objects = []
12
- @parent = options.fetch(:parent, nil)
13
- yield(self) if block
14
- end
15
-
16
- # @return [nil, CodeObject]
17
- attr_accessor :parent
18
-
19
- # @return [nil, CodeObject]
20
- def root
21
- root = self
22
- root = root.parent while root && root.parent
23
- root
24
- end
25
-
26
- def add(*code_objects)
27
- code_objects.each do |code_obj|
28
- @code_objects << code_obj unless code_obj.nil?
29
- end
30
- end
31
-
32
- def code(code = nil, &block)
33
- @code_objects << CodeLiteral.new(code, &block)
34
- end
35
-
36
- def comments(docstring)
37
- @comments = Docstring.new(docstring)
38
- end
39
-
40
- def include_module(module_name)
41
- add(IncludeStatement.new(module_name))
42
- end
43
- alias :include :include_module
44
-
45
- def extend_module(module_name)
46
- add(ExtendStatement.new(module_name))
47
- end
48
- alias :extend :extend_module
49
-
50
- def require_statement(path)
51
- @top_content << "require '#{path}'"
52
- end
53
- alias require require_statement
54
-
55
- # Allows inserting top-of document content.
56
- def top(string)
57
- root.instance_variable_get("@top_content") << string
58
- end
59
-
60
- def require_relative(path)
61
- @top_content << "require_relative '#{path}'"
62
- end
63
-
64
- def method(name, options = {}, &block)
65
- m = Dsl::Method.new(name, options)
66
- yield(m) if block
67
- add(m)
68
- end
69
-
70
- def module(name, &block)
71
- m = Dsl::Module.new(name, parent: self)
72
- yield(m) if block
73
- add(m)
74
- m
75
- end
76
-
77
- def class(name, options = {}, &block)
78
- c = Dsl::Class.new(name, options.merge(parent: self))
79
- yield(c) if block
80
- add(c)
81
- c
82
- end
83
-
84
- def lines
85
-
86
- lines = []
87
-
88
- lines.concat(@comments.lines)
89
- lines << :newline unless @comments.empty?
90
-
91
- @top_content.each do |statement|
92
- lines << statement
93
- end
94
- lines << :newline unless @top_content.empty?
95
-
96
- @code_objects.each.with_index do |code_obj, n|
97
- lines.concat(code_obj.lines)
98
- lines << :newline unless n == @code_objects.size - 1
99
- end
100
- lines
101
- end
102
-
103
- end
104
- end
105
- end
@@ -1,108 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Method
4
-
5
- include Dsl::CodeObject
6
-
7
- # @option options [Symbol] :access (:public)
8
- # @option options [String, nil] :docstring (nil)
9
- def initialize(name, options = {}, &block)
10
- @name = name.to_s
11
- @access = options.fetch(:access, :public)
12
- @code_objects = []
13
- @params = []
14
- @option_tags = []
15
- @return_tags = []
16
- @aliases = []
17
- @docstring = Dsl::Docstring.new(options.fetch(:docstring, nil))
18
- @api_private = options.fetch(:api_private, false)
19
- yield(self) if block
20
- end
21
-
22
- attr_reader :name
23
-
24
- attr_reader :access
25
-
26
- attr_reader :aliases
27
-
28
- def param(name, options = {})
29
- @params << Param.new(name, options)
30
- end
31
-
32
- def option(options)
33
- @option_tags << OptionTag.new(options)
34
- end
35
-
36
- def returns(type, options = {})
37
- @return_tags << ReturnTag.new(options.merge(type:type))
38
- end
39
-
40
- def add(*code_objects)
41
- @code_objects.concat(code_objects)
42
- end
43
-
44
- def code(code = nil, &block)
45
- @code_objects << CodeLiteral.new(code, &block)
46
- end
47
-
48
- def empty?
49
- @code_objects.empty?
50
- end
51
-
52
- def docstring(docstring = nil, &block)
53
- @docstring.append(docstring)
54
- yield(@docstring) if block
55
- @docstring
56
- end
57
-
58
- def block_param
59
- @params << BlockParam.new
60
- end
61
-
62
- def alias_as(other_name)
63
- @aliases << other_name.to_s
64
- end
65
-
66
- def lines
67
- code = []
68
- code.concat(yard_docs)
69
- code << method_signature
70
- code << method_body
71
- code << method_end
72
- code.concat(@aliases.map { |a| "alias :#{a} :#{@name}" })
73
- code
74
- end
75
-
76
- private
77
-
78
- def yard_docs
79
- docs = []
80
- docs.concat(@docstring.lines)
81
- tags = []
82
- tags.concat(ParamList.new(@params).tags)
83
- tags.concat(@option_tags)
84
- tags.concat(@return_tags)
85
- tags << "# @api private" if @api_private
86
- tags.each.with_index do |tag, n|
87
- docs.concat(tag.lines.to_a)
88
- end
89
- docs.compact
90
- end
91
-
92
- def method_signature
93
- "def #{@name}#{ParamList.new(@params).signature}"
94
- end
95
-
96
- def method_body
97
- @code_objects.inject([]) do |lines, code_obj|
98
- lines.concat(code_obj.lines)
99
- end
100
- end
101
-
102
- def method_end
103
- "end"
104
- end
105
-
106
- end
107
- end
108
- end
@@ -1,167 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Module < Dsl::Main
4
-
5
- include Dsl::CodeObject
6
-
7
- # @option options [Main, Module] :parent (nil)
8
- def initialize(name, options = {}, &block)
9
- @name = name
10
- @code_objects = []
11
- @access = :public
12
- @parent = options.fetch(:parent, nil)
13
- @docstring = Dsl::Docstring.new(nil)
14
- yield(self) if block
15
- end
16
-
17
- attr_reader :name
18
-
19
- def add(*code_objects)
20
- code_objects.each do |code_object|
21
- if Dsl::Method === code_object && code_object.access != @access
22
- add(AccessControlStatement.new(code_object.access))
23
- elsif Dsl::AccessControlStatement === code_object
24
- @access = code_object.access
25
- end
26
- super(code_object)
27
- end
28
- end
29
-
30
- def require_statement(path)
31
- root.require(path)
32
- end
33
- alias require require_statement
34
-
35
- def docstring(docstring = nil)
36
- @docstring ||= Dsl::Docstring.new
37
- @docstring.append(docstring) unless docstring.nil?
38
- @docstring
39
- end
40
-
41
- def require_relative(path)
42
- root.require_relative(path)
43
- end
44
-
45
- def constructor(options = {}, &block)
46
- method(:initialize, options, &block)
47
- end
48
-
49
- def attr_accessor(name, options = {}, &block)
50
- a = Dsl::AttributeAccessor.new(name, options)
51
- yield(a) if block
52
- add(a)
53
- end
54
-
55
- def autoload(const_name, path)
56
- @code_objects << AutoloadStatement.new(const_name, path)
57
- end
58
-
59
- def attr_reader(name, options = {}, &block)
60
- a = Dsl::AttributeReader.new(name, options)
61
- yield(a) if block
62
- add(a)
63
- end
64
-
65
- def attr_writer(name, &block)
66
- a = Dsl::AttributeWriter.new(name)
67
- yield(a) if block
68
- add(a)
69
- end
70
-
71
- def eigenclass(&block)
72
- m = Dsl::Eigenclass.new
73
- yield(m) if block
74
- add(m)
75
- end
76
-
77
- def lines
78
- code = []
79
- code.concat(@docstring.lines)
80
- code += open_module
81
- code << :newline if padded?(0)
82
-
83
- @code_objects.each.with_index do |code_object, n|
84
- code << code_object.lines
85
- code << :newline if separator?(n)
86
- end
87
-
88
- if @code_objects.empty?
89
- code[-1] += "; end"
90
- else
91
- code += close_module
92
- end
93
- code
94
- end
95
-
96
- private
97
-
98
- def open_module
99
- ["module #{@name}"]
100
- end
101
-
102
- def close_module
103
- ["end"]
104
- end
105
-
106
- def padded?(n)
107
- !@code_objects[n].kind_of?(Dsl::Module) &&
108
- !(
109
- @code_objects.all? { |obj| autoload_statement?(obj) } ||
110
- @code_objects.all? { |obj| mixin?(obj) } ||
111
- @code_objects.all? { |obj| undocumented_attr_macro?(obj) }
112
- )
113
- end
114
-
115
- def separator?(n)
116
- if last?(n)
117
- padded?(@code_objects.size - 1)
118
- elsif grouped_statements?(n)
119
- false
120
- else
121
- true
122
- end
123
- end
124
-
125
- def last?(n)
126
- @code_objects.size == n + 1
127
- end
128
-
129
- def grouped_statements?(n)
130
- two_autoloads?(n) ||
131
- two_mixins?(n) ||
132
- two_undocumented_attr_macros?(n)
133
- end
134
-
135
- def two_autoloads?(n)
136
- @code_objects[n + 1] &&
137
- autoload_statement?(@code_objects[n + 1]) &&
138
- autoload_statement?(@code_objects[n])
139
- end
140
-
141
- def two_mixins?(n)
142
- @code_objects[n + 1] &&
143
- mixin?(@code_objects[n + 1]) &&
144
- mixin?(@code_objects[n])
145
- end
146
-
147
- def two_undocumented_attr_macros?(n)
148
- @code_objects[n + 1] &&
149
- undocumented_attr_macro?(@code_objects[n + 1]) &&
150
- undocumented_attr_macro?(@code_objects[n])
151
- end
152
-
153
- def autoload_statement?(code_object)
154
- Dsl::AutoloadStatement === code_object
155
- end
156
-
157
- def mixin?(code_object)
158
- Dsl::IncludeStatement === code_object
159
- end
160
-
161
- def undocumented_attr_macro?(code_object)
162
- Dsl::AttributeAccessor === code_object && !code_object.documented?
163
- end
164
-
165
- end
166
- end
167
- end
@@ -1,36 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class OptionTag
4
-
5
- # @option options [required, String] :name
6
- # @option options [required, String] :type
7
- # @option options [String] :param ('options')
8
- # @option options [Boolean] :required (false)
9
- # @option options [String, nil] :docstring (nil)
10
- # @option options [Object] :default
11
- def initialize(options)
12
- @name = options.fetch(:name)
13
- @type = options.fetch(:type)
14
- @param = options.fetch(:param, 'options')
15
- @required = options.fetch(:required, false) ? 'required, ' : ''
16
- @docstring = Dsl::TagDocstring.new(options.fetch(:docstring, nil))
17
- @default = Dsl::TagDefault.new(options.fetch(:default, nil))
18
- end
19
-
20
- def lines
21
- [first_line] + @docstring.lines
22
- end
23
-
24
- private
25
-
26
- def first_line
27
- "# @option #{@param} [#{@required}#{@type}] :#{@name}#{yard_default}"
28
- end
29
-
30
- def yard_default
31
- @default.empty? ? '' : " (#{@default})"
32
- end
33
-
34
- end
35
- end
36
- end
@@ -1,43 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Param
4
-
5
- # @option options [String] :type
6
- # @option options [Object] :default
7
- # @option options [String] :docstring
8
- # @option options [Boolean] :documented (true)
9
- def initialize(name, options = {})
10
- @name = name.to_s
11
- @type = TagType.new(options.fetch(:type, nil))
12
- @default = TagDefault.new(options.fetch(:default, nil))
13
- @docstring = TagDocstring.new(options.fetch(:docstring, nil))
14
- @documented = options.fetch(:documented, true)
15
- end
16
-
17
- attr_reader :name, :default
18
-
19
- def documented?
20
- !!@documented
21
- end
22
-
23
- def tag
24
- if [@type, @default, @docstring].all?(&:empty?)
25
- []
26
- else
27
- [first_line] + @docstring.lines
28
- end
29
- end
30
-
31
- private
32
-
33
- def first_line
34
- "# @param#{@type} #{@name}#{yard_default}"
35
- end
36
-
37
- def yard_default
38
- @default.empty? ? '' : " (#{@default})"
39
- end
40
-
41
- end
42
- end
43
- end
@@ -1,38 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- # @api private
4
- class ParamList
5
-
6
- def initialize(params)
7
- @params = params
8
- end
9
-
10
- def signature
11
- if @params.empty?
12
- nil
13
- else
14
- "(#{@params.map { |p| param_signature(p) }.join(', ')})"
15
- end
16
- end
17
-
18
- def tags
19
- lines = []
20
- @params.each do |param|
21
- lines.concat(param.tag) if param.documented?
22
- end
23
- lines
24
- end
25
-
26
- private
27
-
28
- def param_signature(param)
29
- if param.default.empty?
30
- param.name
31
- else
32
- "#{param.name} = #{param.default}"
33
- end
34
- end
35
-
36
- end
37
- end
38
- end
@@ -1,19 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- # @api private
4
- class ReturnTag
5
-
6
- # @option options [required, String] :type
7
- # @option options [String] :docstring
8
- def initialize(options)
9
- @type = Dsl::TagType.new(options.fetch(:type))
10
- @docstring = Dsl::TagDocstring.new(options.fetch(:docstring, nil))
11
- end
12
-
13
- def lines
14
- ["# @return#{@type}"] + @docstring.lines
15
- end
16
-
17
- end
18
- end
19
- end
@@ -1,20 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- # @api private
4
- class TagDefault
5
-
6
- def initialize(default)
7
- @default = default
8
- end
9
-
10
- def to_s
11
- @default.inspect
12
- end
13
-
14
- def empty?
15
- @default.nil?
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,27 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- # @api private
4
- class TagDocstring
5
-
6
- def initialize(docstring)
7
- @lines = docstring.to_s.strip.lines.inject([]) do |lines, line|
8
- line = line.rstrip
9
- if line.empty?
10
- lines << "#"
11
- else
12
- lines << "# #{line.rstrip}"
13
- end
14
- end
15
- end
16
-
17
- # @return Array<String>
18
- attr_reader :lines
19
-
20
- # @return [Boolean]
21
- def empty?
22
- @lines.empty?
23
- end
24
-
25
- end
26
- end
27
- end
@@ -1,18 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- # @api private
4
- class TagType < String
5
-
6
- def self.new(type)
7
- if type
8
- types = Array(type)
9
- types = types.map { |t| t.nil? ? 'nil' : t.to_s }
10
- super(types.empty? ? '' : " [#{types.join(', ')}]")
11
- else
12
- super('')
13
- end
14
- end
15
-
16
- end
17
- end
18
- end