rbs 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -0
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +6 -1
  5. data/core/array.rbs +2866 -1086
  6. data/core/basic_object.rbs +150 -30
  7. data/core/binding.rbs +33 -0
  8. data/core/builtin.rbs +4 -4
  9. data/core/class.rbs +43 -5
  10. data/core/comparable.rbs +57 -0
  11. data/core/complex.rbs +170 -4
  12. data/core/constants.rbs +51 -0
  13. data/core/deprecated.rbs +7 -0
  14. data/core/dir.rbs +305 -20
  15. data/core/encoding.rbs +472 -77
  16. data/core/enumerable.rbs +2173 -234
  17. data/core/enumerator.rbs +448 -182
  18. data/core/env.rbs +448 -1
  19. data/core/errno.rbs +1 -10
  20. data/core/errors.rbs +152 -2
  21. data/core/exception.rbs +201 -127
  22. data/core/false_class.rbs +27 -0
  23. data/core/fiber.rbs +118 -37
  24. data/core/fiber_error.rbs +8 -9
  25. data/core/file.rbs +1059 -139
  26. data/core/file_test.rbs +287 -32
  27. data/core/float.rbs +776 -300
  28. data/core/gc.rbs +185 -34
  29. data/core/global_variables.rbs +5 -1
  30. data/core/hash.rbs +1582 -649
  31. data/core/integer.rbs +974 -204
  32. data/core/io/buffer.rbs +710 -0
  33. data/core/io/wait.rbs +29 -8
  34. data/core/io.rbs +2438 -417
  35. data/core/kernel.rbs +2315 -316
  36. data/core/marshal.rbs +37 -2
  37. data/core/match_data.rbs +123 -6
  38. data/core/math.rbs +126 -6
  39. data/core/method.rbs +226 -102
  40. data/core/module.rbs +421 -45
  41. data/core/nil_class.rbs +64 -0
  42. data/core/numeric.rbs +620 -142
  43. data/core/object.rbs +453 -81
  44. data/core/object_space.rbs +92 -2
  45. data/core/proc.rbs +482 -285
  46. data/core/process.rbs +443 -34
  47. data/core/ractor.rbs +232 -9
  48. data/core/random.rbs +151 -52
  49. data/core/range.rbs +885 -160
  50. data/core/rational.rbs +122 -6
  51. data/core/rb_config.rbs +14 -4
  52. data/core/refinement.rbs +44 -0
  53. data/core/regexp.rbs +156 -14
  54. data/core/ruby_vm.rbs +42 -3
  55. data/core/signal.rbs +78 -39
  56. data/core/string.rbs +2123 -567
  57. data/core/string_io.rbs +204 -0
  58. data/core/struct.rbs +283 -28
  59. data/core/symbol.rbs +304 -30
  60. data/core/thread.rbs +1288 -688
  61. data/core/thread_group.rbs +66 -10
  62. data/core/time.rbs +643 -217
  63. data/core/trace_point.rbs +100 -12
  64. data/core/true_class.rbs +24 -0
  65. data/core/unbound_method.rbs +73 -7
  66. data/core/warning.rbs +37 -12
  67. data/docs/CONTRIBUTING.md +40 -34
  68. data/docs/stdlib.md +3 -102
  69. data/lib/rbs/annotate/annotations.rb +197 -0
  70. data/lib/rbs/annotate/formatter.rb +80 -0
  71. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  72. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  73. data/lib/rbs/annotate.rb +6 -0
  74. data/lib/rbs/cli.rb +45 -1
  75. data/lib/rbs/definition_builder.rb +5 -1
  76. data/lib/rbs/location_aux.rb +12 -0
  77. data/lib/rbs/prototype/rb.rb +12 -0
  78. data/lib/rbs/version.rb +1 -1
  79. data/sig/annotate/annotations.rbs +102 -0
  80. data/sig/annotate/formatter.rbs +24 -0
  81. data/sig/annotate/rdoc_annotater.rbs +82 -0
  82. data/sig/annotate/rdoc_source.rbs +30 -0
  83. data/sig/cli.rbs +2 -0
  84. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  85. data/sig/location.rbs +6 -0
  86. data/sig/method_types.rbs +5 -1
  87. data/sig/polyfill.rbs +78 -0
  88. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  89. data/stdlib/abbrev/0/array.rbs +26 -0
  90. data/stdlib/base64/0/base64.rbs +31 -0
  91. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  92. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  93. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  94. data/stdlib/cgi/0/core.rbs +59 -0
  95. data/stdlib/coverage/0/coverage.rbs +164 -2
  96. data/stdlib/csv/0/csv.rbs +2862 -398
  97. data/stdlib/date/0/date.rbs +483 -25
  98. data/stdlib/date/0/date_time.rbs +187 -12
  99. data/stdlib/dbm/0/dbm.rbs +152 -17
  100. data/stdlib/digest/0/digest.rbs +146 -0
  101. data/stdlib/erb/0/erb.rbs +65 -245
  102. data/stdlib/fiber/0/fiber.rbs +73 -91
  103. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  104. data/stdlib/find/0/find.rbs +9 -0
  105. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  106. data/stdlib/io-console/0/io-console.rbs +227 -15
  107. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  108. data/stdlib/json/0/json.rbs +1146 -144
  109. data/stdlib/logger/0/formatter.rbs +24 -0
  110. data/stdlib/logger/0/log_device.rbs +64 -0
  111. data/stdlib/logger/0/logger.rbs +165 -13
  112. data/stdlib/logger/0/period.rbs +10 -0
  113. data/stdlib/logger/0/severity.rbs +26 -0
  114. data/stdlib/monitor/0/monitor.rbs +163 -0
  115. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  116. data/stdlib/net-http/0/net-http.rbs +1492 -683
  117. data/stdlib/nkf/0/nkf.rbs +372 -0
  118. data/stdlib/objspace/0/objspace.rbs +149 -90
  119. data/stdlib/openssl/0/openssl.rbs +8108 -71
  120. data/stdlib/optparse/0/optparse.rbs +487 -19
  121. data/stdlib/pathname/0/pathname.rbs +425 -124
  122. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  123. data/stdlib/prime/0/integer-extension.rbs +20 -2
  124. data/stdlib/prime/0/prime.rbs +88 -21
  125. data/stdlib/pstore/0/pstore.rbs +102 -0
  126. data/stdlib/pty/0/pty.rbs +64 -14
  127. data/stdlib/resolv/0/resolv.rbs +420 -31
  128. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  129. data/stdlib/rubygems/0/config_file.rbs +33 -1
  130. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  131. data/stdlib/rubygems/0/installer.rbs +13 -1
  132. data/stdlib/rubygems/0/path_support.rbs +4 -1
  133. data/stdlib/rubygems/0/platform.rbs +5 -1
  134. data/stdlib/rubygems/0/request_set.rbs +44 -2
  135. data/stdlib/rubygems/0/requirement.rbs +65 -2
  136. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  137. data/stdlib/rubygems/0/source_list.rbs +13 -0
  138. data/stdlib/rubygems/0/specification.rbs +21 -1
  139. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  140. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  141. data/stdlib/rubygems/0/version.rbs +60 -157
  142. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  143. data/stdlib/set/0/set.rbs +420 -106
  144. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  145. data/stdlib/singleton/0/singleton.rbs +20 -0
  146. data/stdlib/socket/0/addrinfo.rbs +210 -9
  147. data/stdlib/socket/0/basic_socket.rbs +103 -11
  148. data/stdlib/socket/0/ip_socket.rbs +31 -9
  149. data/stdlib/socket/0/socket.rbs +586 -38
  150. data/stdlib/socket/0/tcp_server.rbs +22 -2
  151. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  152. data/stdlib/socket/0/udp_socket.rbs +25 -2
  153. data/stdlib/socket/0/unix_server.rbs +22 -2
  154. data/stdlib/socket/0/unix_socket.rbs +45 -5
  155. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  156. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  157. data/stdlib/time/0/time.rbs +208 -116
  158. data/stdlib/timeout/0/timeout.rbs +10 -0
  159. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  160. data/stdlib/tsort/0/cyclic.rbs +1 -0
  161. data/stdlib/tsort/0/interfaces.rbs +1 -0
  162. data/stdlib/tsort/0/tsort.rbs +42 -0
  163. data/stdlib/uri/0/common.rbs +57 -8
  164. data/stdlib/uri/0/file.rbs +55 -109
  165. data/stdlib/uri/0/ftp.rbs +6 -3
  166. data/stdlib/uri/0/generic.rbs +556 -327
  167. data/stdlib/uri/0/http.rbs +26 -115
  168. data/stdlib/uri/0/https.rbs +8 -102
  169. data/stdlib/uri/0/ldap.rbs +143 -137
  170. data/stdlib/uri/0/ldaps.rbs +8 -102
  171. data/stdlib/uri/0/mailto.rbs +3 -0
  172. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  173. data/stdlib/uri/0/ws.rbs +6 -3
  174. data/stdlib/uri/0/wss.rbs +5 -3
  175. data/stdlib/yaml/0/dbm.rbs +151 -87
  176. data/stdlib/yaml/0/store.rbs +6 -0
  177. data/stdlib/zlib/0/zlib.rbs +90 -31
  178. metadata +17 -5
  179. data/lib/rbs/location.rb +0 -221
@@ -1,11 +1,12 @@
1
+ # <!-- rdoc-file=gc.c -->
1
2
  # The ObjectSpace module contains a number of routines that interact with the
2
3
  # garbage collection facility and allow you to traverse all living objects with
3
4
  # an iterator.
4
5
  #
5
6
  # ObjectSpace also provides support for object finalizers, procs that will be
6
7
  # called when a specific object is about to be destroyed by garbage collection.
7
- #
8
- # require 'objspace'
8
+ # See the documentation for `ObjectSpace.define_finalizer` for important
9
+ # information on how to use this method correctly.
9
10
  #
10
11
  # a = "A"
11
12
  # b = "B"
@@ -13,13 +14,27 @@
13
14
  # ObjectSpace.define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" })
14
15
  # ObjectSpace.define_finalizer(b, proc {|id| puts "Finalizer two on #{id}" })
15
16
  #
17
+ # a = nil
18
+ # b = nil
19
+ #
16
20
  # *produces:*
17
21
  #
18
22
  # Finalizer two on 537763470
19
23
  # Finalizer one on 537763480
24
+ #
25
+ %a{annotate:rdoc:source:from=gc.c}
20
26
  module ObjectSpace
27
+ # <!--
28
+ # rdoc-file=gc.c
29
+ # - _id2ref(p1)
30
+ # -->
31
+ #
21
32
  def self._id2ref: (Integer id) -> untyped
22
33
 
34
+ # <!--
35
+ # rdoc-file=gc.c
36
+ # - ObjectSpace.count_objects([result_hash]) -> hash
37
+ # -->
23
38
  # Counts all objects grouped by type.
24
39
  #
25
40
  # It returns a hash, such as:
@@ -50,13 +65,74 @@ module ObjectSpace
50
65
  #
51
66
  def self.count_objects: (?Hash[Symbol, Integer] result_hash) -> Hash[Symbol, Integer]
52
67
 
68
+ # <!--
69
+ # rdoc-file=gc.c
70
+ # - ObjectSpace.define_finalizer(obj, aProc=proc())
71
+ # -->
53
72
  # Adds *aProc* as a finalizer, to be called after *obj* was destroyed. The
54
73
  # object ID of the *obj* will be passed as an argument to *aProc*. If *aProc* is
55
74
  # a lambda or method, make sure it can be called with a single argument.
56
75
  #
76
+ # The return value is an array `[0, aProc]`.
77
+ #
78
+ # The two recommended patterns are to either create the finaliser proc in a
79
+ # non-instance method where it can safely capture the needed state, or to use a
80
+ # custom callable object that stores the needed state explicitly as instance
81
+ # variables.
82
+ #
83
+ # class Foo
84
+ # def initialize(data_needed_for_finalization)
85
+ # ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization))
86
+ # end
87
+ #
88
+ # def self.create_finalizer(data_needed_for_finalization)
89
+ # proc {
90
+ # puts "finalizing #{data_needed_for_finalization}"
91
+ # }
92
+ # end
93
+ # end
94
+ #
95
+ # class Bar
96
+ # class Remover
97
+ # def initialize(data_needed_for_finalization)
98
+ # @data_needed_for_finalization = data_needed_for_finalization
99
+ # end
100
+ #
101
+ # def call(id)
102
+ # puts "finalizing #{@data_needed_for_finalization}"
103
+ # end
104
+ # end
105
+ #
106
+ # def initialize(data_needed_for_finalization)
107
+ # ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization))
108
+ # end
109
+ # end
110
+ #
111
+ # Note that if your finalizer references the object to be finalized it will
112
+ # never be run on GC, although it will still be run at exit. You will get a
113
+ # warning if you capture the object to be finalized as the receiver of the
114
+ # finalizer.
115
+ #
116
+ # class CapturesSelf
117
+ # def initialize(name)
118
+ # ObjectSpace.define_finalizer(self, proc {
119
+ # # this finalizer will only be run on exit
120
+ # puts "finalizing #{name}"
121
+ # })
122
+ # end
123
+ # end
124
+ #
125
+ # Also note that finalization can be unpredictable and is never guaranteed to be
126
+ # run except on exit.
127
+ #
57
128
  def self.define_finalizer: (untyped obj, ^(Integer id) -> void aProc) -> [ Integer, Proc ]
58
129
  | (untyped obj) { (Integer id) -> void } -> [ Integer, Proc ]
59
130
 
131
+ # <!--
132
+ # rdoc-file=gc.c
133
+ # - ObjectSpace.each_object([module]) {|obj| ... } -> integer
134
+ # - ObjectSpace.each_object([module]) -> an_enumerator
135
+ # -->
60
136
  # Calls the block once for each living, nonimmediate object in this Ruby
61
137
  # process. If *module* is specified, calls the block for only those classes or
62
138
  # modules that match (or are a subclass of) *module*. Returns the number of
@@ -86,13 +162,27 @@ module ObjectSpace
86
162
  def self.each_object: (?Module `module`) -> Enumerator[untyped, Integer]
87
163
  | (?Module `module`) { (untyped obj) -> void } -> Integer
88
164
 
165
+ # <!--
166
+ # rdoc-file=gc.rb
167
+ # - garbage_collect(full_mark: true, immediate_mark: true, immediate_sweep: true)
168
+ # -->
169
+ #
89
170
  def self.garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool) -> void
90
171
 
172
+ # <!--
173
+ # rdoc-file=gc.c
174
+ # - ObjectSpace.undefine_finalizer(obj)
175
+ # -->
91
176
  # Removes all finalizers for *obj*.
92
177
  #
93
178
  def self.undefine_finalizer: [X] (X obj) -> X
94
179
 
95
180
  private
96
181
 
182
+ # <!--
183
+ # rdoc-file=gc.rb
184
+ # - garbage_collect(full_mark: true, immediate_mark: true, immediate_sweep: true)
185
+ # -->
186
+ #
97
187
  def garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool) -> void
98
188
  end