-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrdoc.rbs
More file actions
393 lines (350 loc) · 11.2 KB
/
rdoc.rbs
File metadata and controls
393 lines (350 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# <!-- rdoc-file=lib/rdoc.rb -->
# RDoc produces documentation for Ruby source files by parsing the source and
# extracting the definition for classes, modules, methods, includes and
# requires. It associates these with optional documentation contained in an
# immediately preceding comment block then renders the result using an output
# formatter.
#
# For a simple introduction to writing or generating documentation using RDoc
# see the README.
#
# ## Roadmap
#
# If you think you found a bug in RDoc see CONTRIBUTING@Bugs
#
# If you want to use RDoc to create documentation for your Ruby source files,
# see RDoc::Markup and refer to `rdoc --help` for command line usage.
#
# If you want to set the default markup format see RDoc::Markup@Markup+Formats
#
# If you want to store rdoc configuration in your gem (such as the default
# markup format) see RDoc::Options@Saved+Options
#
# If you want to write documentation for Ruby files see RDoc::Parser::Ruby
#
# If you want to write documentation for extensions written in C see
# RDoc::Parser::C
#
# If you want to generate documentation using `rake` see RDoc::Task.
#
# If you want to drive RDoc programmatically, see RDoc::RDoc.
#
# If you want to use the library to format text blocks into HTML or other
# formats, look at RDoc::Markup.
#
# If you want to make an RDoc plugin such as a generator or directive handler
# see RDoc::RDoc.
#
# If you want to write your own output generator see RDoc::Generator.
#
# If you want an overview of how RDoc works see CONTRIBUTING
#
# ## Credits
#
# RDoc is currently being maintained by Eric Hodel <drbrain@segment7.net>.
#
# Dave Thomas <dave@pragmaticprogrammer.com> is the original author of RDoc.
#
# * The Ruby parser in rdoc/parse.rb is based heavily on the outstanding work
# of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby parser
# for irb and the rtags package.
#
# <!-- rdoc-file=lib/rdoc/rubygems_hook.rb -->
# This class is referenced by RubyGems to create documents. All implementations
# are moved to the above RubyGemsHook.
#
# This class does nothing when this RDoc is installed as a normal gem or a
# bundled gem.
#
# This class does generate/remove documents for compatibility when this RDoc is
# installed as a default gem.
#
# We can remove this when all maintained RubyGems remove `rubygems/rdoc.rb`.
#
module RDoc
# <!-- rdoc-file=lib/rdoc/token_stream.rb -->
# A TokenStream is a list of tokens, gathered during the parse of some entity
# (say a method). Entities populate these streams by being registered with the
# lexer. Any class can collect tokens by including TokenStream. From the
# outside, you use such an object by calling the start_collecting_tokens method,
# followed by calls to add_token and pop_token.
#
module TokenStream
# <!--
# rdoc-file=lib/rdoc/token_stream.rb
# - add_token(token)
# -->
# Adds one `token` to the collected tokens
#
def add_token: (Hash[untyped, untyped] token) -> void
# <!--
# rdoc-file=lib/rdoc/token_stream.rb
# - collect_tokens()
# -->
# Starts collecting tokens
#
def collect_tokens: () -> void
# <!--
# rdoc-file=lib/rdoc/token_stream.rb
# - start_collecting_tokens()
# -->
#
alias start_collecting_tokens collect_tokens
end
# <!-- rdoc-file=lib/rdoc/class_module.rb -->
# ClassModule is the base class for objects representing either a class or a
# module.
#
class ClassModule < Context
# <!--
# rdoc-file=lib/rdoc/class_module.rb
# - new(name, superclass = nil)
# -->
# Creates a new ClassModule with `name` with optional `superclass`
#
# This is a constructor for subclasses, and must never be called directly.
#
def initialize: (String name, ?String superclass) -> void
# <!--
# rdoc-file=lib/rdoc/class_module.rb
# - add_comment(comment, location)
# -->
# Adds `comment` to this ClassModule's list of comments at `location`. This
# method is preferred over #comment= since it allows ri data to be updated
# across multiple runs.
#
def add_comment: (RDoc::Comment comment, RDoc::Context location) -> void
end
# <!-- rdoc-file=lib/rdoc/normal_class.rb -->
# A normal class, neither singleton nor anonymous
#
class NormalClass < ClassModule
def initialize: (String name, ?String superclass) -> void
end
# <!-- rdoc-file=lib/rdoc/single_class.rb -->
# A singleton class
#
class SingleClass < ClassModule
def initialize: (String name, ?String superclass) -> void
end
# <!-- rdoc-file=lib/rdoc/normal_module.rb -->
# A normal module, like NormalClass
#
class NormalModule < ClassModule
end
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# Abstract class representing either a method or an attribute.
#
class MethodAttr < CodeObject
include Comparable
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# The method/attribute we're aliasing
#
attr_reader is_alias_for: MethodAttr?
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# The call_seq or the param_seq with method name, if there is no call_seq.
#
attr_reader arglists: String
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# Name of this method/attribute.
#
attr_accessor name: String
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# public, protected, private
#
attr_accessor visibility: untyped
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# Is this a singleton method/attribute?
#
attr_accessor singleton: bool
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# Source file token stream
#
attr_reader text: String
# <!-- rdoc-file=lib/rdoc/method_attr.rb -->
# Different ways to call this method
#
attr_accessor call_seq: String
# <!--
# rdoc-file=lib/rdoc/method_attr.rb
# - new(text, name)
# -->
# Creates a new MethodAttr from token stream `text` and method or attribute name
# `name`.
#
# Usually this is called by super from a subclass.
#
def initialize: (String text, String name, ?singleton: bool) -> void
# <!--
# rdoc-file=lib/rdoc/method_attr.rb
# - pretty_name()
# -->
# Method/attribute name with class/instance indicator
#
def pretty_name: () -> ::String
# <!--
# rdoc-file=lib/rdoc/method_attr.rb
# - type()
# -->
# Type of method/attribute (class or instance)
#
def type: () -> ("class" | "instance")
# <!--
# rdoc-file=lib/rdoc/method_attr.rb
# - path()
# -->
# Path to this method for use with HTML generator output.
#
def path: () -> ::String
def to_s: () -> ::String
end
# <!-- rdoc-file=lib/rdoc/any_method.rb -->
# AnyMethod is the base class for objects representing methods
#
class AnyMethod < MethodAttr
include TokenStream
# <!--
# rdoc-file=lib/rdoc/any_method.rb
# - call_seq()
# -->
# Different ways to call this method
# ----
# <!--
# rdoc-file=lib/rdoc/any_method.rb
# - call_seq=(call_seq)
# -->
# Sets the different ways you can call this method. If an empty `call_seq` is
# given nil is assumed.
#
# See also #param_seq
#
attr_accessor call_seq: ::String
# <!-- rdoc-file=lib/rdoc/any_method.rb -->
# Parameters for this method
#
attr_accessor params: ::String
attr_accessor line: Integer
# <!--
# rdoc-file=lib/rdoc/any_method.rb
# - arglists()
# -->
# The call_seq or the param_seq with method name, if there is no call_seq.
#
# Use this for displaying a method's argument lists.
#
def arglists: () -> String?
def callseq: () -> String?
# <!--
# rdoc-file=lib/rdoc/any_method.rb
# - new(text, name)
# -->
# Creates a new AnyMethod with a token stream `text` and `name`
#
def initialize: (String? text, String name, ?singleton: bool) -> void
end
# <!-- rdoc-file=lib/rdoc/attr.rb -->
# An attribute created by #attr, #attr_reader, #attr_writer or #attr_accessor
#
class Attr < MethodAttr
# <!-- rdoc-file=lib/rdoc/attr.rb -->
# Is the attribute readable ('R'), writable ('W') or both ('RW')?
#
attr_accessor rw: "RW" | "R" | "W"
# <!--
# rdoc-file=lib/rdoc/attr.rb
# - new(text, name, rw, comment, singleton = false)
# -->
# Creates a new Attr with body `text`, `name`, read/write status `rw` and
# `comment`. `singleton` marks this as a class attribute.
#
def initialize: (String? text, String name, String rw, RDoc::Comment? comment, ?singleton: bool) -> void
end
# <!-- rdoc-file=lib/rdoc/constant.rb -->
# A constant
#
class Constant < CodeObject
# <!-- rdoc-file=lib/rdoc/constant.rb -->
# Sets the module or class this is constant is an alias for.
#
attr_writer is_alias_for: String
# <!-- rdoc-file=lib/rdoc/constant.rb -->
# The constant's name
#
attr_accessor name: String
# <!-- rdoc-file=lib/rdoc/constant.rb -->
# The constant's value
#
attr_accessor value: String
# <!-- rdoc-file=lib/rdoc/constant.rb -->
# The constant's visibility
#
attr_accessor visibility: String
# <!--
# rdoc-file=lib/rdoc/constant.rb
# - new(name, value, comment)
# -->
# Creates a new constant with `name`, `value` and `comment`
#
def initialize: (String name, String value, RDoc::Comment? comment) -> void
end
# <!-- rdoc-file=lib/rdoc/mixin.rb -->
# A Mixin adds features from a module into another context. RDoc::Include and
# RDoc::Extend are both mixins.
#
class Mixin < CodeObject
# <!-- rdoc-file=lib/rdoc/mixin.rb -->
# Name of included module
#
attr_accessor name: String
# <!--
# rdoc-file=lib/rdoc/mixin.rb
# - new(name, comment)
# -->
# Creates a new Mixin for `name` with `comment`
#
def initialize: (String name, RDoc::Comment? comment) -> void
end
# <!-- rdoc-file=lib/rdoc/include.rb -->
# A Module included in a class with #include
#
# RDoc::Include.new 'Enumerable', 'comment ...'
#
class Include < Mixin
end
# <!-- rdoc-file=lib/rdoc/extend.rb -->
# A Module extension to a class with #extend
#
# RDoc::Extend.new 'Enumerable', 'comment ...'
#
class Extend < Mixin
end
# <!-- rdoc-file=lib/rdoc/alias.rb -->
# Represent an alias, which is an old_name/new_name pair associated with a
# particular context
#
class Alias < CodeObject
# <!-- rdoc-file=lib/rdoc/alias.rb -->
# Aliased method's name
#
attr_accessor name: String
# <!-- rdoc-file=lib/rdoc/alias.rb -->
# Aliasee method's name
#
attr_accessor old_name: String
attr_reader singleton: bool
# <!--
# rdoc-file=lib/rdoc/alias.rb
# - new(text, old_name, new_name, comment, singleton = false)
# -->
# Creates a new Alias with a token stream of `text` that aliases `old_name` to
# `new_name`, has `comment` and is a `singleton` context.
#
def initialize: (String? text, String name, String old_name, RDoc::Comment? comment, ?singleton: bool) -> void
end
# <!-- rdoc-file=lib/rdoc/stats.rb -->
# RDoc statistics collector which prints a summary and report of a project's
# documentation totals.
#
class Stats
end
end