rbs 2.6.0 → 2.7.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +5 -0
  4. data/CHANGELOG.md +48 -1
  5. data/Gemfile.lock +10 -9
  6. data/Rakefile +0 -5
  7. data/Steepfile +1 -0
  8. data/core/basic_object.rbs +2 -2
  9. data/core/fiber.rbs +304 -14
  10. data/core/float.rbs +2 -0
  11. data/core/io.rbs +95 -1
  12. data/core/kernel.rbs +1 -1
  13. data/core/module.rbs +1 -1
  14. data/core/regexp.rbs +1 -1
  15. data/core/string_io.rbs +1 -1
  16. data/core/warning.rbs +1 -1
  17. data/ext/rbs_extension/parser.c +36 -10
  18. data/ext/rbs_extension/ruby_objs.c +4 -2
  19. data/ext/rbs_extension/ruby_objs.h +2 -2
  20. data/lib/rbs/ancestor_graph.rb +2 -0
  21. data/lib/rbs/annotate/annotations.rb +2 -0
  22. data/lib/rbs/annotate/formatter.rb +4 -2
  23. data/lib/rbs/annotate/rdoc_annotator.rb +2 -0
  24. data/lib/rbs/annotate/rdoc_source.rb +2 -0
  25. data/lib/rbs/annotate.rb +2 -0
  26. data/lib/rbs/ast/annotation.rb +2 -0
  27. data/lib/rbs/ast/comment.rb +2 -0
  28. data/lib/rbs/ast/declarations.rb +2 -0
  29. data/lib/rbs/ast/members.rb +2 -0
  30. data/lib/rbs/ast/type_param.rb +3 -1
  31. data/lib/rbs/buffer.rb +2 -0
  32. data/lib/rbs/builtin_names.rb +2 -0
  33. data/lib/rbs/cli.rb +39 -2
  34. data/lib/rbs/collection/cleaner.rb +2 -0
  35. data/lib/rbs/collection/config/lockfile_generator.rb +8 -3
  36. data/lib/rbs/collection/config.rb +2 -0
  37. data/lib/rbs/collection/installer.rb +2 -0
  38. data/lib/rbs/collection/sources/base.rb +14 -0
  39. data/lib/rbs/collection/sources/git.rb +3 -0
  40. data/lib/rbs/collection/sources/rubygems.rb +3 -0
  41. data/lib/rbs/collection/sources/stdlib.rb +12 -7
  42. data/lib/rbs/collection/sources.rb +3 -0
  43. data/lib/rbs/collection.rb +2 -0
  44. data/lib/rbs/constant.rb +2 -0
  45. data/lib/rbs/constant_table.rb +5 -3
  46. data/lib/rbs/definition.rb +13 -1
  47. data/lib/rbs/definition_builder/ancestor_builder.rb +2 -0
  48. data/lib/rbs/definition_builder/method_builder.rb +2 -0
  49. data/lib/rbs/definition_builder.rb +75 -13
  50. data/lib/rbs/environment.rb +2 -0
  51. data/lib/rbs/environment_loader.rb +25 -5
  52. data/lib/rbs/environment_walker.rb +2 -0
  53. data/lib/rbs/errors.rb +3 -1
  54. data/lib/rbs/factory.rb +2 -0
  55. data/lib/rbs/location_aux.rb +3 -1
  56. data/lib/rbs/locator.rb +2 -0
  57. data/lib/rbs/method_type.rb +7 -5
  58. data/lib/rbs/namespace.rb +9 -5
  59. data/lib/rbs/parser_aux.rb +2 -0
  60. data/lib/rbs/parser_compat/lexer_error.rb +2 -0
  61. data/lib/rbs/parser_compat/located_value.rb +2 -0
  62. data/lib/rbs/parser_compat/semantics_error.rb +2 -0
  63. data/lib/rbs/parser_compat/syntax_error.rb +2 -0
  64. data/lib/rbs/prototype/helpers.rb +13 -8
  65. data/lib/rbs/prototype/rb.rb +2 -0
  66. data/lib/rbs/prototype/rbi.rb +11 -6
  67. data/lib/rbs/prototype/runtime.rb +13 -4
  68. data/lib/rbs/repository.rb +4 -4
  69. data/lib/rbs/resolver/constant_resolver.rb +2 -0
  70. data/lib/rbs/resolver/type_name_resolver.rb +2 -0
  71. data/lib/rbs/sorter.rb +168 -0
  72. data/lib/rbs/substitution.rb +2 -0
  73. data/lib/rbs/test/errors.rb +2 -0
  74. data/lib/rbs/test/hook.rb +2 -0
  75. data/lib/rbs/test/observer.rb +2 -0
  76. data/lib/rbs/test/setup.rb +2 -0
  77. data/lib/rbs/test/setup_helper.rb +2 -0
  78. data/lib/rbs/test/spy.rb +2 -0
  79. data/lib/rbs/test/tester.rb +2 -0
  80. data/lib/rbs/test/type_check.rb +2 -0
  81. data/lib/rbs/test.rb +2 -0
  82. data/lib/rbs/type_alias_dependency.rb +2 -0
  83. data/lib/rbs/type_alias_regularity.rb +2 -0
  84. data/lib/rbs/type_name.rb +2 -0
  85. data/lib/rbs/type_name_resolver.rb +4 -2
  86. data/lib/rbs/types.rb +68 -18
  87. data/lib/rbs/validator.rb +2 -0
  88. data/lib/rbs/variance_calculator.rb +2 -0
  89. data/lib/rbs/vendorer.rb +2 -0
  90. data/lib/rbs/version.rb +3 -1
  91. data/lib/rbs/writer.rb +3 -1
  92. data/lib/rbs.rb +4 -2
  93. data/lib/rdoc/discover.rb +20 -0
  94. data/lib/rdoc_plugin/parser.rb +163 -0
  95. data/schema/methodType.json +7 -1
  96. data/schema/types.json +13 -1
  97. data/sig/ancestor_builder.rbs +66 -7
  98. data/sig/annotation.rbs +7 -6
  99. data/sig/builtin_names.rbs +2 -0
  100. data/sig/cli.rbs +8 -0
  101. data/sig/collection/config.rbs +13 -4
  102. data/sig/collection/installer.rbs +2 -0
  103. data/sig/collection/sources.rbs +23 -4
  104. data/sig/definition.rbs +8 -0
  105. data/sig/definition_builder.rbs +64 -7
  106. data/sig/environment.rbs +4 -0
  107. data/sig/environment_loader.rbs +4 -2
  108. data/sig/location.rbs +8 -4
  109. data/sig/manifest.yaml +1 -0
  110. data/sig/members.rbs +1 -1
  111. data/sig/method_builder.rbs +10 -0
  112. data/sig/namespace.rbs +54 -31
  113. data/sig/prototype/rb.rbs +4 -0
  114. data/sig/rbs.rbs +8 -6
  115. data/sig/rdoc/rbs.rbs +63 -0
  116. data/sig/{polyfill.rbs → shims.rbs} +1 -31
  117. data/sig/sorter.rbs +23 -0
  118. data/sig/types.rbs +14 -2
  119. data/sig/vendorer.rbs +32 -25
  120. data/stdlib/bigdecimal/0/big_decimal.rbs +250 -0
  121. data/stdlib/erb/0/erb.rbs +107 -0
  122. data/stdlib/logger/0/logger.rbs +2 -2
  123. data/stdlib/rdoc/0/rdoc.rbs +758 -0
  124. data/steep/Gemfile.lock +8 -8
  125. metadata +12 -6
  126. data/stdlib/fiber/0/fiber.rbs +0 -99
@@ -1408,6 +1408,74 @@ class Integer
1408
1408
  # See also BigDecimal::new.
1409
1409
  #
1410
1410
  def to_d: () -> BigDecimal
1411
+
1412
+ # <!--
1413
+ # rdoc-file=numeric.c
1414
+ # - self / numeric -> numeric_result
1415
+ # -->
1416
+ # Performs division; for integer `numeric`, truncates the result to an integer:
1417
+ #
1418
+ # 4 / 3 # => 1
1419
+ # 4 / -3 # => -2
1420
+ # -4 / 3 # => -2
1421
+ # -4 / -3 # => 1
1422
+ #
1423
+ # For other +numeric+, returns non-integer result:
1424
+ #
1425
+ # 4 / 3.0 # => 1.3333333333333333
1426
+ # 4 / Rational(3, 1) # => (4/3)
1427
+ # 4 / Complex(3, 0) # => ((4/3)+0i)
1428
+ #
1429
+ def /: (BigDecimal) -> BigDecimal
1430
+ | ...
1431
+
1432
+ # <!--
1433
+ # rdoc-file=numeric.c
1434
+ # - self * numeric -> numeric_result
1435
+ # -->
1436
+ # Performs multiplication:
1437
+ #
1438
+ # 4 * 2 # => 8
1439
+ # 4 * -2 # => -8
1440
+ # -4 * 2 # => -8
1441
+ # 4 * 2.0 # => 8.0
1442
+ # 4 * Rational(1, 3) # => (4/3)
1443
+ # 4 * Complex(2, 0) # => (8+0i)
1444
+ #
1445
+ def *: (BigDecimal) -> BigDecimal
1446
+ | ...
1447
+
1448
+ # <!--
1449
+ # rdoc-file=numeric.c
1450
+ # - self + numeric -> numeric_result
1451
+ # -->
1452
+ # Performs addition:
1453
+ #
1454
+ # 2 + 2 # => 4
1455
+ # -2 + 2 # => 0
1456
+ # -2 + -2 # => -4
1457
+ # 2 + 2.0 # => 4.0
1458
+ # 2 + Rational(2, 1) # => (4/1)
1459
+ # 2 + Complex(2, 0) # => (4+0i)
1460
+ #
1461
+ def +: (BigDecimal) -> BigDecimal
1462
+ | ...
1463
+
1464
+ # <!--
1465
+ # rdoc-file=numeric.c
1466
+ # - self - numeric -> numeric_result
1467
+ # -->
1468
+ # Performs subtraction:
1469
+ #
1470
+ # 4 - 2 # => 2
1471
+ # -4 - 2 # => -6
1472
+ # -4 - -2 # => -2
1473
+ # 4 - 2.0 # => 2.0
1474
+ # 4 - Rational(2, 1) # => (2/1)
1475
+ # 4 - Complex(2, 0) # => (2+0i)
1476
+ #
1477
+ def -: (BigDecimal) -> BigDecimal
1478
+ | ...
1411
1479
  end
1412
1480
 
1413
1481
  %a{annotate:rdoc:skip}
@@ -1430,6 +1498,66 @@ class Float
1430
1498
  # See also BigDecimal::new.
1431
1499
  #
1432
1500
  def to_d: (?Integer precision) -> BigDecimal
1501
+
1502
+ # <!--
1503
+ # rdoc-file=numeric.c
1504
+ # - self / other -> numeric
1505
+ # -->
1506
+ # Returns a new Float which is the result of dividing `self` by `other`:
1507
+ #
1508
+ # f = 3.14
1509
+ # f / 2 # => 1.57
1510
+ # f / 2.0 # => 1.57
1511
+ # f / Rational(2, 1) # => 1.57
1512
+ # f / Complex(2, 0) # => (1.57+0.0i)
1513
+ #
1514
+ def /: (BigDecimal) -> BigDecimal
1515
+ | ...
1516
+
1517
+ # <!--
1518
+ # rdoc-file=numeric.c
1519
+ # - self * other -> numeric
1520
+ # -->
1521
+ # Returns a new Float which is the product of `self` and `other`:
1522
+ #
1523
+ # f = 3.14
1524
+ # f * 2 # => 6.28
1525
+ # f * 2.0 # => 6.28
1526
+ # f * Rational(1, 2) # => 1.57
1527
+ # f * Complex(2, 0) # => (6.28+0.0i)
1528
+ #
1529
+ def *: (BigDecimal) -> BigDecimal
1530
+ | ...
1531
+
1532
+ # <!--
1533
+ # rdoc-file=numeric.c
1534
+ # - self + other -> numeric
1535
+ # -->
1536
+ # Returns a new Float which is the sum of `self` and `other`:
1537
+ #
1538
+ # f = 3.14
1539
+ # f + 1 # => 4.140000000000001
1540
+ # f + 1.0 # => 4.140000000000001
1541
+ # f + Rational(1, 1) # => 4.140000000000001
1542
+ # f + Complex(1, 0) # => (4.140000000000001+0i)
1543
+ #
1544
+ def +: (BigDecimal) -> BigDecimal
1545
+ | ...
1546
+
1547
+ # <!--
1548
+ # rdoc-file=numeric.c
1549
+ # - self - other -> numeric
1550
+ # -->
1551
+ # Returns a new Float which is the difference of `self` and `other`:
1552
+ #
1553
+ # f = 3.14
1554
+ # f - 1 # => 2.14
1555
+ # f - 1.0 # => 2.14
1556
+ # f - Rational(1, 1) # => 2.14
1557
+ # f - Complex(1, 0) # => (2.14+0i)
1558
+ #
1559
+ def -: (BigDecimal) -> BigDecimal
1560
+ | ...
1433
1561
  end
1434
1562
 
1435
1563
  %a{annotate:rdoc:skip}
@@ -1472,6 +1600,67 @@ class Rational
1472
1600
  # See also BigDecimal::new.
1473
1601
  #
1474
1602
  def to_d: (Integer precision) -> BigDecimal
1603
+
1604
+ # <!--
1605
+ # rdoc-file=rational.c
1606
+ # - rat / numeric -> numeric
1607
+ # - rat.quo(numeric) -> numeric
1608
+ # -->
1609
+ # Performs division.
1610
+ #
1611
+ # Rational(2, 3) / Rational(2, 3) #=> (1/1)
1612
+ # Rational(900) / Rational(1) #=> (900/1)
1613
+ # Rational(-2, 9) / Rational(-9, 2) #=> (4/81)
1614
+ # Rational(9, 8) / 4 #=> (9/32)
1615
+ # Rational(20, 9) / 9.8 #=> 0.22675736961451246
1616
+ #
1617
+ def /: (BigDecimal) -> BigDecimal
1618
+ | ...
1619
+
1620
+ # <!--
1621
+ # rdoc-file=rational.c
1622
+ # - rat * numeric -> numeric
1623
+ # -->
1624
+ # Performs multiplication.
1625
+ #
1626
+ # Rational(2, 3) * Rational(2, 3) #=> (4/9)
1627
+ # Rational(900) * Rational(1) #=> (900/1)
1628
+ # Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
1629
+ # Rational(9, 8) * 4 #=> (9/2)
1630
+ # Rational(20, 9) * 9.8 #=> 21.77777777777778
1631
+ #
1632
+ def *: (BigDecimal) -> BigDecimal
1633
+ | ...
1634
+
1635
+ # <!--
1636
+ # rdoc-file=rational.c
1637
+ # - rat + numeric -> numeric
1638
+ # -->
1639
+ # Performs addition.
1640
+ #
1641
+ # Rational(2, 3) + Rational(2, 3) #=> (4/3)
1642
+ # Rational(900) + Rational(1) #=> (901/1)
1643
+ # Rational(-2, 9) + Rational(-9, 2) #=> (-85/18)
1644
+ # Rational(9, 8) + 4 #=> (41/8)
1645
+ # Rational(20, 9) + 9.8 #=> 12.022222222222222
1646
+ #
1647
+ def +: (BigDecimal) -> BigDecimal
1648
+ | ...
1649
+
1650
+ # <!--
1651
+ # rdoc-file=rational.c
1652
+ # - rat - numeric -> numeric
1653
+ # -->
1654
+ # Performs subtraction.
1655
+ #
1656
+ # Rational(2, 3) - Rational(2, 3) #=> (0/1)
1657
+ # Rational(900) - Rational(1) #=> (899/1)
1658
+ # Rational(-2, 9) - Rational(-9, 2) #=> (77/18)
1659
+ # Rational(9, 8) - 4 #=> (-23/8)
1660
+ # Rational(20, 9) - 9.8 #=> -7.577777777777778
1661
+ #
1662
+ def -: (BigDecimal) -> BigDecimal
1663
+ | ...
1475
1664
  end
1476
1665
 
1477
1666
  %a{annotate:rdoc:skip}
@@ -1496,6 +1685,67 @@ class Complex
1496
1685
  # See also BigDecimal::new.
1497
1686
  #
1498
1687
  def to_d: (*untyped args) -> BigDecimal
1688
+
1689
+ # <!--
1690
+ # rdoc-file=complex.c
1691
+ # - cmp / numeric -> complex
1692
+ # - cmp.quo(numeric) -> complex
1693
+ # -->
1694
+ # Performs division.
1695
+ #
1696
+ # Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i)
1697
+ # Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i)
1698
+ # Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i)
1699
+ # Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i)
1700
+ # Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i)
1701
+ #
1702
+ def /: (BigDecimal) -> Complex
1703
+ | ...
1704
+
1705
+ # <!--
1706
+ # rdoc-file=complex.c
1707
+ # - cmp * numeric -> complex
1708
+ # -->
1709
+ # Performs multiplication.
1710
+ #
1711
+ # Complex(2, 3) * Complex(2, 3) #=> (-5+12i)
1712
+ # Complex(900) * Complex(1) #=> (900+0i)
1713
+ # Complex(-2, 9) * Complex(-9, 2) #=> (0-85i)
1714
+ # Complex(9, 8) * 4 #=> (36+32i)
1715
+ # Complex(20, 9) * 9.8 #=> (196.0+88.2i)
1716
+ #
1717
+ def *: (BigDecimal) -> Complex
1718
+ | ...
1719
+
1720
+ # <!--
1721
+ # rdoc-file=complex.c
1722
+ # - cmp + numeric -> complex
1723
+ # -->
1724
+ # Performs addition.
1725
+ #
1726
+ # Complex(2, 3) + Complex(2, 3) #=> (4+6i)
1727
+ # Complex(900) + Complex(1) #=> (901+0i)
1728
+ # Complex(-2, 9) + Complex(-9, 2) #=> (-11+11i)
1729
+ # Complex(9, 8) + 4 #=> (13+8i)
1730
+ # Complex(20, 9) + 9.8 #=> (29.8+9i)
1731
+ #
1732
+ def +: (BigDecimal) -> Complex
1733
+ | ...
1734
+
1735
+ # <!--
1736
+ # rdoc-file=complex.c
1737
+ # - cmp - numeric -> complex
1738
+ # -->
1739
+ # Performs subtraction.
1740
+ #
1741
+ # Complex(2, 3) - Complex(2, 3) #=> (0+0i)
1742
+ # Complex(900) - Complex(1) #=> (899+0i)
1743
+ # Complex(-2, 9) - Complex(-9, 2) #=> (7+7i)
1744
+ # Complex(9, 8) - 4 #=> (5+8i)
1745
+ # Complex(20, 9) - 9.8 #=> (10.2+9i)
1746
+ #
1747
+ def -: (BigDecimal) -> Complex
1748
+ | ...
1499
1749
  end
1500
1750
 
1501
1751
  %a{annotate:rdoc:skip}
data/stdlib/erb/0/erb.rbs CHANGED
@@ -446,4 +446,111 @@ class ERB
446
446
  # print MyClass.new('foo', 123).render()
447
447
  #
448
448
  def def_class: (?Class, ?String) -> Class
449
+
450
+ # <!-- rdoc-file=lib/erb.rb -->
451
+ # A utility module for conversion routines, often handy in HTML generation.
452
+ #
453
+ module Util
454
+ # <!--
455
+ # rdoc-file=lib/erb.rb
456
+ # - html_escape(s)
457
+ # -->
458
+ # A utility method for escaping HTML tag characters in *s*.
459
+ #
460
+ # require "erb"
461
+ # include ERB::Util
462
+ #
463
+ # puts html_escape("is a > 0 & a < 10?")
464
+ #
465
+ # *Generates*
466
+ #
467
+ # is a &gt; 0 &amp; a &lt; 10?
468
+ #
469
+ def self?.html_escape: (String str) -> String
470
+
471
+ # <!--
472
+ # rdoc-file=lib/erb.rb
473
+ # - h(s)
474
+ # -->
475
+ #
476
+ alias h html_escape
477
+
478
+ # <!--
479
+ # rdoc-file=lib/erb.rb
480
+ # - h(s)
481
+ # -->
482
+ #
483
+ alias self.h self.html_escape
484
+
485
+ # <!--
486
+ # rdoc-file=lib/erb.rb
487
+ # - url_encode(s)
488
+ # -->
489
+ # A utility method for encoding the String *s* as a URL.
490
+ #
491
+ # require "erb"
492
+ # include ERB::Util
493
+ #
494
+ # puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
495
+ #
496
+ # *Generates*
497
+ #
498
+ # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
499
+ #
500
+ def self?.url_encode: (String) -> String
501
+
502
+ # <!--
503
+ # rdoc-file=lib/erb.rb
504
+ # - u(s)
505
+ # -->
506
+ #
507
+ alias u url_encode
508
+
509
+ # <!--
510
+ # rdoc-file=lib/erb.rb
511
+ # - u(s)
512
+ # -->
513
+ #
514
+ alias self.u self.url_encode
515
+ end
516
+
517
+ # <!-- rdoc-file=lib/erb.rb -->
518
+ # Utility module to define eRuby script as instance method.
519
+ #
520
+ # ### Example
521
+ #
522
+ # example.rhtml:
523
+ # <% for item in @items %>
524
+ # <b><%= item %></b>
525
+ # <% end %>
526
+ #
527
+ # example.rb:
528
+ # require 'erb'
529
+ # class MyClass
530
+ # extend ERB::DefMethod
531
+ # def_erb_method('render()', 'example.rhtml')
532
+ # def initialize(items)
533
+ # @items = items
534
+ # end
535
+ # end
536
+ # print MyClass.new([10,20,30]).render()
537
+ #
538
+ # result:
539
+ #
540
+ # <b>10</b>
541
+ #
542
+ # <b>20</b>
543
+ #
544
+ # <b>30</b>
545
+ #
546
+ module DefMethod
547
+ # <!--
548
+ # rdoc-file=lib/erb.rb
549
+ # - def_erb_method(methodname, erb_or_fname)
550
+ # -->
551
+ # define *methodname* as instance method of current module, using ERB object or
552
+ # eRuby file
553
+ #
554
+ def self.def_erb_method: (String methodname, (String | ERB) erb_or_fname) -> untyped
555
+ end
449
556
  end
@@ -500,7 +500,7 @@ class Logger
500
500
  # `severity`
501
501
  # : The Severity of the log message.
502
502
  #
503
- def level=: (Integer | String severity) -> Integer
503
+ def level=: (Integer | String | Symbol severity) -> Integer
504
504
 
505
505
  # <!--
506
506
  # rdoc-file=lib/logger.rb
@@ -646,7 +646,7 @@ class Logger
646
646
  #
647
647
  # Create an instance.
648
648
  #
649
- def initialize: (logdev logdev, ?Numeric | String shift_age, ?Integer shift_size, ?shift_period_suffix: String, ?binmode: boolish, ?datetime_format: String, ?formatter: _Formatter, ?progname: String, ?level: Integer) -> void
649
+ def initialize: (logdev logdev, ?Numeric | String shift_age, ?Integer shift_size, ?shift_period_suffix: String, ?binmode: boolish, ?datetime_format: String, ?formatter: _Formatter, ?progname: String, ?level: Integer | String | Symbol) -> void
650
650
  end
651
651
 
652
652
  Logger::ProgName: String