rbs 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1091,5 +1091,5 @@ module Kernel
1091
1091
  #
1092
1092
  # See also Pathname::new for more information.
1093
1093
  #
1094
- def Pathname: (String | Pathname) -> Pathname
1094
+ def self?.Pathname: (String | Pathname) -> Pathname
1095
1095
  end
@@ -0,0 +1,366 @@
1
+ # This class implements a pretty printing algorithm. It finds line breaks and
2
+ # nice indentations for grouped structure.
3
+ #
4
+ # By default, the class assumes that primitive elements are strings and each
5
+ # byte in the strings have single column in width. But it can be used for other
6
+ # situations by giving suitable arguments for some methods:
7
+ # * newline object and space generation block for PrettyPrint.new
8
+ # * optional width argument for PrettyPrint#text
9
+ # * PrettyPrint#breakable
10
+ #
11
+ #
12
+ # There are several candidate uses:
13
+ # * text formatting using proportional fonts
14
+ # * multibyte characters which has columns different to number of bytes
15
+ # * non-string formatting
16
+ #
17
+ #
18
+ # ## Bugs
19
+ # * Box based formatting?
20
+ # * Other (better) model/algorithm?
21
+ #
22
+ #
23
+ # Report any bugs at http://bugs.ruby-lang.org
24
+ #
25
+ # ## References
26
+ # Christian Lindig, Strictly Pretty, March 2000,
27
+ # http://www.st.cs.uni-sb.de/~lindig/papers/#pretty
28
+ #
29
+ # Philip Wadler, A prettier printer, March 1998,
30
+ # http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
31
+ #
32
+ # ## Author
33
+ # Tanaka Akira <akr@fsij.org>
34
+ class PrettyPrint
35
+ interface _Output
36
+ def <<: (String) -> void
37
+ end
38
+
39
+ # This is a convenience method which is same as follows:
40
+ #
41
+ # begin
42
+ # q = PrettyPrint.new(output, maxwidth, newline, &genspace)
43
+ # ...
44
+ # q.flush
45
+ # output
46
+ # end
47
+ #
48
+ def self.format: (?untyped output, ?Integer maxwidth, ?String newline, ?^(Integer) -> Integer genspace) { (PrettyPrint) -> untyped } -> _Output
49
+
50
+ # This is similar to PrettyPrint::format but the result has no breaks.
51
+ #
52
+ # `maxwidth`, `newline` and `genspace` are ignored.
53
+ #
54
+ # The invocation of `breakable` in the block doesn't break a line and is treated
55
+ # as just an invocation of `text`.
56
+ #
57
+ def self.singleline_format: (?untyped output, ?Integer? maxwidth, ?String? newline, ?^(Integer) -> Integer? genspace ) { (PrettyPrint::SingleLine) -> untyped } -> _Output
58
+
59
+ # Creates a buffer for pretty printing.
60
+ #
61
+ # `output` is an output target. If it is not specified, '' is assumed. It should
62
+ # have a << method which accepts the first argument `obj` of PrettyPrint#text,
63
+ # the first argument `sep` of PrettyPrint#breakable, the first argument
64
+ # `newline` of PrettyPrint.new, and the result of a given block for
65
+ # PrettyPrint.new.
66
+ #
67
+ # `maxwidth` specifies maximum line length. If it is not specified, 79 is
68
+ # assumed. However actual outputs may overflow `maxwidth` if long non-breakable
69
+ # texts are provided.
70
+ #
71
+ # `newline` is used for line breaks. "n" is used if it is not specified.
72
+ #
73
+ # The block is used to generate spaces. {|width| ' ' * width} is used if it is
74
+ # not given.
75
+ #
76
+ def initialize: (?untyped output, ?Integer maxwidth, ?String newline, ?^(Integer) -> Integer genspace) -> void
77
+
78
+ # The output object.
79
+ #
80
+ # This defaults to '', and should accept the << method
81
+ attr_reader output: _Output
82
+
83
+ # The maximum width of a line, before it is separated in to a newline
84
+ #
85
+ # This defaults to 79, and should be a Fixnum
86
+ attr_reader maxwidth: Integer
87
+
88
+ # The value that is appended to +output+ to add a new line.
89
+ #
90
+ # This defaults to "\n", and should be String
91
+ attr_reader newline: String
92
+
93
+ # A lambda or Proc, that takes one argument, of a Fixnum, and returns
94
+ # the corresponding number of spaces.
95
+ #
96
+ # By default this is:
97
+ # lambda {|n| ' ' * n}
98
+ attr_reader genspace: Proc
99
+
100
+ # The number of spaces to be indented
101
+ attr_reader indent: Integer
102
+
103
+ # The PrettyPrint::GroupQueue of groups in stack to be pretty printed
104
+ attr_reader group_queue: PrettyPrint::GroupQueue
105
+
106
+ # Returns the group most recently added to the stack.
107
+ #
108
+ # Contrived example:
109
+ # out = ""
110
+ # => ""
111
+ # q = PrettyPrint.new(out)
112
+ # => #<PrettyPrint:0x82f85c0 @output="", @maxwidth=79, @newline="\n", @genspace=#<Proc:0x82f8368@/home/vbatts/.rvm/rubies/ruby-head/lib/ruby/2.0.0/prettyprint.rb:82 (lambda)>, @output_width=0, @buffer_width=0, @buffer=[], @group_stack=[#<PrettyPrint::Group:0x82f8138 @depth=0, @breakables=[], @break=false>], @group_queue=#<PrettyPrint::GroupQueue:0x82fb7c0 @queue=[[#<PrettyPrint::Group:0x82f8138 @depth=0, @breakables=[], @break=false>]]>, @indent=0>
113
+ # q.group {
114
+ # q.text q.current_group.inspect
115
+ # q.text q.newline
116
+ # q.group(q.current_group.depth + 1) {
117
+ # q.text q.current_group.inspect
118
+ # q.text q.newline
119
+ # q.group(q.current_group.depth + 1) {
120
+ # q.text q.current_group.inspect
121
+ # q.text q.newline
122
+ # q.group(q.current_group.depth + 1) {
123
+ # q.text q.current_group.inspect
124
+ # q.text q.newline
125
+ # }
126
+ # }
127
+ # }
128
+ # }
129
+ # => 284
130
+ # puts out
131
+ # #<PrettyPrint::Group:0x8354758 @depth=1, @breakables=[], @break=false>
132
+ # #<PrettyPrint::Group:0x8354550 @depth=2, @breakables=[], @break=false>
133
+ # #<PrettyPrint::Group:0x83541cc @depth=3, @breakables=[], @break=false>
134
+ # #<PrettyPrint::Group:0x8347e54 @depth=4, @breakables=[], @break=false>
135
+ #
136
+ def current_group: () -> PrettyPrint::Group
137
+
138
+ # Breaks the buffer into lines that are shorter than #maxwidth
139
+ #
140
+ def break_outmost_groups: () -> untyped
141
+
142
+ # This adds `obj` as a text of `width` columns in width.
143
+ #
144
+ # If `width` is not specified, obj.length is used.
145
+ #
146
+ def text: (String obj, ?Integer width) -> void
147
+
148
+ # This is similar to #breakable except the decision to break or not is
149
+ # determined individually.
150
+ #
151
+ # Two #fill_breakable under a group may cause 4 results: (break,break),
152
+ # (break,non-break), (non-break,break), (non-break,non-break). This is different
153
+ # to #breakable because two #breakable under a group may cause 2 results:
154
+ # (break,break), (non-break,non-break).
155
+ #
156
+ # The text `sep` is inserted if a line is not broken at this point.
157
+ #
158
+ # If `sep` is not specified, " " is used.
159
+ #
160
+ # If `width` is not specified, `sep.length` is used. You will have to specify
161
+ # this when `sep` is a multibyte character, for example.
162
+ #
163
+ def fill_breakable: (?String sep, ?Integer width) -> void
164
+
165
+ # This says "you can break a line here if necessary", and a `width`-column text
166
+ # `sep` is inserted if a line is not broken at the point.
167
+ #
168
+ # If `sep` is not specified, " " is used.
169
+ #
170
+ # If `width` is not specified, `sep.length` is used. You will have to specify
171
+ # this when `sep` is a multibyte character, for example.
172
+ #
173
+ def breakable: (?String sep, ?Integer width) -> void
174
+
175
+ # Groups line break hints added in the block. The line break hints are all to be
176
+ # used or not.
177
+ #
178
+ # If `indent` is specified, the method call is regarded as nested by
179
+ # nest(indent) { ... }.
180
+ #
181
+ # If `open_obj` is specified, `text open_obj, open_width` is called before
182
+ # grouping. If `close_obj` is specified, `text close_obj, close_width` is called
183
+ # after grouping.
184
+ #
185
+ def group: (?::Integer indent, ?::String open_obj, ?::String close_obj, ?Integer open_width, ?Integer close_width) { () -> untyped } -> Integer
186
+
187
+ # Takes a block and queues a new group that is indented 1 level further.
188
+ #
189
+ def group_sub: () { () -> untyped } -> untyped
190
+
191
+ # Increases left margin after newline with `indent` for line breaks added in the
192
+ # block.
193
+ #
194
+ def nest: (Integer indent) { () -> untyped } -> void
195
+
196
+ # outputs buffered data.
197
+ #
198
+ def flush: () -> Integer
199
+
200
+ class Text
201
+ # Creates a new text object.
202
+ #
203
+ # This constructor takes no arguments.
204
+ #
205
+ # The workflow is to append a PrettyPrint::Text object to the buffer, and
206
+ # being able to call the buffer.last() to reference it.
207
+ #
208
+ # As there are objects, use PrettyPrint::Text#add to include the objects
209
+ # and the width to utilized by the String version of this object.
210
+ def initialize: () -> void
211
+
212
+ # The total width of the objects included in this Text object.
213
+ attr_reader width: Integer
214
+
215
+ # Render the String text of the objects that have been added to this Text object.
216
+ #
217
+ # Output the text to +out+, and increment the width to +output_width+
218
+ def output: (untyped `out`, untyped output_width) -> untyped
219
+
220
+ # Include +obj+ in the objects to be pretty printed, and increment
221
+ # this Text object's total width by +width+
222
+ def add: (untyped obj, Integer width) -> void
223
+ end
224
+
225
+ class Breakable
226
+ # Create a new Breakable object.
227
+ #
228
+ # Arguments:
229
+ # * +sep+ String of the separator
230
+ # * +width+ Fixnum width of the +sep+
231
+ # * +q+ parent PrettyPrint object, to base from
232
+ def initialize: (String sep, Integer width, PrettyPrint q) -> void
233
+
234
+ # Holds the separator String
235
+ #
236
+ # The +sep+ argument from ::new
237
+ attr_reader obj: String
238
+
239
+ # The width of +obj+ / +sep+
240
+ attr_reader width: Integer
241
+
242
+ # The number of spaces to indent.
243
+ #
244
+ # This is inferred from +q+ within PrettyPrint, passed in ::new
245
+ attr_reader indent: Integer
246
+
247
+ # Render the String text of the objects that have been added to this
248
+ # Breakable object.
249
+ #
250
+ # Output the text to +out+, and increment the width to +output_width+
251
+ def output: (untyped `out`, Integer output_width) -> untyped
252
+ end
253
+
254
+ class Group
255
+ # The Group class is used for making indentation easier.
256
+ #
257
+ # While this class does neither the breaking into newlines nor indentation,
258
+ # it is used in a stack (as well as a queue) within PrettyPrint, to group
259
+ # objects.
260
+ #
261
+ # For information on using groups, see PrettyPrint#group
262
+ #
263
+ # This class is intended for internal use of the PrettyPrint buffers.
264
+ # :nodoc:
265
+ # Create a Group object
266
+ #
267
+ # Arguments:
268
+ # * +depth+ - this group's relation to previous groups
269
+ def initialize: (untyped depth) -> void
270
+
271
+ # This group's relation to previous groups
272
+ attr_reader depth: untyped
273
+
274
+ # Array to hold the Breakable objects for this Group
275
+ attr_reader breakables: Array[PrettyPrint::Breakable]
276
+
277
+ # Makes a break for this Group, and returns true
278
+ def break: () -> bool
279
+
280
+ # Boolean of whether this Group has made a break
281
+ def break?: () -> bool
282
+
283
+ # Boolean of whether this Group has been queried for being first
284
+ #
285
+ # This is used as a predicate, and ought to be called first.
286
+ def first?: () -> bool
287
+ end
288
+
289
+ class GroupQueue
290
+ # The GroupQueue class is used for managing the queue of Group to be pretty
291
+ # printed.
292
+ #
293
+ # This queue groups the Group objects, based on their depth.
294
+ #
295
+ # This class is intended for internal use of the PrettyPrint buffers.
296
+ # :nodoc:
297
+ # Create a GroupQueue object
298
+ #
299
+ # Arguments:
300
+ # * +groups+ - one or more PrettyPrint::Group objects
301
+ def initialize: (*untyped groups) -> void
302
+
303
+ # Enqueue +group+
304
+ #
305
+ # This does not strictly append the group to the end of the queue,
306
+ # but instead adds it in line, base on the +group.depth+
307
+ def enq: (untyped group) -> void
308
+
309
+ # Returns the outer group of the queue
310
+ def deq: () -> (PrettyPrint::Group | nil)
311
+
312
+ # Remote +group+ from this queue
313
+ def delete: (PrettyPrint::Group group) -> void
314
+ end
315
+
316
+ # PrettyPrint::SingleLine is used by PrettyPrint.singleline_format
317
+ #
318
+ # It is passed to be similar to a PrettyPrint object itself, by responding to:
319
+ # * #text
320
+ # * #breakable
321
+ # * #nest
322
+ # * #group
323
+ # * #flush
324
+ # * #first?
325
+ #
326
+ # but instead, the output has no line breaks
327
+ #
328
+ class SingleLine
329
+ # Create a PrettyPrint::SingleLine object
330
+ #
331
+ # Arguments:
332
+ # * +output+ - String (or similar) to store rendered text. Needs to respond to '<<'
333
+ # * +maxwidth+ - Argument position expected to be here for compatibility.
334
+ # This argument is a noop.
335
+ # * +newline+ - Argument position expected to be here for compatibility.
336
+ # This argument is a noop.
337
+ def initialize: (String | untyped output, ?Integer? maxwidth, ?String? newline) -> void
338
+
339
+ # Add +obj+ to the text to be output.
340
+ #
341
+ # +width+ argument is here for compatibility. It is a noop argument.
342
+ def text: (String obj, ?Integer? width) -> void
343
+
344
+ # Appends +sep+ to the text to be output. By default +sep+ is ' '
345
+ #
346
+ # +width+ argument is here for compatibility. It is a noop argument.
347
+ def breakable: (?String sep, ?Integer? width) -> void
348
+
349
+ def nest: (untyped indent) { () -> untyped } -> void
350
+
351
+ # Opens a block for grouping objects to be pretty printed.
352
+ #
353
+ # Arguments:
354
+ # * +indent+ - noop argument. Present for compatibility.
355
+ # * +open_obj+ - text appended before the &blok. Default is ''
356
+ # * +close_obj+ - text appended after the &blok. Default is ''
357
+ # * +open_width+ - noop argument. Present for compatibility.
358
+ # * +close_width+ - noop argument. Present for compatibility.
359
+ def group: (?Integer? indent, ?String open_obj, ?String close_obj, ?Integer? open_width, ?Integer? close_width) { () -> untyped } -> untyped
360
+
361
+ def flush: () -> nil
362
+
363
+ # This is used as a predicate, and ought to be called first.
364
+ def first?: () -> bool
365
+ end
366
+ end
@@ -397,5 +397,5 @@ module Kernel
397
397
 
398
398
  # Returns `uri` converted to an URI object.
399
399
  #
400
- def URI: (URI::Generic | String uri) -> URI::Generic
400
+ def self?.URI: (URI::Generic | String uri) -> URI::Generic
401
401
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-24 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RBS is the language for type signatures for Ruby and standard library
14
14
  definitions.
@@ -46,7 +46,6 @@ files:
46
46
  - core/comparable.rbs
47
47
  - core/complex.rbs
48
48
  - core/constants.rbs
49
- - core/data.rbs
50
49
  - core/deprecated.rbs
51
50
  - core/dir.rbs
52
51
  - core/encoding.rbs
@@ -203,6 +202,7 @@ files:
203
202
  - stdlib/dbm/0/dbm.rbs
204
203
  - stdlib/erb/0/erb.rbs
205
204
  - stdlib/fiber/0/fiber.rbs
205
+ - stdlib/fileutils/0/fileutils.rbs
206
206
  - stdlib/find/0/find.rbs
207
207
  - stdlib/forwardable/0/forwardable.rbs
208
208
  - stdlib/ipaddr/0/ipaddr.rbs
@@ -215,6 +215,7 @@ files:
215
215
  - stdlib/monitor/0/monitor.rbs
216
216
  - stdlib/mutex_m/0/mutex_m.rbs
217
217
  - stdlib/pathname/0/pathname.rbs
218
+ - stdlib/prettyprint/0/prettyprint.rbs
218
219
  - stdlib/prime/0/integer-extension.rbs
219
220
  - stdlib/prime/0/prime.rbs
220
221
  - stdlib/pstore/0/pstore.rbs
@@ -257,14 +258,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
258
  requirements:
258
259
  - - ">="
259
260
  - !ruby/object:Gem::Version
260
- version: '0'
261
+ version: '2.6'
261
262
  required_rubygems_version: !ruby/object:Gem::Requirement
262
263
  requirements:
263
264
  - - ">="
264
265
  - !ruby/object:Gem::Version
265
266
  version: '0'
266
267
  requirements: []
267
- rubygems_version: 3.1.2
268
+ rubygems_version: 3.2.3
268
269
  signing_key:
269
270
  specification_version: 4
270
271
  summary: Type signature for Ruby.
@@ -1,5 +0,0 @@
1
- # This is a deprecated class, base class for C extensions using Data_Make_Struct
2
- # or Data_Wrap_Struct.
3
- #
4
- class Data < Object
5
- end