rbs 2.0.0 → 2.2.2

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.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +34 -0
  3. data/.github/workflows/ruby.yml +5 -0
  4. data/CHANGELOG.md +82 -0
  5. data/README.md +6 -1
  6. data/Rakefile +56 -21
  7. data/core/array.rbs +2866 -1086
  8. data/core/basic_object.rbs +150 -30
  9. data/core/binding.rbs +33 -0
  10. data/core/builtin.rbs +4 -4
  11. data/core/class.rbs +43 -5
  12. data/core/comparable.rbs +57 -0
  13. data/core/complex.rbs +170 -4
  14. data/core/constants.rbs +51 -0
  15. data/core/deprecated.rbs +7 -0
  16. data/core/dir.rbs +305 -20
  17. data/core/encoding.rbs +1214 -77
  18. data/core/enumerable.rbs +2173 -234
  19. data/core/enumerator.rbs +448 -182
  20. data/core/env.rbs +448 -1
  21. data/core/errno.rbs +1 -10
  22. data/core/errors.rbs +152 -2
  23. data/core/exception.rbs +201 -127
  24. data/core/false_class.rbs +27 -0
  25. data/core/fiber.rbs +118 -37
  26. data/core/fiber_error.rbs +8 -9
  27. data/core/file.rbs +1060 -142
  28. data/core/file_test.rbs +287 -32
  29. data/core/float.rbs +776 -300
  30. data/core/gc.rbs +185 -34
  31. data/core/global_variables.rbs +5 -1
  32. data/core/hash.rbs +1582 -649
  33. data/core/integer.rbs +974 -204
  34. data/core/io/buffer.rbs +710 -0
  35. data/core/io/wait.rbs +29 -8
  36. data/core/io.rbs +2438 -417
  37. data/core/kernel.rbs +2319 -318
  38. data/core/marshal.rbs +37 -2
  39. data/core/match_data.rbs +123 -6
  40. data/core/math.rbs +126 -6
  41. data/core/method.rbs +226 -102
  42. data/core/module.rbs +421 -45
  43. data/core/nil_class.rbs +64 -0
  44. data/core/numeric.rbs +620 -142
  45. data/core/object.rbs +453 -81
  46. data/core/object_space.rbs +92 -2
  47. data/core/proc.rbs +482 -285
  48. data/core/process.rbs +443 -34
  49. data/core/ractor.rbs +232 -9
  50. data/core/random.rbs +151 -52
  51. data/core/range.rbs +885 -160
  52. data/core/rational.rbs +122 -6
  53. data/core/rb_config.rbs +14 -4
  54. data/core/refinement.rbs +44 -0
  55. data/core/regexp.rbs +156 -14
  56. data/core/ruby_vm.rbs +42 -3
  57. data/core/signal.rbs +78 -39
  58. data/core/string.rbs +2123 -567
  59. data/core/string_io.rbs +204 -0
  60. data/core/struct.rbs +283 -28
  61. data/core/symbol.rbs +304 -30
  62. data/core/thread.rbs +1288 -688
  63. data/core/thread_group.rbs +66 -10
  64. data/core/time.rbs +643 -217
  65. data/core/trace_point.rbs +100 -12
  66. data/core/true_class.rbs +24 -0
  67. data/core/unbound_method.rbs +73 -7
  68. data/core/warning.rbs +37 -12
  69. data/docs/CONTRIBUTING.md +40 -34
  70. data/docs/stdlib.md +3 -102
  71. data/docs/syntax.md +54 -11
  72. data/ext/rbs_extension/extconf.rb +1 -0
  73. data/ext/rbs_extension/lexer.h +5 -0
  74. data/ext/rbs_extension/lexstate.c +6 -0
  75. data/ext/rbs_extension/parser.c +85 -10
  76. data/ext/rbs_extension/ruby_objs.c +4 -2
  77. data/ext/rbs_extension/ruby_objs.h +2 -2
  78. data/goodcheck.yml +0 -11
  79. data/lib/rbs/annotate/annotations.rb +197 -0
  80. data/lib/rbs/annotate/formatter.rb +80 -0
  81. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  82. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  83. data/lib/rbs/annotate.rb +6 -0
  84. data/lib/rbs/ast/members.rb +21 -13
  85. data/lib/rbs/buffer.rb +17 -11
  86. data/lib/rbs/cli.rb +48 -1
  87. data/lib/rbs/definition_builder/method_builder.rb +28 -16
  88. data/lib/rbs/definition_builder.rb +6 -2
  89. data/lib/rbs/environment.rb +8 -4
  90. data/lib/rbs/location_aux.rb +12 -0
  91. data/lib/rbs/namespace.rb +1 -1
  92. data/lib/rbs/prototype/rb.rb +12 -0
  93. data/lib/rbs/type_alias_regularity.rb +6 -4
  94. data/lib/rbs/type_name.rb +1 -1
  95. data/lib/rbs/types.rb +1 -1
  96. data/lib/rbs/validator.rb +6 -0
  97. data/lib/rbs/version.rb +1 -1
  98. data/lib/rbs/writer.rb +54 -4
  99. data/lib/rbs.rb +0 -2
  100. data/schema/typeParam.json +3 -3
  101. data/sig/annotate/annotations.rbs +102 -0
  102. data/sig/annotate/formatter.rbs +24 -0
  103. data/sig/annotate/rdoc_annotater.rbs +82 -0
  104. data/sig/annotate/rdoc_source.rbs +30 -0
  105. data/sig/buffer.rbs +6 -2
  106. data/sig/cli.rbs +2 -0
  107. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  108. data/sig/location.rbs +6 -0
  109. data/sig/members.rbs +24 -18
  110. data/sig/method_builder.rbs +5 -4
  111. data/sig/method_types.rbs +5 -1
  112. data/sig/polyfill.rbs +78 -0
  113. data/sig/validator.rbs +3 -1
  114. data/sig/writer.rbs +79 -2
  115. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  116. data/stdlib/abbrev/0/array.rbs +26 -0
  117. data/stdlib/base64/0/base64.rbs +31 -0
  118. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  119. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  120. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  121. data/stdlib/cgi/0/core.rbs +649 -21
  122. data/stdlib/coverage/0/coverage.rbs +164 -2
  123. data/stdlib/csv/0/csv.rbs +2862 -398
  124. data/stdlib/date/0/date.rbs +483 -25
  125. data/stdlib/date/0/date_time.rbs +187 -12
  126. data/stdlib/dbm/0/dbm.rbs +152 -17
  127. data/stdlib/digest/0/digest.rbs +146 -0
  128. data/stdlib/erb/0/erb.rbs +65 -245
  129. data/stdlib/fiber/0/fiber.rbs +73 -91
  130. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  131. data/stdlib/find/0/find.rbs +9 -0
  132. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  133. data/stdlib/io-console/0/io-console.rbs +227 -15
  134. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  135. data/stdlib/json/0/json.rbs +1147 -145
  136. data/stdlib/logger/0/formatter.rbs +24 -0
  137. data/stdlib/logger/0/log_device.rbs +64 -0
  138. data/stdlib/logger/0/logger.rbs +165 -13
  139. data/stdlib/logger/0/period.rbs +10 -0
  140. data/stdlib/logger/0/severity.rbs +26 -0
  141. data/stdlib/monitor/0/monitor.rbs +163 -0
  142. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  143. data/stdlib/net-http/0/manifest.yaml +1 -0
  144. data/stdlib/net-http/0/net-http.rbs +1513 -683
  145. data/stdlib/nkf/0/nkf.rbs +372 -0
  146. data/stdlib/objspace/0/objspace.rbs +149 -90
  147. data/stdlib/openssl/0/openssl.rbs +8108 -71
  148. data/stdlib/optparse/0/optparse.rbs +487 -19
  149. data/stdlib/pathname/0/pathname.rbs +425 -124
  150. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  151. data/stdlib/prime/0/integer-extension.rbs +20 -2
  152. data/stdlib/prime/0/prime.rbs +88 -21
  153. data/stdlib/pstore/0/pstore.rbs +102 -0
  154. data/stdlib/pty/0/pty.rbs +64 -14
  155. data/stdlib/resolv/0/resolv.rbs +420 -31
  156. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  157. data/stdlib/rubygems/0/config_file.rbs +33 -1
  158. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  159. data/stdlib/rubygems/0/installer.rbs +13 -1
  160. data/stdlib/rubygems/0/path_support.rbs +4 -1
  161. data/stdlib/rubygems/0/platform.rbs +5 -1
  162. data/stdlib/rubygems/0/request_set.rbs +44 -2
  163. data/stdlib/rubygems/0/requirement.rbs +65 -2
  164. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  165. data/stdlib/rubygems/0/source_list.rbs +13 -0
  166. data/stdlib/rubygems/0/specification.rbs +21 -1
  167. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  168. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  169. data/stdlib/rubygems/0/version.rbs +60 -157
  170. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  171. data/stdlib/set/0/set.rbs +423 -109
  172. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  173. data/stdlib/singleton/0/singleton.rbs +20 -0
  174. data/stdlib/socket/0/addrinfo.rbs +210 -9
  175. data/stdlib/socket/0/basic_socket.rbs +103 -11
  176. data/stdlib/socket/0/ip_socket.rbs +31 -9
  177. data/stdlib/socket/0/socket.rbs +586 -38
  178. data/stdlib/socket/0/tcp_server.rbs +22 -2
  179. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  180. data/stdlib/socket/0/udp_socket.rbs +25 -2
  181. data/stdlib/socket/0/unix_server.rbs +22 -2
  182. data/stdlib/socket/0/unix_socket.rbs +45 -5
  183. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  184. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  185. data/stdlib/time/0/time.rbs +208 -116
  186. data/stdlib/timeout/0/timeout.rbs +10 -0
  187. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  188. data/stdlib/tsort/0/cyclic.rbs +1 -0
  189. data/stdlib/tsort/0/interfaces.rbs +1 -0
  190. data/stdlib/tsort/0/tsort.rbs +42 -0
  191. data/stdlib/uri/0/common.rbs +57 -8
  192. data/stdlib/uri/0/file.rbs +55 -109
  193. data/stdlib/uri/0/ftp.rbs +6 -3
  194. data/stdlib/uri/0/generic.rbs +558 -329
  195. data/stdlib/uri/0/http.rbs +60 -114
  196. data/stdlib/uri/0/https.rbs +8 -102
  197. data/stdlib/uri/0/ldap.rbs +143 -137
  198. data/stdlib/uri/0/ldaps.rbs +8 -102
  199. data/stdlib/uri/0/mailto.rbs +3 -0
  200. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  201. data/stdlib/uri/0/ws.rbs +6 -3
  202. data/stdlib/uri/0/wss.rbs +5 -3
  203. data/stdlib/yaml/0/dbm.rbs +151 -87
  204. data/stdlib/yaml/0/store.rbs +6 -0
  205. data/stdlib/zlib/0/zlib.rbs +90 -31
  206. metadata +18 -6
  207. data/lib/rbs/location.rb +0 -221
  208. data/sig/char_scanner.rbs +0 -9
data/sig/writer.rbs CHANGED
@@ -1,4 +1,6 @@
1
1
  module RBS
2
+ # Writer prints RBS AST to String.
3
+ #
2
4
  class Writer
3
5
  interface _IO
4
6
  def puts: (*untyped) -> void
@@ -6,23 +8,96 @@ module RBS
6
8
  def flush: () -> void
7
9
  end
8
10
 
11
+ # Channel to output the result.
12
+ #
9
13
  attr_reader out: _IO
14
+
15
+ # Array of indentations.
16
+ #
10
17
  attr_reader indentation: Array[String]
11
18
 
12
19
  def initialize: (out: _IO) -> void
13
20
 
21
+ # Output the array of declarations.
22
+ # It automatically inserts empty lines between the declarations.
23
+ #
24
+ def write: (Array[AST::Declarations::t]) -> void
25
+
26
+ def preserve?: () -> bool
27
+
28
+ def preserve!: (?preserve: bool) -> self
29
+
30
+ private
31
+
32
+ @preserve: bool
33
+
34
+ # Increases the indentation and yields the block.
35
+ #
14
36
  def indent: (?Integer size) { () -> void } -> void
15
37
 
38
+ # Returns the current indentation of lines.
39
+ #
16
40
  def prefix: () -> String
17
41
 
42
+ # Prints a string.
43
+ # Automatically appends the `#prefix` and newline at the end.
44
+ #
18
45
  def puts: (?String) -> void
19
46
 
47
+ # Prints a (possibly) multi-line string.
48
+ #
49
+ # Drops `leading_spaces` of spaces at the beginning of each line.
50
+ #
51
+ # ```ruby
52
+ # put_lines(<<TEXT, leading_spaces: 0)
53
+ # Hello
54
+ # world!
55
+ # TEXT
56
+ #
57
+ # # Outputs
58
+ # # Hello
59
+ # # world!
60
+ #
61
+ # put_lines(<<TEXT, leading_spaces: 2)
62
+ # Hello
63
+ # world!
64
+ # TEXT
65
+ #
66
+ # # Outputs
67
+ # # Hello
68
+ # # world!
69
+ # ```
70
+ #
71
+ # This is for `Location#source`.
72
+ # The `#source` returns the text spans from the beginning to end of the element.
73
+ # It will look like the following.
74
+ #
75
+ # ```rbs
76
+ # module Foo
77
+ # type t = Integer # the definition of `t` starts from line=2, column=2
78
+ # | String
79
+ # | :false # the definition of `t` ends from line=4, column=17
80
+ # end
81
+ # ```
82
+ #
83
+ # The expected output will be something like:
84
+ #
85
+ # ```rbs
86
+ # type t = Integer # Extracted from `Foo` definition and keeps the line breaks
87
+ # | String
88
+ # | :false
89
+ # ```
90
+ #
91
+ # And it can be done with a `#put_lines(source, leading_spaces: 2)` call.
92
+ #
93
+ def put_lines: (String, leading_spaces: Integer) -> void
94
+
95
+ def write_loc_source: (_Located) { () -> void } -> void
96
+
20
97
  def write_annotation: (Array[AST::Annotation]) -> void
21
98
 
22
99
  def write_comment: (AST::Comment?) -> void
23
100
 
24
- def write: (Array[AST::Declarations::t]) -> void
25
-
26
101
  def write_decl: (AST::Declarations::t) -> void
27
102
 
28
103
  def write_member: (AST::Declarations::Module::member) -> void
@@ -31,6 +106,8 @@ module RBS
31
106
 
32
107
  def name_and_args: (TypeName, Array[Types::t]) -> String?
33
108
 
109
+ def write_alias: (AST::Declarations::Alias) -> void
110
+
34
111
  def method_name: (Symbol) -> String
35
112
 
36
113
  def write_def: (AST::Members::MethodDefinition) -> void
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=lib/abbrev.rb -->
1
2
  # Calculates the set of unambiguous abbreviations for a given set of strings.
2
3
  #
3
4
  # require 'abbrev'
@@ -34,6 +35,10 @@
34
35
  # "w" => "winter" }
35
36
  #
36
37
  module Abbrev
38
+ # <!--
39
+ # rdoc-file=lib/abbrev.rb
40
+ # - abbrev(words, pattern = nil)
41
+ # -->
37
42
  # Given a set of strings, calculate the set of unambiguous abbreviations for
38
43
  # those strings, and return a hash where the keys are all the possible
39
44
  # abbreviations and the values are the full strings.
@@ -56,5 +61,6 @@ module Abbrev
56
61
  #
57
62
  # Abbrev.abbrev(%w{car box cone}, 'ca')
58
63
  # #=> {"car"=>"car", "ca"=>"car"}
64
+ #
59
65
  def self?.abbrev: (Array[String], ?String | Regexp | nil) -> Hash[String, String]
60
66
  end
@@ -0,0 +1,26 @@
1
+ %a{annotate:rdoc:skip}
2
+ class Array[unchecked out Elem]
3
+ # <!--
4
+ # rdoc-file=lib/abbrev.rb
5
+ # - abbrev(pattern = nil)
6
+ # -->
7
+ # Calculates the set of unambiguous abbreviations for the strings in `self`.
8
+ #
9
+ # require 'abbrev'
10
+ # %w{ car cone }.abbrev
11
+ # #=> {"car"=>"car", "ca"=>"car", "cone"=>"cone", "con"=>"cone", "co"=>"cone"}
12
+ #
13
+ # The optional `pattern` parameter is a pattern or a string. Only input strings
14
+ # that match the pattern or start with the string are included in the output
15
+ # hash.
16
+ #
17
+ # %w{ fast boat day }.abbrev(/^.a/)
18
+ # #=> {"fast"=>"fast", "fas"=>"fast", "fa"=>"fast", "day"=>"day", "da"=>"day"}
19
+ #
20
+ # Abbrev.abbrev(%w{car box cone}, "ca")
21
+ # #=> {"car"=>"car", "ca"=>"car"}
22
+ #
23
+ # See also Abbrev.abbrev
24
+ #
25
+ def abbrev: (?String | Regexp | nil) -> Hash[String, String]
26
+ end
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=lib/base64.rb -->
1
2
  # The Base64 module provides for the encoding (#encode64, #strict_encode64,
2
3
  # #urlsafe_encode64) and decoding (#decode64, #strict_decode64,
3
4
  # #urlsafe_decode64) of binary data using a Base64 representation.
@@ -17,6 +18,10 @@
17
18
  # data into purely printable characters.
18
19
  #
19
20
  module Base64
21
+ # <!--
22
+ # rdoc-file=lib/base64.rb
23
+ # - decode64(str)
24
+ # -->
20
25
  # Returns the Base64-decoded version of `str`. This method complies with RFC
21
26
  # 2045. Characters outside the base alphabet are ignored.
22
27
  #
@@ -32,8 +37,13 @@ module Base64
32
37
  # This is line two
33
38
  # This is line three
34
39
  # And so on...
40
+ #
35
41
  def self?.decode64: (String str) -> String
36
42
 
43
+ # <!--
44
+ # rdoc-file=lib/base64.rb
45
+ # - encode64(bin)
46
+ # -->
37
47
  # Returns the Base64-encoded version of `bin`. This method complies with RFC
38
48
  # 2045. Line feeds are added to every 60 encoded characters.
39
49
  #
@@ -44,28 +54,49 @@ module Base64
44
54
  #
45
55
  # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
46
56
  # UnVieQ==
57
+ #
47
58
  def self?.encode64: (String bin) -> String
48
59
 
60
+ # <!--
61
+ # rdoc-file=lib/base64.rb
62
+ # - strict_decode64(str)
63
+ # -->
49
64
  # Returns the Base64-decoded version of `str`. This method complies with RFC
50
65
  # 4648. ArgumentError is raised if `str` is incorrectly padded or contains
51
66
  # non-alphabet characters. Note that CR or LF are also rejected.
67
+ #
52
68
  def self?.strict_decode64: (String str) -> String
53
69
 
70
+ # <!--
71
+ # rdoc-file=lib/base64.rb
72
+ # - strict_encode64(bin)
73
+ # -->
54
74
  # Returns the Base64-encoded version of `bin`. This method complies with RFC
55
75
  # 4648. No line feeds are added.
76
+ #
56
77
  def self?.strict_encode64: (String bin) -> String
57
78
 
79
+ # <!--
80
+ # rdoc-file=lib/base64.rb
81
+ # - urlsafe_decode64(str)
82
+ # -->
58
83
  # Returns the Base64-decoded version of `str`. This method complies with ``Base
59
84
  # 64 Encoding with URL and Filename Safe Alphabet'' in RFC 4648. The alphabet
60
85
  # uses '-' instead of '+' and '_' instead of '/'.
61
86
  #
62
87
  # The padding character is optional. This method accepts both correctly-padded
63
88
  # and unpadded input. Note that it still rejects incorrectly-padded input.
89
+ #
64
90
  def self?.urlsafe_decode64: (String str) -> String
65
91
 
92
+ # <!--
93
+ # rdoc-file=lib/base64.rb
94
+ # - urlsafe_encode64(bin, padding: true)
95
+ # -->
66
96
  # Returns the Base64-encoded version of `bin`. This method complies with ``Base
67
97
  # 64 Encoding with URL and Filename Safe Alphabet'' in RFC 4648. The alphabet
68
98
  # uses '-' instead of '+' and '_' instead of '/'. Note that the result can still
69
99
  # contain '='. You can remove the padding by setting `padding` as false.
100
+ #
70
101
  def self?.urlsafe_encode64: (String bin, ?padding: boolish) -> String
71
102
  end
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=lib/benchmark.rb -->
1
2
  # The Benchmark module provides methods to measure and report the time used to
2
3
  # execute Ruby code.
3
4
  #
@@ -101,13 +102,19 @@
101
102
  # >total: 2.880000 0.000000 2.880000 ( 2.883764)
102
103
  # >avg: 0.960000 0.000000 0.960000 ( 0.961255)
103
104
  #
104
- #
105
105
  module Benchmark
106
+ # <!--
107
+ # rdoc-file=lib/benchmark.rb
108
+ # - benchmark(caption = "", label_width = nil, format = nil, *labels) { |report| ... }
109
+ # -->
106
110
  # Invokes the block with a Benchmark::Report object, which may be used to
107
111
  # collect and report on the results of individual benchmark tests. Reserves
108
112
  # `label_width` leading spaces for labels on each line. Prints `caption` at the
109
- # top of the report, and uses `format` to format each line. Returns an array of
110
- # Benchmark::Tms objects.
113
+ # top of the report, and uses `format` to format each line. (Note: `caption`
114
+ # must contain a terminating newline character, see the default
115
+ # Benchmark::Tms::CAPTION for an example.)
116
+ #
117
+ # Returns an array of Benchmark::Tms objects.
111
118
  #
112
119
  # If the block returns an array of Benchmark::Tms objects, these will be used to
113
120
  # format additional lines of output. If `labels` parameter are given, these are
@@ -141,6 +148,10 @@ module Benchmark
141
148
  #
142
149
  def self?.benchmark: (String caption, ?Integer? label_width, ?String? format, *String labels) { (Report report) -> (Array[Tms] | void) } -> Array[Tms]
143
150
 
151
+ # <!--
152
+ # rdoc-file=lib/benchmark.rb
153
+ # - bm(label_width = 0, *labels) { |report| ... }
154
+ # -->
144
155
  # A simple interface to the #benchmark method, #bm generates sequential reports
145
156
  # with labels. `label_width` and `labels` parameters have the same meaning as
146
157
  # for #benchmark.
@@ -163,6 +174,10 @@ module Benchmark
163
174
  #
164
175
  def self?.bm: (?Integer label_width, *String labels) { (Report report) -> void } -> Array[Tms]
165
176
 
177
+ # <!--
178
+ # rdoc-file=lib/benchmark.rb
179
+ # - bmbm(width = 0) { |job| ... }
180
+ # -->
166
181
  # Sometimes benchmark results are skewed because code executed earlier
167
182
  # encounters different garbage collection overheads than that run later. #bmbm
168
183
  # attempts to minimize this effect by running the tests twice, the first time as
@@ -200,6 +215,10 @@ module Benchmark
200
215
  #
201
216
  def self?.bmbm: (?Integer width) { (Job job) -> void } -> Array[Tms]
202
217
 
218
+ # <!--
219
+ # rdoc-file=lib/benchmark.rb
220
+ # - measure(label = "") { || ... }
221
+ # -->
203
222
  # Returns the time used to execute the given block as a Benchmark::Tms object.
204
223
  # Takes `label` option.
205
224
  #
@@ -218,16 +237,22 @@ module Benchmark
218
237
  #
219
238
  def self?.measure: (?String label) { () -> void } -> Tms
220
239
 
240
+ # <!--
241
+ # rdoc-file=lib/benchmark.rb
242
+ # - realtime() { || ... }
243
+ # -->
221
244
  # Returns the elapsed real time used to execute the given block.
222
245
  #
223
246
  def self?.realtime: () { () -> void } -> Float
224
247
 
225
248
  BENCHMARK_VERSION: String
226
249
 
250
+ # <!-- rdoc-file=lib/benchmark.rb -->
227
251
  # The default caption string (heading above the output times).
228
252
  #
229
253
  CAPTION: String
230
254
 
255
+ # <!-- rdoc-file=lib/benchmark.rb -->
231
256
  # The default format string used to display times. See also
232
257
  # Benchmark::Tms#format.
233
258
  #
@@ -260,50 +285,81 @@ module Benchmark
260
285
  alias report item
261
286
  end
262
287
 
288
+ # <!-- rdoc-file=lib/benchmark.rb -->
263
289
  # A data object, representing the times associated with a benchmark measurement.
264
290
  #
265
291
  class Tms
292
+ # <!--
293
+ # rdoc-file=lib/benchmark.rb
294
+ # - *(x)
295
+ # -->
266
296
  # Returns a new Tms object obtained by memberwise multiplication of the
267
297
  # individual times for this Tms object by `x`.
268
298
  #
269
299
  def *: (untyped x) -> untyped
270
300
 
301
+ # <!--
302
+ # rdoc-file=lib/benchmark.rb
303
+ # - +(other)
304
+ # -->
271
305
  # Returns a new Tms object obtained by memberwise summation of the individual
272
306
  # times for this Tms object with those of the `other` Tms object. This method
273
307
  # and #/() are useful for taking statistics.
274
308
  #
275
309
  def +: (untyped other) -> untyped
276
310
 
311
+ # <!--
312
+ # rdoc-file=lib/benchmark.rb
313
+ # - -(other)
314
+ # -->
277
315
  # Returns a new Tms object obtained by memberwise subtraction of the individual
278
316
  # times for the `other` Tms object from those of this Tms object.
279
317
  #
280
318
  def -: (untyped other) -> untyped
281
319
 
320
+ # <!--
321
+ # rdoc-file=lib/benchmark.rb
322
+ # - /(x)
323
+ # -->
282
324
  # Returns a new Tms object obtained by memberwise division of the individual
283
325
  # times for this Tms object by `x`. This method and #+() are useful for taking
284
326
  # statistics.
285
327
  #
286
328
  def /: (untyped x) -> untyped
287
329
 
330
+ # <!--
331
+ # rdoc-file=lib/benchmark.rb
332
+ # - add() { || ... }
333
+ # -->
288
334
  # Returns a new Tms object whose times are the sum of the times for this Tms
289
335
  # object, plus the time required to execute the code block (`blk`).
290
336
  #
291
337
  def add: () { (*untyped) -> untyped } -> untyped
292
338
 
339
+ # <!--
340
+ # rdoc-file=lib/benchmark.rb
341
+ # - add!(&blk)
342
+ # -->
293
343
  # An in-place version of #add. Changes the times of this Tms object by making it
294
344
  # the sum of the times for this Tms object, plus the time required to execute
295
345
  # the code block (`blk`).
296
346
  #
297
347
  def add!: () { (*untyped) -> untyped } -> untyped
298
348
 
349
+ # <!-- rdoc-file=lib/benchmark.rb -->
299
350
  # System CPU time of children
300
351
  #
301
352
  def cstime: () -> Float
302
353
 
354
+ # <!-- rdoc-file=lib/benchmark.rb -->
303
355
  # User CPU time of children
304
356
  #
305
357
  def cutime: () -> Float
306
358
 
359
+ # <!--
360
+ # rdoc-file=lib/benchmark.rb
361
+ # - format(format = nil, *args)
362
+ # -->
307
363
  # Returns the contents of this Tms object as a formatted string, according to a
308
364
  # `format` string like that passed to Kernel.format. In addition, #format
309
365
  # accepts the following extensions:
@@ -331,40 +387,55 @@ module Benchmark
331
387
  #
332
388
  def format: (?String format, *untyped args) -> String
333
389
 
390
+ # <!-- rdoc-file=lib/benchmark.rb -->
334
391
  # Label
335
392
  #
336
393
  def label: () -> String
337
394
 
395
+ # <!-- rdoc-file=lib/benchmark.rb -->
338
396
  # Elapsed real time
339
397
  #
340
398
  def real: () -> Float
341
399
 
400
+ # <!-- rdoc-file=lib/benchmark.rb -->
342
401
  # System CPU time
343
402
  #
344
403
  def stime: () -> Float
345
404
 
405
+ # <!--
406
+ # rdoc-file=lib/benchmark.rb
407
+ # - to_a()
408
+ # -->
346
409
  # Returns a new 6-element array, consisting of the label, user CPU time, system
347
410
  # CPU time, children's user CPU time, children's system CPU time and elapsed
348
411
  # real time.
349
412
  #
350
413
  def to_a: () -> untyped
351
414
 
415
+ # <!--
416
+ # rdoc-file=lib/benchmark.rb
417
+ # - to_s()
418
+ # -->
352
419
  # Same as #format.
353
420
  #
354
421
  def to_s: () -> String
355
422
 
423
+ # <!-- rdoc-file=lib/benchmark.rb -->
356
424
  # Total time, that is `utime` + `stime` + `cutime` + `cstime`
357
425
  #
358
426
  def total: () -> Float
359
427
 
428
+ # <!-- rdoc-file=lib/benchmark.rb -->
360
429
  # User CPU time
361
430
  #
362
431
  def utime: () -> Float
363
432
 
433
+ # <!-- rdoc-file=lib/benchmark.rb -->
364
434
  # Default caption, see also Benchmark::CAPTION
365
435
  #
366
436
  CAPTION: String
367
437
 
438
+ # <!-- rdoc-file=lib/benchmark.rb -->
368
439
  # Default format string, see also Benchmark::FORMAT
369
440
  #
370
441
  FORMAT: String