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,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
|
-
#
|
|
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
|
-
|
|
6
|
+
class AnyMethod < ::RDoc::MethodAttr
|
|
18
7
|
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
20
|
+
MARSHAL_VERSION = 4 # :nodoc:
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
##
|
|
23
|
+
# Don't rename \#initialize to \::new
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
attr_accessor :dont_rename_initialize
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
32
|
+
# The section title of the method (if defined in a C file via +:category:+)
|
|
33
|
+
attr_accessor :section_title
|
|
36
34
|
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
super(text, name, singleton: singleton)
|
|
40
|
+
include TokenStream
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
48
|
+
@c_function = nil
|
|
49
|
+
@dont_rename_initialize = false
|
|
50
|
+
@token_stream = nil
|
|
51
|
+
@calls_super = false
|
|
52
|
+
@superclass_method = nil
|
|
53
|
+
end
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
92
|
+
##
|
|
93
|
+
# Different ways to call this method
|
|
97
94
|
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
108
|
-
|
|
102
|
+
deduplicate_call_seq(call_seq)
|
|
103
|
+
end
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
111
|
+
def call_seq=(call_seq)
|
|
112
|
+
return if call_seq.nil? || call_seq.empty?
|
|
115
113
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
end
|
|
114
|
+
@call_seq = call_seq
|
|
115
|
+
end
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
# cannot be found.
|
|
117
|
+
##
|
|
118
|
+
# Whether the method has a call-seq.
|
|
123
119
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
124
|
+
##
|
|
125
|
+
# Loads is_alias_for from the internal name. Returns nil if the alias
|
|
126
|
+
# cannot be found.
|
|
132
127
|
|
|
133
|
-
|
|
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
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
[a.name, parse(a.comment)]
|
|
139
|
+
@is_alias_for = klass.find_method method_name, singleton
|
|
140
|
+
end
|
|
145
141
|
end
|
|
146
142
|
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
221
|
-
|
|
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
|
-
|
|
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
|
-
|
|
229
|
-
|
|
229
|
+
##
|
|
230
|
+
# Method name
|
|
231
|
+
#
|
|
232
|
+
# If the method has no assigned name, it extracts it from #call_seq.
|
|
230
233
|
|
|
231
|
-
|
|
232
|
-
@
|
|
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
|
-
|
|
239
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
|
|
299
|
-
|
|
304
|
+
params
|
|
305
|
+
end
|
|
300
306
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
311
|
+
def skip_description?
|
|
312
|
+
has_call_seq? && call_seq.nil? && !!(is_alias_for || !aliases.empty?)
|
|
313
|
+
end
|
|
308
314
|
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
##
|
|
316
|
+
# Sets the store for this method and its referenced code objects.
|
|
311
317
|
|
|
312
|
-
|
|
313
|
-
|
|
318
|
+
def store=(store)
|
|
319
|
+
super
|
|
314
320
|
|
|
315
|
-
|
|
316
|
-
|
|
321
|
+
@file = @store.add_file @file.full_name if @file
|
|
322
|
+
end
|
|
317
323
|
|
|
318
|
-
|
|
319
|
-
|
|
324
|
+
##
|
|
325
|
+
# For methods that +super+, find the superclass method that would be called.
|
|
320
326
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
327
|
+
def superclass_method
|
|
328
|
+
return unless @calls_super
|
|
329
|
+
return @superclass_method if @superclass_method
|
|
324
330
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
333
|
-
|
|
338
|
+
@superclass_method
|
|
339
|
+
end
|
|
334
340
|
|
|
335
341
|
protected
|
|
336
342
|
|
|
337
|
-
|
|
338
|
-
|
|
343
|
+
##
|
|
344
|
+
# call_seq without deduplication and alias lookup.
|
|
339
345
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
346
|
+
def _call_seq
|
|
347
|
+
@call_seq if defined?(@call_seq) && @call_seq
|
|
348
|
+
end
|
|
343
349
|
|
|
344
350
|
private
|
|
345
351
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
352
|
+
##
|
|
353
|
+
# call_seq with alias examples information removed, if this
|
|
354
|
+
# method is an alias method.
|
|
349
355
|
|
|
350
|
-
|
|
351
|
-
|
|
356
|
+
def deduplicate_call_seq(call_seq)
|
|
357
|
+
return call_seq unless is_alias_for || !aliases.empty?
|
|
352
358
|
|
|
353
|
-
|
|
359
|
+
method_name = self.name
|
|
354
360
|
|
|
355
|
-
|
|
361
|
+
entries = call_seq.split "\n"
|
|
356
362
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
|
|
364
|
-
|
|
369
|
+
ignore.delete(method_name)
|
|
370
|
+
ignore_bracket_methods, ignore_other_methods = ignore.partition {|i| i.start_with?('[') }
|
|
365
371
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
|
|
386
|
+
entries.empty? ? nil : entries.join("\n")
|
|
387
|
+
end
|
|
381
388
|
end
|
|
382
389
|
end
|