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