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