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,417 +1,424 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # Abstract class representing either a method or an attribute.
4
-
5
- class RDoc::MethodAttr < RDoc::CodeObject
6
-
7
- include Comparable
8
-
2
+ module RDoc
9
3
  ##
10
- # Name of this method/attribute.
4
+ # Abstract class representing either a method or an attribute.
11
5
 
12
- attr_accessor :name
6
+ class MethodAttr < CodeObject
13
7
 
14
- ##
15
- # public, protected, private
8
+ include Comparable
16
9
 
17
- attr_accessor :visibility
10
+ ##
11
+ # Name of this method/attribute.
18
12
 
19
- ##
20
- # Is this a singleton method/attribute?
13
+ attr_accessor :name
21
14
 
22
- attr_accessor :singleton
15
+ ##
16
+ # public, protected, private
23
17
 
24
- ##
25
- # Array of other names for this method/attribute
18
+ attr_accessor :visibility
26
19
 
27
- attr_reader :aliases
20
+ ##
21
+ # Is this a singleton method/attribute?
28
22
 
29
- ##
30
- # The method/attribute we're aliasing
23
+ attr_accessor :singleton
31
24
 
32
- attr_accessor :is_alias_for
25
+ ##
26
+ # Array of other names for this method/attribute
33
27
 
34
- #--
35
- # The attributes below are for AnyMethod only.
36
- # They are left here for the time being to
37
- # allow ri to operate.
38
- # TODO modify ri to avoid calling these on attributes.
39
- #++
28
+ attr_reader :aliases
40
29
 
41
- ##
42
- # Parameters yielded by the called block
30
+ ##
31
+ # The method/attribute we're aliasing
43
32
 
44
- attr_reader :block_params
33
+ attr_accessor :is_alias_for
45
34
 
46
- ##
47
- # Parameters for this method
35
+ #--
36
+ # The attributes below are for AnyMethod only.
37
+ # They are left here for the time being to
38
+ # allow ri to operate.
39
+ # TODO modify ri to avoid calling these on attributes.
40
+ #++
48
41
 
49
- attr_accessor :params
42
+ ##
43
+ # Parameters yielded by the called block
50
44
 
51
- ##
52
- # Different ways to call this method
45
+ attr_reader :block_params
53
46
 
54
- attr_accessor :call_seq
47
+ ##
48
+ # Parameters for this method
55
49
 
56
- ##
57
- # RBS type signature lines from inline annotations or loaded .rbs files.
58
- # Each entry is one overload or type expression.
50
+ attr_accessor :params
59
51
 
60
- attr_accessor :type_signature_lines
52
+ ##
53
+ # Different ways to call this method
61
54
 
62
- ##
63
- # The call_seq or the param_seq with method name, if there is no call_seq.
55
+ attr_accessor :call_seq
64
56
 
65
- attr_reader :arglists
57
+ ##
58
+ # RBS type signature lines from inline annotations or loaded .rbs files.
59
+ # Each entry is one overload or type expression.
66
60
 
67
- ##
68
- # Creates a new MethodAttr with method or attribute
69
- # name +name+.
70
- #
71
- # Usually this is called by super from a subclass.
72
-
73
- def initialize(name, singleton: false)
74
- super()
75
-
76
- @name = name
77
-
78
- @aliases = []
79
- @is_alias_for = nil
80
- @parent_name = nil
81
- @singleton = singleton
82
- @visibility = :public
83
- @see = false
84
-
85
- @arglists = nil
86
- @block_params = nil
87
- @call_seq = nil
88
- @params = nil
89
- @type_signature_lines = nil
90
- end
61
+ attr_accessor :type_signature_lines
91
62
 
92
- ##
93
- # Resets cached data for the object so it can be rebuilt by accessor methods
63
+ ##
64
+ # The call_seq or the param_seq with method name, if there is no call_seq.
94
65
 
95
- def initialize_copy(other) # :nodoc:
96
- @full_name = nil
97
- end
66
+ attr_reader :arglists
98
67
 
99
- def initialize_visibility # :nodoc:
100
- super
101
- @see = nil
102
- end
68
+ ##
69
+ # Creates a new MethodAttr with method or attribute
70
+ # name +name+.
71
+ #
72
+ # Usually this is called by super from a subclass.
103
73
 
104
- ##
105
- # Order by #singleton then #name
74
+ def initialize(name, singleton: false)
75
+ super()
106
76
 
107
- def <=>(other)
108
- return unless other.respond_to?(:singleton) &&
109
- other.respond_to?(:name)
77
+ @name = name
110
78
 
111
- [@singleton ? 0 : 1, name_ord_range, name] <=>
112
- [other.singleton ? 0 : 1, other.name_ord_range, other.name]
113
- end
79
+ @aliases = []
80
+ @is_alias_for = nil
81
+ @parent_name = nil
82
+ @singleton = singleton
83
+ @visibility = :public
84
+ @see = false
114
85
 
115
- def ==(other) # :nodoc:
116
- equal?(other) or self.class == other.class and full_name == other.full_name
117
- end
86
+ @arglists = nil
87
+ @block_params = nil
88
+ @call_seq = nil
89
+ @params = nil
90
+ @type_signature_lines = nil
91
+ end
118
92
 
119
- ##
120
- # A method/attribute is documented if any of the following is true:
121
- # - it was marked with :nodoc:;
122
- # - it has a comment;
123
- # - it is an alias for a documented method;
124
- # - it has a +#see+ method that is documented.
125
-
126
- def documented?
127
- super or
128
- (is_alias_for and is_alias_for.documented?) or
129
- (see and see.documented?)
130
- end
93
+ ##
94
+ # Resets cached data for the object so it can be rebuilt by accessor methods
131
95
 
132
- ##
133
- # A method/attribute to look at,
134
- # in particular if this method/attribute has no documentation.
135
- #
136
- # It can be a method/attribute of the superclass or of an included module,
137
- # including the Kernel module, which is always appended to the included
138
- # modules.
139
- #
140
- # Returns +nil+ if there is no such method/attribute.
141
- # The +#is_alias_for+ method/attribute, if any, is not included.
142
- #
143
- # Templates may generate a "see also ..." if this method/attribute
144
- # has documentation, and "see ..." if it does not.
145
-
146
- def see
147
- @see = find_see if @see == false
148
- @see
149
- end
96
+ def initialize_copy(other) # :nodoc:
97
+ @full_name = nil
98
+ end
150
99
 
151
- ##
152
- # Sets the store for this class or module and its contained code objects.
100
+ def initialize_visibility # :nodoc:
101
+ super
102
+ @see = nil
103
+ end
153
104
 
154
- def store=(store)
155
- super
105
+ ##
106
+ # Order by #singleton then #name
156
107
 
157
- @file = @store.add_file @file.full_name if @file
158
- end
108
+ def <=>(other)
109
+ return unless other.respond_to?(:singleton) &&
110
+ other.respond_to?(:name)
159
111
 
160
- def find_see # :nodoc:
161
- return nil if singleton || is_alias_for
112
+ [@singleton ? 0 : 1, name_ord_range, name] <=>
113
+ [other.singleton ? 0 : 1, other.name_ord_range, other.name]
114
+ end
162
115
 
163
- # look for the method
164
- other = find_method_or_attribute name
165
- return other if other
116
+ def ==(other) # :nodoc:
117
+ equal?(other) or self.class == other.class and full_name == other.full_name
118
+ end
166
119
 
167
- # if it is a setter, look for a getter
168
- return nil unless name =~ /[a-z_]=$/i # avoid == or ===
169
- return find_method_or_attribute name[0..-2]
170
- end
120
+ ##
121
+ # A method/attribute is documented if any of the following is true:
122
+ # - it was marked with :nodoc:;
123
+ # - it has a comment;
124
+ # - it is an alias for a documented method;
125
+ # - it has a +#see+ method that is documented.
126
+
127
+ def documented?
128
+ super or
129
+ (is_alias_for and is_alias_for.documented?) or
130
+ (see and see.documented?)
131
+ end
171
132
 
172
- def find_method_or_attribute(name) # :nodoc:
173
- return nil unless parent.respond_to? :ancestors
133
+ ##
134
+ # A method/attribute to look at,
135
+ # in particular if this method/attribute has no documentation.
136
+ #
137
+ # It can be a method/attribute of the superclass or of an included module,
138
+ # including the Kernel module, which is always appended to the included
139
+ # modules.
140
+ #
141
+ # Returns +nil+ if there is no such method/attribute.
142
+ # The +#is_alias_for+ method/attribute, if any, is not included.
143
+ #
144
+ # Templates may generate a "see also ..." if this method/attribute
145
+ # has documentation, and "see ..." if it does not.
146
+
147
+ def see
148
+ @see = find_see if @see == false
149
+ @see
150
+ end
174
151
 
175
- searched = parent.ancestors
176
- kernel = @store.modules_hash['Kernel']
152
+ ##
153
+ # Sets the store for this class or module and its contained code objects.
177
154
 
178
- searched << kernel if kernel &&
179
- parent != kernel && !searched.include?(kernel)
155
+ def store=(store)
156
+ super
180
157
 
181
- searched.each do |ancestor|
182
- next if String === ancestor
183
- next if parent == ancestor
158
+ @file = @store.add_file @file.full_name if @file
159
+ end
184
160
 
185
- other = ancestor.find_method_named('#' + name) ||
186
- ancestor.find_attribute_named(name)
161
+ def find_see # :nodoc:
162
+ return nil if singleton || is_alias_for
187
163
 
164
+ # look for the method
165
+ other = find_method_or_attribute name
188
166
  return other if other
167
+
168
+ # if it is a setter, look for a getter
169
+ return nil unless name =~ /[a-z_]=$/i # avoid == or ===
170
+ return find_method_or_attribute name[0..-2]
189
171
  end
190
172
 
191
- nil
192
- end
173
+ def find_method_or_attribute(name) # :nodoc:
174
+ return nil unless parent.respond_to? :ancestors
193
175
 
194
- ##
195
- # Abstract method. Contexts in their building phase call this
196
- # to register a new alias for this known method/attribute.
197
- #
198
- # - creates a new AnyMethod/Attribute named <tt>an_alias.new_name</tt>;
199
- # - adds +self+ as an alias for the new method or attribute
200
- # - adds the method or attribute to #aliases
201
- # - adds the method or attribute to +context+.
202
-
203
- def add_alias(an_alias, context)
204
- raise NotImplementedError
205
- end
176
+ searched = parent.ancestors
177
+ kernel = @store.modules_hash['Kernel']
206
178
 
207
- ##
208
- # HTML fragment reference for this method
179
+ searched << kernel if kernel &&
180
+ parent != kernel && !searched.include?(kernel)
209
181
 
210
- def aref
211
- type = singleton ? 'c' : 'i'
212
- # % characters are not allowed in html names => dash instead
213
- "#{aref_prefix}-#{type}-#{html_name}"
214
- end
182
+ searched.each do |ancestor|
183
+ next if String === ancestor
184
+ next if parent == ancestor
215
185
 
216
- ##
217
- # Prefix for +aref+, defined by subclasses.
186
+ other = ancestor.find_method_named('#' + name) ||
187
+ ancestor.find_attribute_named(name)
218
188
 
219
- def aref_prefix
220
- raise NotImplementedError
221
- end
189
+ return other if other
190
+ end
222
191
 
223
- ##
224
- # Attempts to sanitize the content passed by the Ruby parser:
225
- # remove outer parentheses, etc.
192
+ nil
193
+ end
226
194
 
227
- def block_params=(value)
228
- # 'yield.to_s' or 'assert yield, msg'
229
- return @block_params = '' if value =~ /^[\.,]/
195
+ ##
196
+ # Abstract method. Contexts in their building phase call this
197
+ # to register a new alias for this known method/attribute.
198
+ #
199
+ # - creates a new AnyMethod/Attribute named <tt>an_alias.new_name</tt>;
200
+ # - adds +self+ as an alias for the new method or attribute
201
+ # - adds the method or attribute to #aliases
202
+ # - adds the method or attribute to +context+.
203
+
204
+ def add_alias(an_alias, context)
205
+ raise NotImplementedError
206
+ end
230
207
 
231
- # remove trailing 'if/unless ...'
232
- return @block_params = '' if value =~ /^(if|unless)\s/
208
+ ##
209
+ # HTML fragment reference for this method
233
210
 
234
- value = $1.strip if value =~ /^(.+)\s(if|unless)\s/
211
+ def aref
212
+ type = singleton ? 'c' : 'i'
213
+ # % characters are not allowed in html names => dash instead
214
+ "#{aref_prefix}-#{type}-#{html_name}"
215
+ end
235
216
 
236
- # outer parentheses
237
- value = $1 if value =~ /^\s*\((.*)\)\s*$/
238
- value = value.strip
217
+ ##
218
+ # Prefix for +aref+, defined by subclasses.
239
219
 
240
- # proc/lambda
241
- return @block_params = $1 if value =~ /^(proc|lambda)(\s*\{|\sdo)/
220
+ def aref_prefix
221
+ raise NotImplementedError
222
+ end
242
223
 
243
- # surrounding +...+ or [...]
244
- value = $1.strip if value =~ /^\+(.*)\+$/
245
- value = $1.strip if value =~ /^\[(.*)\]$/
224
+ ##
225
+ # Attempts to sanitize the content passed by the Ruby parser:
226
+ # remove outer parentheses, etc.
246
227
 
247
- return @block_params = '' if value.empty?
228
+ def block_params=(value)
229
+ # 'yield.to_s' or 'assert yield, msg'
230
+ return @block_params = '' if value =~ /^[\.,]/
248
231
 
249
- # global variable
250
- return @block_params = 'str' if value =~ /^\$[&0-9]$/
232
+ # remove trailing 'if/unless ...'
233
+ return @block_params = '' if value =~ /^(if|unless)\s/
251
234
 
252
- # wipe out array/hash indices
253
- value.gsub!(/(\w)\[[^\[]+\]/, '\1')
235
+ value = $1.strip if value =~ /^(.+)\s(if|unless)\s/
254
236
 
255
- # remove @ from class/instance variables
256
- value.gsub!(/@@?([a-z0-9_]+)/, '\1')
237
+ # outer parentheses
238
+ value = $1 if value =~ /^\s*\((.*)\)\s*$/
239
+ value = value.strip
257
240
 
258
- # method calls => method name
259
- value.gsub!(/([A-Z:a-z0-9_]+)\.([a-z0-9_]+)(\s*\(\s*[a-z0-9_.,\s]*\s*\)\s*)?/) do
260
- case $2
261
- when 'to_s' then $1
262
- when 'const_get' then 'const'
263
- when 'new' then
264
- $1.split('::').last. # ClassName => class_name
265
- gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
266
- gsub(/([a-z\d])([A-Z])/, '\1_\2').
267
- downcase
268
- else
269
- $2
270
- end
271
- end
241
+ # proc/lambda
242
+ return @block_params = $1 if value =~ /^(proc|lambda)(\s*\{|\sdo)/
272
243
 
273
- # class prefixes
274
- value.gsub!(/[A-Za-z0-9_:]+::/, '')
244
+ # surrounding +...+ or [...]
245
+ value = $1.strip if value =~ /^\+(.*)\+$/
246
+ value = $1.strip if value =~ /^\[(.*)\]$/
275
247
 
276
- # simple expressions
277
- value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/
248
+ return @block_params = '' if value.empty?
278
249
 
279
- @block_params = value.strip
280
- end
250
+ # global variable
251
+ return @block_params = 'str' if value =~ /^\$[&0-9]$/
281
252
 
282
- ##
283
- # HTML id-friendly method/attribute name
253
+ # wipe out array/hash indices
254
+ value.gsub!(/(\w)\[[^\[]+\]/, '\1')
284
255
 
285
- def html_name
286
- require 'cgi/escape'
287
- require 'cgi/util' unless defined?(CGI::EscapeExt)
256
+ # remove @ from class/instance variables
257
+ value.gsub!(/@@?([a-z0-9_]+)/, '\1')
288
258
 
289
- CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
290
- end
259
+ # method calls => method name
260
+ value.gsub!(/([A-Z:a-z0-9_]+)\.([a-z0-9_]+)(\s*\(\s*[a-z0-9_.,\s]*\s*\)\s*)?/) do
261
+ case $2
262
+ when 'to_s' then $1
263
+ when 'const_get' then 'const'
264
+ when 'new'
265
+ $1.split('::').last. # ClassName => class_name
266
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
267
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
268
+ downcase
269
+ else
270
+ $2
271
+ end
272
+ end
291
273
 
292
- ##
293
- # Full method/attribute name including namespace
274
+ # class prefixes
275
+ value.gsub!(/[A-Za-z0-9_:]+::/, '')
294
276
 
295
- def full_name
296
- @full_name ||= "#{parent_name}#{pretty_name}"
297
- end
277
+ # simple expressions
278
+ value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/
298
279
 
299
- def inspect # :nodoc:
300
- alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
301
- visibility = self.visibility
302
- visibility = "forced #{visibility}" if force_documentation
303
- "#<%s:0x%x %s (%s)%s>" % [
304
- self.class, object_id,
305
- full_name,
306
- visibility,
307
- alias_for,
308
- ]
309
- end
280
+ @block_params = value.strip
281
+ end
310
282
 
311
- ##
312
- # '::' for a class method/attribute, '#' for an instance method.
283
+ ##
284
+ # HTML id-friendly method/attribute name
313
285
 
314
- def name_prefix
315
- @singleton ? '::' : '#'
316
- end
286
+ def html_name
287
+ require 'cgi/escape'
288
+ require 'cgi/util' unless defined?(CGI::EscapeExt)
317
289
 
318
- ##
319
- # Method/attribute name with class/instance indicator
290
+ CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
291
+ end
320
292
 
321
- def pretty_name
322
- "#{name_prefix}#{@name}"
323
- end
293
+ ##
294
+ # Full method/attribute name including namespace
324
295
 
325
- ##
326
- # Type of method/attribute (class or instance)
296
+ def full_name
297
+ @full_name ||= "#{parent_name}#{pretty_name}"
298
+ end
327
299
 
328
- def type
329
- singleton ? 'class' : 'instance'
330
- end
300
+ def inspect # :nodoc:
301
+ alias_for =
302
+ if @is_alias_for.respond_to? :name
303
+ " (alias for #{@is_alias_for.name})"
304
+ elsif Array === @is_alias_for
305
+ " (alias for #{@is_alias_for.last})"
306
+ end
307
+ visibility = self.visibility
308
+ visibility = "forced #{visibility}" if force_documentation
309
+ "#<%s:0x%x %s (%s)%s>" % [
310
+ self.class, object_id,
311
+ full_name,
312
+ visibility,
313
+ alias_for,
314
+ ]
315
+ end
331
316
 
332
- ##
333
- # Path to this method for use with HTML generator output.
317
+ ##
318
+ # '::' for a class method/attribute, '#' for an instance method.
334
319
 
335
- def path
336
- "#{@parent.path}##{aref}"
337
- end
320
+ def name_prefix
321
+ @singleton ? '::' : '#'
322
+ end
338
323
 
339
- ##
340
- # Name of our parent with special handling for un-marshaled methods
324
+ ##
325
+ # Method/attribute name with class/instance indicator
341
326
 
342
- def parent_name
343
- @parent_name || super
344
- end
327
+ def pretty_name
328
+ "#{name_prefix}#{@name}"
329
+ end
345
330
 
346
- def pretty_print(q) # :nodoc:
347
- alias_for =
348
- if @is_alias_for.respond_to? :name then
349
- "alias for #{@is_alias_for.name}"
350
- elsif Array === @is_alias_for then
351
- "alias for #{@is_alias_for.last}"
352
- end
331
+ ##
332
+ # Type of method/attribute (class or instance)
353
333
 
354
- q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
355
- if alias_for then
356
- q.breakable
357
- q.text alias_for
358
- end
334
+ def type
335
+ singleton ? 'class' : 'instance'
336
+ end
337
+
338
+ ##
339
+ # Path to this method for use with HTML generator output.
340
+
341
+ def path
342
+ "#{@parent.path}##{aref}"
343
+ end
344
+
345
+ ##
346
+ # Name of our parent with special handling for un-marshaled methods
347
+
348
+ def parent_name
349
+ @parent_name || super
350
+ end
359
351
 
360
- unless comment.empty? then
361
- q.breakable
362
- q.text "comment:"
363
- q.breakable
364
- q.pp @comment
352
+ def pretty_print(q) # :nodoc:
353
+ alias_for =
354
+ if @is_alias_for.respond_to? :name
355
+ "alias for #{@is_alias_for.name}"
356
+ elsif Array === @is_alias_for
357
+ "alias for #{@is_alias_for.last}"
358
+ end
359
+
360
+ q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
361
+ if alias_for
362
+ q.breakable
363
+ q.text alias_for
364
+ end
365
+
366
+ unless comment.empty?
367
+ q.breakable
368
+ q.text "comment:"
369
+ q.breakable
370
+ q.pp @comment
371
+ end
365
372
  end
366
373
  end
367
- end
368
374
 
369
- ##
370
- # Used by RDoc::Generator::JsonIndex to create a record for the search
371
- # engine.
372
- #
373
- # TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
374
- # Use #search_snippet instead for getting documentation snippets.
375
-
376
- def search_record
377
- [
378
- @name,
379
- full_name,
380
- @name,
381
- @parent.full_name,
382
- path,
383
- params,
384
- search_snippet,
385
- ]
386
- end
375
+ ##
376
+ # Used by RDoc::Generator::JsonIndex to create a record for the search
377
+ # engine.
378
+ #
379
+ # TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
380
+ # Use #search_snippet instead for getting documentation snippets.
381
+
382
+ def search_record
383
+ [
384
+ @name,
385
+ full_name,
386
+ @name,
387
+ @parent.full_name,
388
+ path,
389
+ params,
390
+ search_snippet,
391
+ ]
392
+ end
387
393
 
388
- ##
389
- # Returns an HTML snippet of the comment for search results.
394
+ ##
395
+ # Returns an HTML snippet of the comment for search results.
390
396
 
391
- def search_snippet
392
- return '' if @comment.empty?
397
+ def search_snippet
398
+ return '' if @comment.empty?
393
399
 
394
- snippet(@comment)
395
- end
400
+ snippet(@comment)
401
+ end
396
402
 
397
- def to_s # :nodoc:
398
- if @is_alias_for
399
- "#{self.class.name}: #{full_name} -> #{is_alias_for}"
400
- else
401
- "#{self.class.name}: #{full_name}"
403
+ def to_s # :nodoc:
404
+ if @is_alias_for
405
+ "#{self.class.name}: #{full_name} -> #{is_alias_for}"
406
+ else
407
+ "#{self.class.name}: #{full_name}"
408
+ end
402
409
  end
403
- end
404
410
 
405
- def name_ord_range # :nodoc:
406
- case name.ord
407
- when 0..64 # anything below "A"
408
- 1
409
- when 91..96 # the symbols between "Z" and "a"
410
- 2
411
- when 123..126 # 7-bit symbols above "z": "{", "|", "}", "~"
412
- 3
413
- else # everythig else can be sorted as normal
414
- 4
411
+ def name_ord_range # :nodoc:
412
+ case name.ord
413
+ when 0..64 # anything below "A"
414
+ 1
415
+ when 91..96 # the symbols between "Z" and "a"
416
+ 2
417
+ when 123..126 # 7-bit symbols above "z": "{", "|", "}", "~"
418
+ 3
419
+ else # everythig else can be sorted as normal
420
+ 4
421
+ end
415
422
  end
416
423
  end
417
424
  end