rdoc 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +1 -3
  3. data/RI.md +75 -75
  4. data/exe/rdoc +2 -2
  5. data/lib/rdoc/code_object/alias.rb +71 -69
  6. data/lib/rdoc/code_object/any_method.rb +305 -303
  7. data/lib/rdoc/code_object/attr.rb +150 -148
  8. data/lib/rdoc/code_object/class_module.rb +798 -792
  9. data/lib/rdoc/code_object/constant.rb +175 -173
  10. data/lib/rdoc/code_object/context/section.rb +142 -138
  11. data/lib/rdoc/code_object/context.rb +926 -958
  12. data/lib/rdoc/code_object/extend.rb +7 -5
  13. data/lib/rdoc/code_object/include.rb +7 -5
  14. data/lib/rdoc/code_object/method_attr.rb +326 -319
  15. data/lib/rdoc/code_object/mixin.rb +97 -95
  16. data/lib/rdoc/code_object/normal_class.rb +77 -78
  17. data/lib/rdoc/code_object/normal_module.rb +61 -59
  18. data/lib/rdoc/code_object/require.rb +23 -39
  19. data/lib/rdoc/code_object/single_class.rb +21 -19
  20. data/lib/rdoc/code_object/top_level.rb +212 -219
  21. data/lib/rdoc/code_object.rb +305 -303
  22. data/lib/rdoc/comment.rb +275 -273
  23. data/lib/rdoc/cross_reference.rb +192 -190
  24. data/lib/rdoc/encoding.rb +105 -103
  25. data/lib/rdoc/erb_partial.rb +13 -11
  26. data/lib/rdoc/erbio.rb +29 -27
  27. data/lib/rdoc/generator/aliki.rb +161 -153
  28. data/lib/rdoc/generator/darkfish.rb +645 -635
  29. data/lib/rdoc/generator/json_index.rb +233 -229
  30. data/lib/rdoc/generator/markup.rb +164 -146
  31. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  32. data/lib/rdoc/generator/pot/po.rb +52 -51
  33. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  34. data/lib/rdoc/generator/pot.rb +85 -81
  35. data/lib/rdoc/generator/ri.rb +23 -19
  36. data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
  37. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  38. data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
  39. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  40. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  41. data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
  42. data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  44. data/lib/rdoc/generator.rb +48 -46
  45. data/lib/rdoc/i18n/locale.rb +99 -95
  46. data/lib/rdoc/i18n/text.rb +109 -105
  47. data/lib/rdoc/i18n.rb +7 -5
  48. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  49. data/lib/rdoc/markdown.kpeg +15 -11
  50. data/lib/rdoc/markdown.rb +40 -47
  51. data/lib/rdoc/markup/block_quote.rb +12 -8
  52. data/lib/rdoc/markup/document.rb +127 -123
  53. data/lib/rdoc/markup/formatter.rb +219 -215
  54. data/lib/rdoc/markup/include.rb +33 -29
  55. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  56. data/lib/rdoc/markup/inline_parser.rb +281 -277
  57. data/lib/rdoc/markup/list.rb +80 -88
  58. data/lib/rdoc/markup/list_item.rb +73 -85
  59. data/lib/rdoc/markup/paragraph.rb +23 -19
  60. data/lib/rdoc/markup/parser.rb +501 -497
  61. data/lib/rdoc/markup/pre_process.rb +283 -279
  62. data/lib/rdoc/markup/raw.rb +2 -2
  63. data/lib/rdoc/markup/rule.rb +16 -12
  64. data/lib/rdoc/markup/to_ansi.rb +143 -139
  65. data/lib/rdoc/markup/to_bs.rb +72 -68
  66. data/lib/rdoc/markup/to_html.rb +594 -565
  67. data/lib/rdoc/markup/to_html_crossref.rb +234 -230
  68. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  69. data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
  70. data/lib/rdoc/markup/to_label.rb +63 -59
  71. data/lib/rdoc/markup/to_markdown.rb +212 -208
  72. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  73. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  74. data/lib/rdoc/markup/to_test.rb +60 -56
  75. data/lib/rdoc/markup/to_tt_only.rb +84 -80
  76. data/lib/rdoc/markup/verbatim.rb +62 -58
  77. data/lib/rdoc/markup.rb +198 -196
  78. data/lib/rdoc/options.rb +1063 -1061
  79. data/lib/rdoc/parser/c.rb +1039 -1037
  80. data/lib/rdoc/parser/changelog.rb +319 -315
  81. data/lib/rdoc/parser/markdown.rb +17 -13
  82. data/lib/rdoc/parser/rbs.rb +239 -235
  83. data/lib/rdoc/parser/rd.rb +17 -13
  84. data/lib/rdoc/parser/ruby.rb +1245 -1124
  85. data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
  86. data/lib/rdoc/parser/simple.rb +31 -27
  87. data/lib/rdoc/parser/text.rb +12 -8
  88. data/lib/rdoc/parser.rb +228 -220
  89. data/lib/rdoc/rbs_helper.rb +1 -1
  90. data/lib/rdoc/rd/inline.rb +57 -53
  91. data/lib/rdoc/rd.rb +90 -88
  92. data/lib/rdoc/rdoc.rb +500 -491
  93. data/lib/rdoc/ri/driver.rb +1140 -1135
  94. data/lib/rdoc/ri/formatter.rb +7 -3
  95. data/lib/rdoc/ri/paths.rb +140 -136
  96. data/lib/rdoc/ri/servlet.rb +354 -350
  97. data/lib/rdoc/ri/store.rb +4 -2
  98. data/lib/rdoc/ri/task.rb +55 -51
  99. data/lib/rdoc/ri.rb +14 -12
  100. data/lib/rdoc/rubygems_hook.rb +183 -181
  101. data/lib/rdoc/server.rb +349 -347
  102. data/lib/rdoc/stats/normal.rb +46 -42
  103. data/lib/rdoc/stats/quiet.rb +39 -35
  104. data/lib/rdoc/stats/verbose.rb +35 -31
  105. data/lib/rdoc/stats.rb +365 -363
  106. data/lib/rdoc/store.rb +888 -902
  107. data/lib/rdoc/task.rb +260 -256
  108. data/lib/rdoc/text.rb +135 -133
  109. data/lib/rdoc/token_stream.rb +101 -93
  110. data/lib/rdoc/tom_doc.rb +203 -201
  111. data/lib/rdoc/version.rb +1 -1
  112. metadata +4 -5
  113. data/lib/rdoc/markdown/literals.kpeg +0 -21
  114. data/lib/rdoc/markdown/literals.rb +0 -454
@@ -1,387 +1,389 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # AnyMethod is the base class for objects representing methods
2
+ module RDoc
3
+ ##
4
+ # AnyMethod is the base class for objects representing methods
4
5
 
5
- class RDoc::AnyMethod < RDoc::MethodAttr
6
+ class AnyMethod < ::RDoc::MethodAttr
6
7
 
7
- ##
8
- # 2::
9
- # RDoc 4
10
- # Added calls_super
11
- # Added parent name and class
12
- # Added section title
13
- # 3::
14
- # RDoc 4.1
15
- # Added is_alias_for
16
- # 4::
17
- # Added type_signature_lines (serialized as joined string)
18
-
19
- MARSHAL_VERSION = 4 # :nodoc:
8
+ ##
9
+ # 2::
10
+ # RDoc 4
11
+ # Added calls_super
12
+ # Added parent name and class
13
+ # Added section title
14
+ # 3::
15
+ # RDoc 4.1
16
+ # Added is_alias_for
17
+ # 4::
18
+ # Added type_signature_lines (serialized as joined string)
20
19
 
21
- ##
22
- # Don't rename \#initialize to \::new
20
+ MARSHAL_VERSION = 4 # :nodoc:
23
21
 
24
- attr_accessor :dont_rename_initialize
22
+ ##
23
+ # Don't rename \#initialize to \::new
25
24
 
26
- ##
27
- # The C function that implements this method (if it was defined in a C file)
25
+ attr_accessor :dont_rename_initialize
28
26
 
29
- attr_accessor :c_function
27
+ ##
28
+ # The C function that implements this method (if it was defined in a C file)
30
29
 
31
- # The section title of the method (if defined in a C file via +:category:+)
32
- attr_accessor :section_title
30
+ attr_accessor :c_function
33
31
 
34
- ##
35
- # If true this method uses +super+ to call a superclass version
32
+ # The section title of the method (if defined in a C file via +:category:+)
33
+ attr_accessor :section_title
36
34
 
37
- attr_accessor :calls_super
35
+ ##
36
+ # If true this method uses +super+ to call a superclass version
38
37
 
39
- include RDoc::TokenStream
38
+ attr_accessor :calls_super
40
39
 
41
- ##
42
- # Creates a new AnyMethod with name +name+
40
+ include TokenStream
43
41
 
44
- def initialize(name, singleton: false)
45
- super(name, singleton: singleton)
42
+ ##
43
+ # Creates a new AnyMethod with name +name+
46
44
 
47
- @c_function = nil
48
- @dont_rename_initialize = false
49
- @token_stream = nil
50
- @calls_super = false
51
- @superclass_method = nil
52
- end
45
+ def initialize(name, singleton: false)
46
+ super(name, singleton: singleton)
53
47
 
54
- ##
55
- # Adds +an_alias+ as an alias for this method in +context+.
56
-
57
- def add_alias(an_alias, context = nil)
58
- method = self.class.new an_alias.new_name, singleton: singleton
59
-
60
- method.record_location an_alias.file
61
- method.params = self.params
62
- method.visibility = self.visibility
63
- method.comment = an_alias.comment
64
- method.is_alias_for = self
65
- method.type_signature_lines = self.type_signature_lines
66
- @aliases << method
67
- context.add_method method if context
68
- method
69
- end
48
+ @c_function = nil
49
+ @dont_rename_initialize = false
50
+ @token_stream = nil
51
+ @calls_super = false
52
+ @superclass_method = nil
53
+ end
70
54
 
71
- ##
72
- # Prefix for +aref+ is 'method'.
55
+ ##
56
+ # Adds +an_alias+ as an alias for this method in +context+.
57
+
58
+ def add_alias(an_alias, context = nil)
59
+ method = self.class.new an_alias.new_name, singleton: singleton
60
+
61
+ method.record_location an_alias.file
62
+ method.params = self.params
63
+ method.visibility = self.visibility
64
+ method.comment = an_alias.comment
65
+ method.is_alias_for = self
66
+ method.type_signature_lines = self.type_signature_lines
67
+ @aliases << method
68
+ context.add_method method if context
69
+ method
70
+ end
73
71
 
74
- def aref_prefix
75
- 'method'
76
- end
72
+ ##
73
+ # Prefix for +aref+ is 'method'.
77
74
 
78
- ##
79
- # The call_seq or the param_seq with method name, if there is no call_seq.
80
- #
81
- # Use this for displaying a method's argument lists.
82
-
83
- def arglists
84
- if @call_seq then
85
- @call_seq
86
- elsif @params then
87
- "#{name}#{param_seq}"
75
+ def aref_prefix
76
+ 'method'
88
77
  end
89
- end
90
78
 
91
- ##
92
- # Different ways to call this method
79
+ ##
80
+ # The call_seq or the param_seq with method name, if there is no call_seq.
81
+ #
82
+ # Use this for displaying a method's argument lists.
93
83
 
94
- def call_seq
95
- unless call_seq = _call_seq
96
- call_seq = is_alias_for._call_seq if is_alias_for
84
+ def arglists
85
+ if @call_seq
86
+ @call_seq
87
+ elsif @params
88
+ "#{name}#{param_seq}"
89
+ end
97
90
  end
98
91
 
99
- return unless call_seq
92
+ ##
93
+ # Different ways to call this method
100
94
 
101
- deduplicate_call_seq(call_seq)
102
- end
95
+ def call_seq
96
+ unless call_seq = _call_seq
97
+ call_seq = is_alias_for._call_seq if is_alias_for
98
+ end
103
99
 
104
- ##
105
- # Sets the different ways you can call this method. If an empty +call_seq+
106
- # is given nil is assumed.
107
- #
108
- # See also #param_seq
100
+ return unless call_seq
109
101
 
110
- def call_seq=(call_seq)
111
- return if call_seq.nil? || call_seq.empty?
102
+ deduplicate_call_seq(call_seq)
103
+ end
112
104
 
113
- @call_seq = call_seq
114
- end
105
+ ##
106
+ # Sets the different ways you can call this method. If an empty +call_seq+
107
+ # is given nil is assumed.
108
+ #
109
+ # See also #param_seq
115
110
 
116
- ##
117
- # Whether the method has a call-seq.
111
+ def call_seq=(call_seq)
112
+ return if call_seq.nil? || call_seq.empty?
118
113
 
119
- def has_call_seq?
120
- !!(@call_seq || is_alias_for&._call_seq)
121
- end
114
+ @call_seq = call_seq
115
+ end
122
116
 
123
- ##
124
- # Loads is_alias_for from the internal name. Returns nil if the alias
125
- # cannot be found.
117
+ ##
118
+ # Whether the method has a call-seq.
126
119
 
127
- def is_alias_for # :nodoc:
128
- case @is_alias_for
129
- when RDoc::MethodAttr then
130
- @is_alias_for
131
- when Array then
132
- return nil unless @store
120
+ def has_call_seq?
121
+ !!(@call_seq || is_alias_for&._call_seq)
122
+ end
133
123
 
134
- klass_name, singleton, method_name = @is_alias_for
124
+ ##
125
+ # Loads is_alias_for from the internal name. Returns nil if the alias
126
+ # cannot be found.
135
127
 
136
- return nil unless klass = @store.find_class_or_module(klass_name)
128
+ def is_alias_for # :nodoc:
129
+ case @is_alias_for
130
+ when MethodAttr
131
+ @is_alias_for
132
+ when Array
133
+ return nil unless @store
137
134
 
138
- @is_alias_for = klass.find_method method_name, singleton
139
- end
140
- end
135
+ klass_name, singleton, method_name = @is_alias_for
141
136
 
142
- ##
143
- # Dumps this AnyMethod for use by ri. See also #marshal_load
137
+ return nil unless klass = @store.find_class_or_module(klass_name)
144
138
 
145
- def marshal_dump
146
- aliases = @aliases.map do |a|
147
- [a.name, parse(a.comment)]
139
+ @is_alias_for = klass.find_method method_name, singleton
140
+ end
148
141
  end
149
142
 
150
- is_alias_for = [
151
- @is_alias_for.parent.full_name,
152
- @is_alias_for.singleton,
153
- @is_alias_for.name
154
- ] if @is_alias_for
155
-
156
- [ MARSHAL_VERSION,
157
- @name,
158
- full_name,
159
- @singleton,
160
- @visibility,
161
- parse(@comment),
162
- @call_seq,
163
- @block_params,
164
- aliases,
165
- @params,
166
- @file.relative_name,
167
- @calls_super,
168
- @parent.name,
169
- @parent.class,
170
- @section.title,
171
- is_alias_for,
172
- @type_signature_lines&.join("\n"),
173
- ]
174
- end
143
+ ##
144
+ # Dumps this AnyMethod for use by ri. See also #marshal_load
175
145
 
176
- ##
177
- # Loads this AnyMethod from +array+. For a loaded AnyMethod the following
178
- # methods will return cached values:
179
- #
180
- # * #full_name
181
- # * #parent_name
182
-
183
- def marshal_load(array)
184
- initialize_visibility
185
-
186
- @dont_rename_initialize = nil
187
- @token_stream = nil
188
- @aliases = []
189
- @parent = nil
190
- @parent_name = nil
191
- @parent_class = nil
192
- @section = nil
193
- @file = nil
194
-
195
- version = array[0]
196
- @name = array[1]
197
- @full_name = array[2]
198
- @singleton = array[3]
199
- @visibility = array[4]
200
- @comment = RDoc::Comment.from_document array[5]
201
- @call_seq = array[6]
202
- @block_params = array[7]
203
- # 8 handled below
204
- @params = array[9]
205
- # 10 handled below
206
- @calls_super = array[11]
207
- @parent_name = array[12]
208
- @parent_title = array[13]
209
- @section_title = array[14]
210
- @is_alias_for = array[15]
211
- @type_signature_lines = array[16]&.split("\n")
212
-
213
- array[8].each do |new_name, document|
214
- add_alias RDoc::Alias.new(@name, new_name, RDoc::Comment.from_document(document), singleton: @singleton)
146
+ def marshal_dump
147
+ aliases = @aliases.map do |a|
148
+ [a.name, parse(a.comment)]
149
+ end
150
+
151
+ is_alias_for = [
152
+ @is_alias_for.parent.full_name,
153
+ @is_alias_for.singleton,
154
+ @is_alias_for.name
155
+ ] if @is_alias_for
156
+
157
+ [ MARSHAL_VERSION,
158
+ @name,
159
+ full_name,
160
+ @singleton,
161
+ @visibility,
162
+ parse(@comment),
163
+ @call_seq,
164
+ @block_params,
165
+ aliases,
166
+ @params,
167
+ @file.relative_name,
168
+ @calls_super,
169
+ @parent.name,
170
+ @parent.class,
171
+ @section.title,
172
+ is_alias_for,
173
+ @type_signature_lines&.join("\n"),
174
+ ]
215
175
  end
216
176
 
217
- @parent_name ||= if @full_name =~ /#/ then
218
- $`
219
- else
220
- name = @full_name.split('::')
221
- name.pop
222
- name.join '::'
223
- end
177
+ ##
178
+ # Loads this AnyMethod from +array+. For a loaded AnyMethod the following
179
+ # methods will return cached values:
180
+ #
181
+ # * #full_name
182
+ # * #parent_name
183
+
184
+ def marshal_load(array)
185
+ initialize_visibility
186
+
187
+ @dont_rename_initialize = nil
188
+ @token_stream = nil
189
+ @aliases = []
190
+ @parent = nil
191
+ @parent_name = nil
192
+ @parent_class = nil
193
+ @section = nil
194
+ @file = nil
195
+
196
+ version = array[0]
197
+ @name = array[1]
198
+ @full_name = array[2]
199
+ @singleton = array[3]
200
+ @visibility = array[4] || :public
201
+ @comment = Comment.from_document array[5]
202
+ @call_seq = array[6]
203
+ @block_params = array[7]
204
+ # 8 handled below
205
+ @params = array[9]
206
+ # 10 handled below
207
+ @calls_super = array[11]
208
+ @parent_name = array[12]
209
+ @parent_title = array[13]
210
+ @section_title = array[14]
211
+ @is_alias_for = array[15]
212
+ @type_signature_lines = array[16]&.split("\n")
213
+
214
+ array[8].each do |new_name, document|
215
+ add_alias Alias.new(@name, new_name, Comment.from_document(document), singleton: @singleton)
216
+ end
224
217
 
225
- @file = RDoc::TopLevel.new array[10] if version > 0
226
- end
218
+ @parent_name ||= if @full_name =~ /#/
219
+ $`
220
+ else
221
+ name = @full_name.split('::')
222
+ name.pop
223
+ name.join '::'
224
+ end
227
225
 
228
- ##
229
- # Method name
230
- #
231
- # If the method has no assigned name, it extracts it from #call_seq.
226
+ @file = TopLevel.new array[10] if version > 0
227
+ end
232
228
 
233
- def name
234
- return @name if @name
229
+ ##
230
+ # Method name
231
+ #
232
+ # If the method has no assigned name, it extracts it from #call_seq.
235
233
 
236
- @name =
237
- @call_seq[/^.*?\.(\w+)/, 1] ||
238
- @call_seq[/^.*?(\w+)/, 1] ||
239
- @call_seq if @call_seq
240
- end
234
+ def name
235
+ return @name if @name
241
236
 
242
- ##
243
- # A list of this method's method and yield parameters. +call-seq+ params
244
- # are preferred over parsed method and block params.
245
-
246
- def param_list
247
- if @call_seq then
248
- params = @call_seq.split("\n").last
249
- params = params.sub(/.*?\((.*)\)/, '\1')
250
- params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2')
251
- elsif @params then
252
- params = @params.sub(/\((.*)\)/, '\1')
253
-
254
- params << ",#{@block_params}" if @block_params
255
- elsif @block_params then
256
- params = @block_params
257
- else
258
- return []
237
+ @name =
238
+ @call_seq[/^.*?\.(\w+)/, 1] ||
239
+ @call_seq[/^.*?(\w+)/, 1] ||
240
+ @call_seq if @call_seq
259
241
  end
260
242
 
261
- if @block_params then
262
- # If this method has explicit block parameters, remove any explicit
263
- # &block
264
- params = params.sub(/,?\s*&\w+/, '')
265
- else
266
- params = params.sub(/\&(\w+)/, '\1')
267
- end
243
+ ##
244
+ # A list of this method's method and yield parameters. +call-seq+ params
245
+ # are preferred over parsed method and block params.
246
+
247
+ def param_list
248
+ if @call_seq
249
+ params = @call_seq.split("\n").last
250
+ params = params.sub(/.*?\((.*)\)/, '\1')
251
+ params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2')
252
+ elsif @params
253
+ params = @params.sub(/\((.*)\)/, '\1')
254
+
255
+ params << ",#{@block_params}" if @block_params
256
+ elsif @block_params
257
+ params = @block_params
258
+ else
259
+ return []
260
+ end
268
261
 
269
- params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
262
+ if @block_params
263
+ # If this method has explicit block parameters, remove any explicit
264
+ # &block
265
+ params = params.sub(/,?\s*&\w+/, '')
266
+ else
267
+ params = params.sub(/\&(\w+)/, '\1')
268
+ end
270
269
 
271
- params.map { |param| param.sub(/=.*/, '') }
272
- end
270
+ params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
273
271
 
274
- ##
275
- # Pretty parameter list for this method. If the method's parameters were
276
- # given by +call-seq+ it is preferred over the parsed values.
277
-
278
- def param_seq
279
- if @call_seq then
280
- params = @call_seq.split("\n").last
281
- params = params.sub(/[^( ]+/, '')
282
- params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
283
- elsif @params then
284
- params = @params.gsub(/\s*\#.*/, '')
285
- params = params.tr_s("\n ", " ")
286
- params = "(#{params})" unless params[0] == ?(
287
- else
288
- params = ''
272
+ params.map { |param| param.sub(/=.*/, '') }
289
273
  end
290
274
 
291
- if @block_params then
292
- # If this method has explicit block parameters, remove any explicit
293
- # &block
294
- params = params.sub(/,?\s*&\w+/, '')
275
+ ##
276
+ # Pretty parameter list for this method. If the method's parameters were
277
+ # given by +call-seq+ it is preferred over the parsed values.
278
+
279
+ def param_seq
280
+ if @call_seq
281
+ params = @call_seq.split("\n").last
282
+ params = params.sub(/[^( ]+/, '')
283
+ params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
284
+ elsif @params
285
+ params = @params.gsub(/\s*\#.*/, '')
286
+ params = params.tr_s("\n ", " ")
287
+ params = "(#{params})" unless params[0] == ?(
288
+ else
289
+ params = ''
290
+ end
295
291
 
296
- block = @block_params.tr_s("\n ", " ")
297
- if block[0] == ?(
298
- block = block.sub(/^\(/, '').sub(/\)/, '')
292
+ if @block_params
293
+ # If this method has explicit block parameters, remove any explicit
294
+ # &block
295
+ params = params.sub(/,?\s*&\w+/, '')
296
+
297
+ block = @block_params.tr_s("\n ", " ")
298
+ if block[0] == ?(
299
+ block = block.sub(/^\(/, '').sub(/\)/, '')
300
+ end
301
+ params << " { |#{block}| ... }"
299
302
  end
300
- params << " { |#{block}| ... }"
301
- end
302
303
 
303
- params
304
- end
304
+ params
305
+ end
305
306
 
306
- ##
307
- # Whether to skip the method description, true for methods that have
308
- # aliases with a call-seq that doesn't include the method name.
307
+ ##
308
+ # Whether to skip the method description, true for methods that have
309
+ # aliases with a call-seq that doesn't include the method name.
309
310
 
310
- def skip_description?
311
- has_call_seq? && call_seq.nil? && !!(is_alias_for || !aliases.empty?)
312
- end
311
+ def skip_description?
312
+ has_call_seq? && call_seq.nil? && !!(is_alias_for || !aliases.empty?)
313
+ end
313
314
 
314
- ##
315
- # Sets the store for this method and its referenced code objects.
315
+ ##
316
+ # Sets the store for this method and its referenced code objects.
316
317
 
317
- def store=(store)
318
- super
318
+ def store=(store)
319
+ super
319
320
 
320
- @file = @store.add_file @file.full_name if @file
321
- end
321
+ @file = @store.add_file @file.full_name if @file
322
+ end
322
323
 
323
- ##
324
- # For methods that +super+, find the superclass method that would be called.
324
+ ##
325
+ # For methods that +super+, find the superclass method that would be called.
325
326
 
326
- def superclass_method
327
- return unless @calls_super
328
- return @superclass_method if @superclass_method
327
+ def superclass_method
328
+ return unless @calls_super
329
+ return @superclass_method if @superclass_method
329
330
 
330
- parent.each_ancestor do |ancestor|
331
- if method = ancestor.method_list.find { |m| m.name == @name } then
332
- @superclass_method = method
333
- break
331
+ parent.each_ancestor do |ancestor|
332
+ if method = ancestor.method_list.find { |m| m.name == @name }
333
+ @superclass_method = method
334
+ break
335
+ end
334
336
  end
335
- end
336
337
 
337
- @superclass_method
338
- end
338
+ @superclass_method
339
+ end
339
340
 
340
341
  protected
341
342
 
342
- ##
343
- # call_seq without deduplication and alias lookup.
343
+ ##
344
+ # call_seq without deduplication and alias lookup.
344
345
 
345
- def _call_seq
346
- @call_seq if defined?(@call_seq) && @call_seq
347
- end
346
+ def _call_seq
347
+ @call_seq if defined?(@call_seq) && @call_seq
348
+ end
348
349
 
349
350
  private
350
351
 
351
- ##
352
- # call_seq with alias examples information removed, if this
353
- # method is an alias method.
352
+ ##
353
+ # call_seq with alias examples information removed, if this
354
+ # method is an alias method.
354
355
 
355
- def deduplicate_call_seq(call_seq)
356
- return call_seq unless is_alias_for || !aliases.empty?
356
+ def deduplicate_call_seq(call_seq)
357
+ return call_seq unless is_alias_for || !aliases.empty?
357
358
 
358
- method_name = self.name
359
+ method_name = self.name
359
360
 
360
- entries = call_seq.split "\n"
361
+ entries = call_seq.split "\n"
361
362
 
362
- ignore = aliases.map(&:name)
363
- if is_alias_for
364
- ignore << is_alias_for.name
365
- ignore.concat is_alias_for.aliases.map(&:name)
366
- end
363
+ ignore = aliases.map(&:name)
364
+ if is_alias_for
365
+ ignore << is_alias_for.name
366
+ ignore.concat is_alias_for.aliases.map(&:name)
367
+ end
367
368
 
368
- ignore.delete(method_name)
369
- ignore_bracket_methods, ignore_other_methods = ignore.partition {|i| i.start_with?('[') }
369
+ ignore.delete(method_name)
370
+ ignore_bracket_methods, ignore_other_methods = ignore.partition {|i| i.start_with?('[') }
370
371
 
371
- if ignore_other_methods.any?
372
- ignore_union = Regexp.union(ignore_other_methods)
373
- entries.reject! do |entry|
374
- /\A(?:\w*\.)?#{ignore_union}(?:[(\s]|\z)/.match?(entry) ||
375
- /\s#{ignore_union}\s/.match?(entry)
372
+ if ignore_other_methods.any?
373
+ ignore_union = Regexp.union(ignore_other_methods)
374
+ entries.reject! do |entry|
375
+ /\A(?:\w*\.)?#{ignore_union}(?:[(\s]|\z)/.match?(entry) ||
376
+ /\s#{ignore_union}\s/.match?(entry)
377
+ end
376
378
  end
377
- end
378
- if ignore_bracket_methods.any?
379
- entries.reject! do |entry|
380
- # Ignore `receiver[arg] -> return_type` `[](arg)` `[]`
381
- /\A\w*\[.*?\](?:[(\s]|\z)/.match?(entry)
379
+ if ignore_bracket_methods.any?
380
+ entries.reject! do |entry|
381
+ # Ignore `receiver[arg] -> return_type` `[](arg)` `[]`
382
+ /\A\w*\[.*?\](?:[(\s]|\z)/.match?(entry)
383
+ end
382
384
  end
383
- end
384
385
 
385
- entries.empty? ? nil : entries.join("\n")
386
+ entries.empty? ? nil : entries.join("\n")
387
+ end
386
388
  end
387
389
  end