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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -3
- data/RI.md +75 -75
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +71 -69
- data/lib/rdoc/code_object/any_method.rb +305 -303
- data/lib/rdoc/code_object/attr.rb +150 -148
- data/lib/rdoc/code_object/class_module.rb +798 -792
- data/lib/rdoc/code_object/constant.rb +175 -173
- data/lib/rdoc/code_object/context/section.rb +142 -138
- data/lib/rdoc/code_object/context.rb +926 -958
- data/lib/rdoc/code_object/extend.rb +7 -5
- data/lib/rdoc/code_object/include.rb +7 -5
- data/lib/rdoc/code_object/method_attr.rb +326 -319
- data/lib/rdoc/code_object/mixin.rb +97 -95
- data/lib/rdoc/code_object/normal_class.rb +77 -78
- data/lib/rdoc/code_object/normal_module.rb +61 -59
- data/lib/rdoc/code_object/require.rb +23 -39
- data/lib/rdoc/code_object/single_class.rb +21 -19
- data/lib/rdoc/code_object/top_level.rb +212 -219
- data/lib/rdoc/code_object.rb +305 -303
- data/lib/rdoc/comment.rb +275 -273
- data/lib/rdoc/cross_reference.rb +192 -190
- data/lib/rdoc/encoding.rb +105 -103
- data/lib/rdoc/erb_partial.rb +13 -11
- data/lib/rdoc/erbio.rb +29 -27
- data/lib/rdoc/generator/aliki.rb +161 -153
- data/lib/rdoc/generator/darkfish.rb +645 -635
- data/lib/rdoc/generator/json_index.rb +233 -229
- data/lib/rdoc/generator/markup.rb +164 -146
- data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
- data/lib/rdoc/generator/pot/po.rb +52 -51
- data/lib/rdoc/generator/pot/po_entry.rb +138 -132
- data/lib/rdoc/generator/pot.rb +85 -81
- data/lib/rdoc/generator/ri.rb +23 -19
- data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
- data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
- data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
- data/lib/rdoc/generator.rb +48 -46
- data/lib/rdoc/i18n/locale.rb +99 -95
- data/lib/rdoc/i18n/text.rb +109 -105
- data/lib/rdoc/i18n.rb +7 -5
- data/lib/rdoc/markdown/byte_runtime.rb +80 -0
- data/lib/rdoc/markdown.kpeg +15 -11
- data/lib/rdoc/markdown.rb +40 -47
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/formatter.rb +219 -215
- data/lib/rdoc/markup/include.rb +33 -29
- data/lib/rdoc/markup/indented_paragraph.rb +37 -33
- data/lib/rdoc/markup/inline_parser.rb +281 -277
- data/lib/rdoc/markup/list.rb +80 -88
- data/lib/rdoc/markup/list_item.rb +73 -85
- data/lib/rdoc/markup/paragraph.rb +23 -19
- data/lib/rdoc/markup/parser.rb +501 -497
- data/lib/rdoc/markup/pre_process.rb +283 -279
- data/lib/rdoc/markup/raw.rb +2 -2
- data/lib/rdoc/markup/rule.rb +16 -12
- data/lib/rdoc/markup/to_ansi.rb +143 -139
- data/lib/rdoc/markup/to_bs.rb +72 -68
- data/lib/rdoc/markup/to_html.rb +594 -565
- data/lib/rdoc/markup/to_html_crossref.rb +234 -230
- data/lib/rdoc/markup/to_html_snippet.rb +232 -227
- data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
- data/lib/rdoc/markup/to_label.rb +63 -59
- data/lib/rdoc/markup/to_markdown.rb +212 -208
- data/lib/rdoc/markup/to_rdoc.rb +336 -332
- data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
- data/lib/rdoc/markup/to_test.rb +60 -56
- data/lib/rdoc/markup/to_tt_only.rb +84 -80
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +198 -196
- data/lib/rdoc/options.rb +1063 -1061
- data/lib/rdoc/parser/c.rb +1039 -1037
- data/lib/rdoc/parser/changelog.rb +319 -315
- data/lib/rdoc/parser/markdown.rb +17 -13
- data/lib/rdoc/parser/rbs.rb +239 -235
- data/lib/rdoc/parser/rd.rb +17 -13
- data/lib/rdoc/parser/ruby.rb +1245 -1124
- data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
- data/lib/rdoc/parser/simple.rb +31 -27
- data/lib/rdoc/parser/text.rb +12 -8
- data/lib/rdoc/parser.rb +228 -220
- data/lib/rdoc/rbs_helper.rb +1 -1
- data/lib/rdoc/rd/inline.rb +57 -53
- data/lib/rdoc/rd.rb +90 -88
- data/lib/rdoc/rdoc.rb +500 -491
- data/lib/rdoc/ri/driver.rb +1140 -1135
- data/lib/rdoc/ri/formatter.rb +7 -3
- data/lib/rdoc/ri/paths.rb +140 -136
- data/lib/rdoc/ri/servlet.rb +354 -350
- data/lib/rdoc/ri/store.rb +4 -2
- data/lib/rdoc/ri/task.rb +55 -51
- data/lib/rdoc/ri.rb +14 -12
- data/lib/rdoc/rubygems_hook.rb +183 -181
- data/lib/rdoc/server.rb +349 -347
- data/lib/rdoc/stats/normal.rb +46 -42
- data/lib/rdoc/stats/quiet.rb +39 -35
- data/lib/rdoc/stats/verbose.rb +35 -31
- data/lib/rdoc/stats.rb +365 -363
- data/lib/rdoc/store.rb +888 -902
- data/lib/rdoc/task.rb +260 -256
- data/lib/rdoc/text.rb +135 -133
- data/lib/rdoc/token_stream.rb +101 -93
- data/lib/rdoc/tom_doc.rb +203 -201
- data/lib/rdoc/version.rb +1 -1
- metadata +4 -5
- data/lib/rdoc/markdown/literals.kpeg +0 -21
- 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
|
-
#
|
|
4
|
+
# Abstract class representing either a method or an attribute.
|
|
11
5
|
|
|
12
|
-
|
|
6
|
+
class MethodAttr < CodeObject
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
# public, protected, private
|
|
8
|
+
include Comparable
|
|
16
9
|
|
|
17
|
-
|
|
10
|
+
##
|
|
11
|
+
# Name of this method/attribute.
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
# Is this a singleton method/attribute?
|
|
13
|
+
attr_accessor :name
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
##
|
|
16
|
+
# public, protected, private
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
# Array of other names for this method/attribute
|
|
18
|
+
attr_accessor :visibility
|
|
26
19
|
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
+
##
|
|
31
|
+
# The method/attribute we're aliasing
|
|
43
32
|
|
|
44
|
-
|
|
33
|
+
attr_accessor :is_alias_for
|
|
45
34
|
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
63
|
+
##
|
|
64
|
+
# The call_seq or the param_seq with method name, if there is no call_seq.
|
|
94
65
|
|
|
95
|
-
|
|
96
|
-
@full_name = nil
|
|
97
|
-
end
|
|
66
|
+
attr_reader :arglists
|
|
98
67
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
74
|
+
def initialize(name, singleton: false)
|
|
75
|
+
super()
|
|
106
76
|
|
|
107
|
-
|
|
108
|
-
return unless other.respond_to?(:singleton) &&
|
|
109
|
-
other.respond_to?(:name)
|
|
77
|
+
@name = name
|
|
110
78
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
79
|
+
@aliases = []
|
|
80
|
+
@is_alias_for = nil
|
|
81
|
+
@parent_name = nil
|
|
82
|
+
@singleton = singleton
|
|
83
|
+
@visibility = :public
|
|
84
|
+
@see = false
|
|
114
85
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
|
|
134
|
-
|
|
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
|
-
|
|
100
|
+
def initialize_visibility # :nodoc:
|
|
101
|
+
super
|
|
102
|
+
@see = nil
|
|
103
|
+
end
|
|
153
104
|
|
|
154
|
-
|
|
155
|
-
|
|
105
|
+
##
|
|
106
|
+
# Order by #singleton then #name
|
|
156
107
|
|
|
157
|
-
|
|
158
|
-
|
|
108
|
+
def <=>(other)
|
|
109
|
+
return unless other.respond_to?(:singleton) &&
|
|
110
|
+
other.respond_to?(:name)
|
|
159
111
|
|
|
160
|
-
|
|
161
|
-
|
|
112
|
+
[@singleton ? 0 : 1, name_ord_range, name] <=>
|
|
113
|
+
[other.singleton ? 0 : 1, other.name_ord_range, other.name]
|
|
114
|
+
end
|
|
162
115
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
116
|
+
def ==(other) # :nodoc:
|
|
117
|
+
equal?(other) or self.class == other.class and full_name == other.full_name
|
|
118
|
+
end
|
|
166
119
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
173
|
-
|
|
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
|
-
|
|
176
|
-
|
|
152
|
+
##
|
|
153
|
+
# Sets the store for this class or module and its contained code objects.
|
|
177
154
|
|
|
178
|
-
|
|
179
|
-
|
|
155
|
+
def store=(store)
|
|
156
|
+
super
|
|
180
157
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
next if parent == ancestor
|
|
158
|
+
@file = @store.add_file @file.full_name if @file
|
|
159
|
+
end
|
|
184
160
|
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
192
|
-
|
|
173
|
+
def find_method_or_attribute(name) # :nodoc:
|
|
174
|
+
return nil unless parent.respond_to? :ancestors
|
|
193
175
|
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
179
|
+
searched << kernel if kernel &&
|
|
180
|
+
parent != kernel && !searched.include?(kernel)
|
|
209
181
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
186
|
+
other = ancestor.find_method_named('#' + name) ||
|
|
187
|
+
ancestor.find_attribute_named(name)
|
|
218
188
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
end
|
|
189
|
+
return other if other
|
|
190
|
+
end
|
|
222
191
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
# remove outer parentheses, etc.
|
|
192
|
+
nil
|
|
193
|
+
end
|
|
226
194
|
|
|
227
|
-
|
|
228
|
-
#
|
|
229
|
-
|
|
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
|
-
|
|
232
|
-
|
|
208
|
+
##
|
|
209
|
+
# HTML fragment reference for this method
|
|
233
210
|
|
|
234
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
value = value.strip
|
|
217
|
+
##
|
|
218
|
+
# Prefix for +aref+, defined by subclasses.
|
|
239
219
|
|
|
240
|
-
|
|
241
|
-
|
|
220
|
+
def aref_prefix
|
|
221
|
+
raise NotImplementedError
|
|
222
|
+
end
|
|
242
223
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
224
|
+
##
|
|
225
|
+
# Attempts to sanitize the content passed by the Ruby parser:
|
|
226
|
+
# remove outer parentheses, etc.
|
|
246
227
|
|
|
247
|
-
|
|
228
|
+
def block_params=(value)
|
|
229
|
+
# 'yield.to_s' or 'assert yield, msg'
|
|
230
|
+
return @block_params = '' if value =~ /^[\.,]/
|
|
248
231
|
|
|
249
|
-
|
|
250
|
-
|
|
232
|
+
# remove trailing 'if/unless ...'
|
|
233
|
+
return @block_params = '' if value =~ /^(if|unless)\s/
|
|
251
234
|
|
|
252
|
-
|
|
253
|
-
value.gsub!(/(\w)\[[^\[]+\]/, '\1')
|
|
235
|
+
value = $1.strip if value =~ /^(.+)\s(if|unless)\s/
|
|
254
236
|
|
|
255
|
-
|
|
256
|
-
|
|
237
|
+
# outer parentheses
|
|
238
|
+
value = $1 if value =~ /^\s*\((.*)\)\s*$/
|
|
239
|
+
value = value.strip
|
|
257
240
|
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
|
|
274
|
-
|
|
244
|
+
# surrounding +...+ or [...]
|
|
245
|
+
value = $1.strip if value =~ /^\+(.*)\+$/
|
|
246
|
+
value = $1.strip if value =~ /^\[(.*)\]$/
|
|
275
247
|
|
|
276
|
-
|
|
277
|
-
value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/
|
|
248
|
+
return @block_params = '' if value.empty?
|
|
278
249
|
|
|
279
|
-
|
|
280
|
-
|
|
250
|
+
# global variable
|
|
251
|
+
return @block_params = 'str' if value =~ /^\$[&0-9]$/
|
|
281
252
|
|
|
282
|
-
|
|
283
|
-
|
|
253
|
+
# wipe out array/hash indices
|
|
254
|
+
value.gsub!(/(\w)\[[^\[]+\]/, '\1')
|
|
284
255
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
require 'cgi/util' unless defined?(CGI::EscapeExt)
|
|
256
|
+
# remove @ from class/instance variables
|
|
257
|
+
value.gsub!(/@@?([a-z0-9_]+)/, '\1')
|
|
288
258
|
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
274
|
+
# class prefixes
|
|
275
|
+
value.gsub!(/[A-Za-z0-9_:]+::/, '')
|
|
294
276
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
end
|
|
277
|
+
# simple expressions
|
|
278
|
+
value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/
|
|
298
279
|
|
|
299
|
-
|
|
300
|
-
|
|
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
|
-
|
|
283
|
+
##
|
|
284
|
+
# HTML id-friendly method/attribute name
|
|
313
285
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
286
|
+
def html_name
|
|
287
|
+
require 'cgi/escape'
|
|
288
|
+
require 'cgi/util' unless defined?(CGI::EscapeExt)
|
|
317
289
|
|
|
318
|
-
|
|
319
|
-
|
|
290
|
+
CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
|
|
291
|
+
end
|
|
320
292
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
end
|
|
293
|
+
##
|
|
294
|
+
# Full method/attribute name including namespace
|
|
324
295
|
|
|
325
|
-
|
|
326
|
-
|
|
296
|
+
def full_name
|
|
297
|
+
@full_name ||= "#{parent_name}#{pretty_name}"
|
|
298
|
+
end
|
|
327
299
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
317
|
+
##
|
|
318
|
+
# '::' for a class method/attribute, '#' for an instance method.
|
|
334
319
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
320
|
+
def name_prefix
|
|
321
|
+
@singleton ? '::' : '#'
|
|
322
|
+
end
|
|
338
323
|
|
|
339
|
-
|
|
340
|
-
|
|
324
|
+
##
|
|
325
|
+
# Method/attribute name with class/instance indicator
|
|
341
326
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
327
|
+
def pretty_name
|
|
328
|
+
"#{name_prefix}#{@name}"
|
|
329
|
+
end
|
|
345
330
|
|
|
346
|
-
|
|
347
|
-
|
|
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
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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
|
-
|
|
394
|
+
##
|
|
395
|
+
# Returns an HTML snippet of the comment for search results.
|
|
390
396
|
|
|
391
|
-
|
|
392
|
-
|
|
397
|
+
def search_snippet
|
|
398
|
+
return '' if @comment.empty?
|
|
393
399
|
|
|
394
|
-
|
|
395
|
-
|
|
400
|
+
snippet(@comment)
|
|
401
|
+
end
|
|
396
402
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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
|