yard2steep 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/example/sample1/lib/example1.rb +15 -2
- data/example/sample1/sig/example1.rbi +6 -2
- data/lib/yard2steep/ast/class_node.rb +18 -5
- data/lib/yard2steep/gen.rb +1 -1
- data/lib/yard2steep/parser.rb +16 -65
- data/lib/yard2steep/type/ast.rb +52 -0
- data/lib/yard2steep/type/parser.rb +145 -0
- data/lib/yard2steep/type.rb +41 -0
- data/lib/yard2steep/version.rb +1 -1
- data/sig/steep-scaffold/td.rbi +58 -5
- data/sig/yard2steep/yard2steep/ast/class_node.rbi +4 -1
- data/sig/yard2steep/yard2steep/parser.rbi +0 -4
- data/sig/yard2steep/yard2steep/type/ast.rbi +18 -0
- data/sig/yard2steep/yard2steep/type/parser.rbi +14 -0
- data/sig/yard2steep/yard2steep/type.rbi +8 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd410ad306476662e4768508ddb91363d6881d8714b83588f890b871571e8c2
|
4
|
+
data.tar.gz: a4ea944e7ec8b0ddaec01dfadce13cf85ad934ee1612aeff4ca00b045396f57e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca073d5d4eba5d8caad1d94877b9d7800cd1ec10306f2f02e8bc36cd37695e70a5e571c30aafeec27f0e42842e25ac34e46d1115f0534a39c846085612d97e1e
|
7
|
+
data.tar.gz: 470f49608f90134ce4cddee5e9a905371347ae3ad8eb49b245a2d8fab83b8be8b5d9d82fb813cf2389c49fdfecbb6c23f9f32b9ac2973bcd46010ba0a410ec7e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Generate [steep](https://github.com/soutaro/steep) type definition file from yard annotation.
|
4
4
|
|
5
|
-
:warning: **This is highly experimental project. Current version is 0.1.
|
5
|
+
:warning: **This is highly experimental project. Current version is 0.1.1.**
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -12,6 +12,11 @@ end
|
|
12
12
|
# NOTE: this is wrong comment. so should ignore it
|
13
13
|
# @param [Array] contents
|
14
14
|
|
15
|
+
class SomeClass
|
16
|
+
# @dynamic index
|
17
|
+
attr_reader :index
|
18
|
+
end
|
19
|
+
|
15
20
|
class MyClass
|
16
21
|
# NOTE: method definition in singleton class should be ignored
|
17
22
|
class << self
|
@@ -24,8 +29,6 @@ class MyClass
|
|
24
29
|
|
25
30
|
CONSTANT = "This is constant".freeze
|
26
31
|
|
27
|
-
attr_reader :index
|
28
|
-
|
29
32
|
# This for should not be used.
|
30
33
|
# @return [String]
|
31
34
|
def self.name
|
@@ -42,6 +45,11 @@ class MyClass
|
|
42
45
|
[:ok, :no]
|
43
46
|
end
|
44
47
|
|
48
|
+
# @return [Array<Array<Symbol>>]
|
49
|
+
def nest
|
50
|
+
[[:o]]
|
51
|
+
end
|
52
|
+
|
45
53
|
# @return [Array(Symbol, Integer)]
|
46
54
|
def type
|
47
55
|
[:number, 1]
|
@@ -58,6 +66,11 @@ class MyClass
|
|
58
66
|
{ ok: 3, no: nil }
|
59
67
|
end
|
60
68
|
|
69
|
+
# @return [Hash{ Symbol => Array<Integer> }]
|
70
|
+
def nest_hash
|
71
|
+
{ ok: [1, 2] }
|
72
|
+
end
|
73
|
+
|
61
74
|
# @param [Array<Integer>] contents
|
62
75
|
# @param [Symbol] order
|
63
76
|
# @return [Array<Integer>]
|
@@ -1,12 +1,16 @@
|
|
1
|
-
class
|
1
|
+
class SomeClass
|
2
2
|
@index: any
|
3
3
|
def index: -> any
|
4
|
+
end
|
5
|
+
class MyClass
|
4
6
|
def self.name: -> String
|
5
7
|
def name: -> String
|
6
8
|
def pair: -> Array<Symbol>
|
9
|
+
def nest: -> Array<Array<Symbol>>
|
7
10
|
def type: -> Array<Symbol | Integer>
|
8
11
|
def opts: -> Hash<any, any>
|
9
12
|
def values: (?off: Integer) -> Hash<Symbol, Integer | nil>
|
13
|
+
def nest_hash: -> Hash<Symbol, Array<Integer>>
|
10
14
|
def reverse: (Array<Integer>, order: Symbol) -> Array<Integer>
|
11
15
|
def first!: (any) -> any
|
12
16
|
def present?: (any) -> any
|
@@ -16,6 +20,6 @@ MyClass::CONSTANT: any
|
|
16
20
|
module MyClass::InnerClass
|
17
21
|
def double: (source: Integer) -> Integer
|
18
22
|
end
|
19
|
-
class OtherClass
|
23
|
+
class OtherClass <: MyClass
|
20
24
|
def yes: -> any
|
21
25
|
end
|
@@ -7,19 +7,21 @@ module Yard2steep
|
|
7
7
|
AST::ClassNode.new(
|
8
8
|
kind: 'module',
|
9
9
|
c_name: 'main',
|
10
|
-
|
10
|
+
super_c: nil,
|
11
|
+
parent: nil,
|
11
12
|
)
|
12
13
|
end
|
13
14
|
|
14
|
-
# @dynamic kind, c_name, c_list, m_list, ivar_list, children, parent
|
15
|
-
attr_reader :kind, :c_name, :c_list, :m_list, :ivar_list, :children, :parent
|
15
|
+
# @dynamic kind, c_name, super_c, c_list, m_list, ivar_list, children, parent
|
16
|
+
attr_reader :kind, :c_name, :super_c, :c_list, :m_list, :ivar_list, :children, :parent
|
16
17
|
|
17
18
|
KIND = ['class', 'module']
|
18
19
|
|
19
20
|
# @param [String] kind
|
20
21
|
# @param [String] c_name
|
21
|
-
# @param [AST::ClassNode
|
22
|
-
|
22
|
+
# @param [AST::ClassNode, nil] parent
|
23
|
+
# @param [String, nil] super_c
|
24
|
+
def initialize(kind:, c_name:, super_c:, parent:)
|
23
25
|
Util.assert! { KIND.include?(kind) }
|
24
26
|
Util.assert! { c_name.is_a?(String) }
|
25
27
|
Util.assert! {
|
@@ -28,6 +30,7 @@ module Yard2steep
|
|
28
30
|
}
|
29
31
|
@kind = kind
|
30
32
|
@c_name = c_name
|
33
|
+
@super_c = super_c
|
31
34
|
@c_list = [] # list of constants
|
32
35
|
@m_list = [] # list of methods
|
33
36
|
@ivar_list = [] # list of instance variables
|
@@ -73,6 +76,16 @@ module Yard2steep
|
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
79
|
+
def long_super
|
80
|
+
@long_super ||= begin
|
81
|
+
if @parent.c_name == 'main'
|
82
|
+
@super_c
|
83
|
+
else
|
84
|
+
"#{@parent.long_name}::#{@super_c}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
76
89
|
# @return [String]
|
77
90
|
def to_s
|
78
91
|
inspect
|
data/lib/yard2steep/gen.rb
CHANGED
@@ -40,7 +40,7 @@ module Yard2steep
|
|
40
40
|
gen_children!(c_node, off: 0)
|
41
41
|
else
|
42
42
|
if (c_node.m_list.size > 0) || (c_node.ivar_list.size > 0)
|
43
|
-
emit! "#{c_node.kind} #{c_node.long_name}\n", off: off
|
43
|
+
emit! "#{c_node.kind} #{c_node.long_name}#{c_node.super_c ? " <: #{c_node.long_super}" : nil}\n", off: off
|
44
44
|
gen_ivar_list!(c_node, off: off + 2)
|
45
45
|
gen_m_list!(c_node, off: off + 2)
|
46
46
|
emit! "end\n", off: off
|
data/lib/yard2steep/parser.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'yard2steep/ast'
|
2
|
+
require 'yard2steep/type'
|
2
3
|
|
3
4
|
module Yard2steep
|
4
5
|
class Parser
|
@@ -12,7 +13,7 @@ module Yard2steep
|
|
12
13
|
(class)
|
13
14
|
#{S_P_RE}
|
14
15
|
(\w+)
|
15
|
-
(
|
16
|
+
(
|
16
17
|
#{S_P_RE}
|
17
18
|
<
|
18
19
|
#{S_P_RE}
|
@@ -60,7 +61,14 @@ module Yard2steep
|
|
60
61
|
$/x
|
61
62
|
|
62
63
|
COMMENT_RE = /#{PRE_RE}#/
|
63
|
-
TYPE_WITH_PAREN_RE =
|
64
|
+
TYPE_WITH_PAREN_RE = /
|
65
|
+
\[
|
66
|
+
(
|
67
|
+
[^\]]
|
68
|
+
*
|
69
|
+
)
|
70
|
+
\]
|
71
|
+
/x
|
64
72
|
|
65
73
|
PARAM_RE = /
|
66
74
|
#{COMMENT_RE}
|
@@ -280,9 +288,10 @@ module Yard2steep
|
|
280
288
|
reset_method_context!
|
281
289
|
|
282
290
|
c = AST::ClassNode.new(
|
283
|
-
kind:
|
284
|
-
c_name:
|
285
|
-
|
291
|
+
kind: m[1],
|
292
|
+
c_name: m[2],
|
293
|
+
super_c: m[3] && m[3].gsub('<', '').strip,
|
294
|
+
parent: @current_class,
|
286
295
|
)
|
287
296
|
@current_class.append_child(c)
|
288
297
|
@current_class = c
|
@@ -516,69 +525,11 @@ module Yard2steep
|
|
516
525
|
print "#{' ' * (@stack.size * 2 + offset)}#{message}\n" if @debug
|
517
526
|
end
|
518
527
|
|
519
|
-
ARRAY_TYPE_RE = /^
|
520
|
-
Array
|
521
|
-
#{S_RE}
|
522
|
-
<
|
523
|
-
([^>]+)
|
524
|
-
>
|
525
|
-
#{S_RE}
|
526
|
-
$/x
|
527
|
-
FIXED_ARRAY_TYPE_RE = /^
|
528
|
-
Array
|
529
|
-
#{S_RE}
|
530
|
-
\(
|
531
|
-
([^)]+)
|
532
|
-
\)
|
533
|
-
#{S_RE}
|
534
|
-
$/x
|
535
|
-
HASH_TYPE_RE = /^
|
536
|
-
Hash
|
537
|
-
#{S_RE}
|
538
|
-
\{
|
539
|
-
#{S_RE}
|
540
|
-
([^=]+)
|
541
|
-
#{S_RE}
|
542
|
-
=>
|
543
|
-
#{S_RE}
|
544
|
-
([^}]+)
|
545
|
-
#{S_RE}
|
546
|
-
\}
|
547
|
-
#{S_RE}
|
548
|
-
$/x
|
549
|
-
|
550
|
-
# NOTE: normalize type to steep representation
|
551
|
-
#
|
552
528
|
# @param [String] type
|
553
529
|
# @return [String]
|
554
530
|
def normalize_type(type)
|
555
|
-
|
556
|
-
|
557
|
-
'Array<any>'.freeze
|
558
|
-
elsif (m = ARRAY_TYPE_RE.match(type))
|
559
|
-
"Array<#{normalize_multi_type(m[1])}>"
|
560
|
-
elsif (m = FIXED_ARRAY_TYPE_RE.match(type))
|
561
|
-
"Array<#{normalize_multi_type(m[1])}>"
|
562
|
-
else
|
563
|
-
raise "invalid Array type: #{type}"
|
564
|
-
end
|
565
|
-
elsif type[0..3] == 'Hash'.freeze
|
566
|
-
if type == 'Hash'.freeze
|
567
|
-
'Hash<any, any>'.freeze
|
568
|
-
elsif (m = HASH_TYPE_RE.match(type))
|
569
|
-
"Hash<#{normalize_multi_type(m[1])}, #{normalize_multi_type(m[2])}>"
|
570
|
-
else
|
571
|
-
raise "invalid Hash type: #{type}"
|
572
|
-
end
|
573
|
-
else
|
574
|
-
normalize_multi_type(type)
|
575
|
-
end
|
576
|
-
end
|
577
|
-
|
578
|
-
# @param [String] type_s
|
579
|
-
# @return [String]
|
580
|
-
def normalize_multi_type(type_s)
|
581
|
-
type_s.split(',').map { |s| s.strip }.uniq.join(' | ')
|
531
|
+
debug_print! type
|
532
|
+
Type.translate(type)
|
582
533
|
end
|
583
534
|
end
|
584
535
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Yard2steep
|
2
|
+
class Type
|
3
|
+
class TypeBase
|
4
|
+
# @param [Array<TypeBase>] types
|
5
|
+
# @return [String]
|
6
|
+
def self.union2s(types)
|
7
|
+
types.map { |t| t.to_s }.uniq.join(' | ')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class AnyType < TypeBase
|
12
|
+
def to_s
|
13
|
+
'any'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class NormalType < TypeBase
|
18
|
+
# @param [String] type
|
19
|
+
def initialize(type:)
|
20
|
+
@type = type
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
@type
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class ArrayType < TypeBase
|
29
|
+
# @param [Array<TypeBase>] type
|
30
|
+
def initialize(type:)
|
31
|
+
@type = type
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
"Array<#{TypeBase.union2s(@type)}>"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class HashType < TypeBase
|
40
|
+
# @param [Array<TypeBase>] key
|
41
|
+
# @param [Array<TypeBase>] val
|
42
|
+
def initialize(key:, val:)
|
43
|
+
@key = key
|
44
|
+
@val = val
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
"Hash<#{TypeBase.union2s(@key)}, #{TypeBase.union2s(@val)}>"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
module Yard2steep
|
2
|
+
class Type
|
3
|
+
class Parser
|
4
|
+
# @param [Array<String>]
|
5
|
+
# @return [Array<TypeBase>]
|
6
|
+
def self.parse(tokens)
|
7
|
+
Parser.new(tokens).parse
|
8
|
+
end
|
9
|
+
|
10
|
+
# @param [Array<String>]
|
11
|
+
def initialize(tokens)
|
12
|
+
@tokens = tokens
|
13
|
+
@types = []
|
14
|
+
end
|
15
|
+
|
16
|
+
# @reutrn [Array<TypeBase>]
|
17
|
+
def parse
|
18
|
+
debug_print!(@tokens)
|
19
|
+
|
20
|
+
return [] if (@tokens.size == 0)
|
21
|
+
|
22
|
+
@types.push(parse_type)
|
23
|
+
while @tokens.size > 0
|
24
|
+
expect!(',')
|
25
|
+
@types.push(parse_type)
|
26
|
+
end
|
27
|
+
|
28
|
+
@types
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @return [TypeBase]
|
34
|
+
def parse_type
|
35
|
+
t = get
|
36
|
+
Util.assert! { t }
|
37
|
+
|
38
|
+
case t
|
39
|
+
when 'Array'
|
40
|
+
r = parse_array
|
41
|
+
when 'Hash'
|
42
|
+
r = parse_hash
|
43
|
+
else
|
44
|
+
r = parse_normal_type(t)
|
45
|
+
end
|
46
|
+
|
47
|
+
debug_print! "type: #{r}\n"
|
48
|
+
debug_print! "peek: #{peek}\n"
|
49
|
+
|
50
|
+
r
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param [String] t
|
54
|
+
# @return [NormalType]
|
55
|
+
def parse_normal_type(t)
|
56
|
+
NormalType.new(type: t)
|
57
|
+
end
|
58
|
+
|
59
|
+
# @param [String] term_s
|
60
|
+
# @return [Array<TypeBase>]
|
61
|
+
def parse_multiple_types(term_s)
|
62
|
+
t = peek
|
63
|
+
if t == term_s
|
64
|
+
expect!(term_s)
|
65
|
+
return []
|
66
|
+
end
|
67
|
+
|
68
|
+
r = []
|
69
|
+
r.push(parse_type)
|
70
|
+
|
71
|
+
while t = peek
|
72
|
+
break if t != ','
|
73
|
+
expect!(',')
|
74
|
+
r.push(parse_type)
|
75
|
+
end
|
76
|
+
|
77
|
+
debug_print! "term_s: #{term_s}\n"
|
78
|
+
expect!(term_s)
|
79
|
+
|
80
|
+
r
|
81
|
+
end
|
82
|
+
|
83
|
+
# @return [ArrayType]
|
84
|
+
def parse_array
|
85
|
+
case peek
|
86
|
+
when '<'
|
87
|
+
expect!('<')
|
88
|
+
ArrayType.new(
|
89
|
+
type: parse_multiple_types('>')
|
90
|
+
)
|
91
|
+
when '('
|
92
|
+
expect!('(')
|
93
|
+
ArrayType.new(
|
94
|
+
type: parse_multiple_types(')')
|
95
|
+
)
|
96
|
+
else
|
97
|
+
ArrayType.new(
|
98
|
+
type: [AnyType.new]
|
99
|
+
)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def parse_hash
|
104
|
+
debug_print!("parse_hash, peek: #{peek}")
|
105
|
+
|
106
|
+
case peek
|
107
|
+
when '{'
|
108
|
+
expect!('{')
|
109
|
+
key = parse_multiple_types('=')
|
110
|
+
expect!('>')
|
111
|
+
val = parse_multiple_types('}')
|
112
|
+
HashType.new(
|
113
|
+
key: key,
|
114
|
+
val: val,
|
115
|
+
)
|
116
|
+
else
|
117
|
+
HashType.new(
|
118
|
+
key: [AnyType.new],
|
119
|
+
val: [AnyType.new],
|
120
|
+
)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# @param [String] token
|
125
|
+
def expect!(token)
|
126
|
+
t = get
|
127
|
+
Util.assert! { t == token }
|
128
|
+
end
|
129
|
+
|
130
|
+
def get
|
131
|
+
@tokens.shift
|
132
|
+
end
|
133
|
+
|
134
|
+
def peek
|
135
|
+
@tokens[0]
|
136
|
+
end
|
137
|
+
|
138
|
+
# @param [String] message
|
139
|
+
def debug_print!(message)
|
140
|
+
# TODO(south37) Add flag
|
141
|
+
# print message
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
require 'yard2steep/type/ast'
|
3
|
+
require 'yard2steep/type/parser'
|
4
|
+
|
5
|
+
module Yard2steep
|
6
|
+
class Type
|
7
|
+
# @param [Strng]
|
8
|
+
# @return [String]
|
9
|
+
def self.translate(text)
|
10
|
+
Type.new(text).translate
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param [String] text
|
14
|
+
def initialize(text)
|
15
|
+
@text = text
|
16
|
+
end
|
17
|
+
|
18
|
+
def translate
|
19
|
+
tokens = tokens(@text)
|
20
|
+
ast = Parser.parse(tokens)
|
21
|
+
TypeBase.union2s(ast)
|
22
|
+
end
|
23
|
+
|
24
|
+
S_RE = /[\s\t]*/
|
25
|
+
TOKENS = /
|
26
|
+
[<>(),|={}]|[\w:]+
|
27
|
+
/x
|
28
|
+
|
29
|
+
# @param [String] str
|
30
|
+
# @return [Array<String>]
|
31
|
+
def tokens(str)
|
32
|
+
r = []
|
33
|
+
s = StringScanner.new(str)
|
34
|
+
while !s.eos?
|
35
|
+
s.scan(S_RE)
|
36
|
+
r.push(s.scan(TOKENS))
|
37
|
+
end
|
38
|
+
r
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/yard2steep/version.rb
CHANGED
data/sig/steep-scaffold/td.rbi
CHANGED
@@ -35,7 +35,6 @@ class Yard2steep::Parser
|
|
35
35
|
def type_node: (any) -> any
|
36
36
|
def debug_print!: (any, ?offset: Integer) -> void
|
37
37
|
def normalize_type: (any) -> any
|
38
|
-
def normalize_multi_type: (any) -> any
|
39
38
|
end
|
40
39
|
|
41
40
|
Yard2steep::Parser::S_RE: Regexp
|
@@ -60,9 +59,6 @@ Yard2steep::Parser::ATTR_RE: Regexp
|
|
60
59
|
Yard2steep::Parser::STATES: Hash<any, any>
|
61
60
|
Yard2steep::Parser::ANY_TYPE: String
|
62
61
|
Yard2steep::Parser::ANY_BLOCK_TYPE: String
|
63
|
-
Yard2steep::Parser::ARRAY_TYPE_RE: Regexp
|
64
|
-
Yard2steep::Parser::FIXED_ARRAY_TYPE_RE: Regexp
|
65
|
-
Yard2steep::Parser::HASH_TYPE_RE: Regexp
|
66
62
|
class Yard2steep::CLI
|
67
63
|
@option: any
|
68
64
|
@src_dir: any
|
@@ -89,6 +85,60 @@ class Yard2steep::Engine
|
|
89
85
|
def self.execute: (any, any, ?debug: bool, ?debug_ast: bool) -> any
|
90
86
|
end
|
91
87
|
|
88
|
+
class Yard2steep::Type::TypeBase
|
89
|
+
def self.union2s: (any) -> any
|
90
|
+
end
|
91
|
+
|
92
|
+
class Yard2steep::Type::AnyType
|
93
|
+
def to_s: () -> String
|
94
|
+
end
|
95
|
+
|
96
|
+
class Yard2steep::Type::NormalType
|
97
|
+
@type: any
|
98
|
+
def initialize: (type: any) -> any
|
99
|
+
def to_s: () -> any
|
100
|
+
end
|
101
|
+
|
102
|
+
class Yard2steep::Type::ArrayType
|
103
|
+
@type: any
|
104
|
+
def initialize: (type: any) -> any
|
105
|
+
def to_s: () -> String
|
106
|
+
end
|
107
|
+
|
108
|
+
class Yard2steep::Type::HashType
|
109
|
+
@key: any
|
110
|
+
@val: any
|
111
|
+
def initialize: (key: any, val: any) -> any
|
112
|
+
def to_s: () -> String
|
113
|
+
end
|
114
|
+
|
115
|
+
class Yard2steep::Type::Parser
|
116
|
+
@tokens: any
|
117
|
+
@types: any
|
118
|
+
def initialize: (any) -> Array<any>
|
119
|
+
def parse: () -> any
|
120
|
+
def parse_type: () -> any
|
121
|
+
def parse_normal_type: (any) -> any
|
122
|
+
def parse_multiple_types: (any) -> any
|
123
|
+
def parse_array: () -> any
|
124
|
+
def parse_hash: () -> any
|
125
|
+
def expect!: (any) -> any
|
126
|
+
def get: () -> any
|
127
|
+
def peek: () -> any
|
128
|
+
def debug_print!: (any) -> any
|
129
|
+
def self.parse: (any) -> any
|
130
|
+
end
|
131
|
+
|
132
|
+
class Yard2steep::Type
|
133
|
+
@text: any
|
134
|
+
def initialize: (any) -> any
|
135
|
+
def translate: () -> any
|
136
|
+
def tokens: (any) -> any
|
137
|
+
def self.translate: (any) -> any
|
138
|
+
end
|
139
|
+
|
140
|
+
Yard2steep::Type::S_RE: Regexp
|
141
|
+
Yard2steep::Type::TOKENS: Regexp
|
92
142
|
module Yard2steep::Util
|
93
143
|
def self.assert!: { () -> any } -> void
|
94
144
|
end
|
@@ -106,18 +156,21 @@ end
|
|
106
156
|
class Yard2steep::AST::ClassNode
|
107
157
|
@kind: any
|
108
158
|
@c_name: any
|
159
|
+
@super_c: any
|
109
160
|
@c_list: any
|
110
161
|
@m_list: any
|
111
162
|
@ivar_list: any
|
112
163
|
@children: any
|
113
164
|
@parent: any
|
114
165
|
@long_name: any
|
115
|
-
|
166
|
+
@long_super: any
|
167
|
+
def initialize: (kind: any, c_name: any, super_c: any, parent: any) -> any
|
116
168
|
def append_constant: (any) -> any
|
117
169
|
def append_m: (any) -> any
|
118
170
|
def append_ivar: (any) -> any
|
119
171
|
def append_child: (any) -> any
|
120
172
|
def long_name: () -> any
|
173
|
+
def long_super: () -> any
|
121
174
|
def to_s: () -> any
|
122
175
|
def inspect: () -> String
|
123
176
|
def self.create_main: () -> any
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class Yard2steep::AST::ClassNode
|
2
2
|
@kind: any
|
3
3
|
@c_name: any
|
4
|
+
@super_c: any
|
4
5
|
@c_list: any
|
5
6
|
@m_list: any
|
6
7
|
@ivar_list: any
|
@@ -9,17 +10,19 @@ class Yard2steep::AST::ClassNode
|
|
9
10
|
def self.create_main: -> AST::ClassNode
|
10
11
|
def kind: -> any
|
11
12
|
def c_name: -> any
|
13
|
+
def super_c: -> any
|
12
14
|
def c_list: -> any
|
13
15
|
def m_list: -> any
|
14
16
|
def ivar_list: -> any
|
15
17
|
def children: -> any
|
16
18
|
def parent: -> any
|
17
|
-
def initialize: (kind: String, c_name: String, parent: AST::ClassNode | nil) -> any
|
19
|
+
def initialize: (kind: String, c_name: String, super_c: String | nil, parent: AST::ClassNode | nil) -> any
|
18
20
|
def append_constant: (AST::ConstantNode) -> void
|
19
21
|
def append_m: (AST::MethodNode) -> void
|
20
22
|
def append_ivar: (AST::IVarNode) -> void
|
21
23
|
def append_child: (AST::ClassNode) -> void
|
22
24
|
def long_name: -> String
|
25
|
+
def long_super: -> any
|
23
26
|
def to_s: -> String
|
24
27
|
def inspect: -> String
|
25
28
|
end
|
@@ -23,7 +23,6 @@ class Yard2steep::Parser
|
|
23
23
|
def type_node: (String) -> AST::PTypeNode
|
24
24
|
def debug_print!: (String, ?offset: Integer) -> void
|
25
25
|
def normalize_type: (String) -> String
|
26
|
-
def normalize_multi_type: (String) -> String
|
27
26
|
end
|
28
27
|
Yard2steep::Parser::S_RE: any
|
29
28
|
Yard2steep::Parser::S_P_RE: any
|
@@ -47,6 +46,3 @@ Yard2steep::Parser::ATTR_RE: any
|
|
47
46
|
Yard2steep::Parser::STATES: any
|
48
47
|
Yard2steep::Parser::ANY_TYPE: any
|
49
48
|
Yard2steep::Parser::ANY_BLOCK_TYPE: any
|
50
|
-
Yard2steep::Parser::ARRAY_TYPE_RE: any
|
51
|
-
Yard2steep::Parser::FIXED_ARRAY_TYPE_RE: any
|
52
|
-
Yard2steep::Parser::HASH_TYPE_RE: any
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Yard2steep::Type::TypeBase
|
2
|
+
def self.union2s: (Array<TypeBase>) -> String
|
3
|
+
end
|
4
|
+
class Yard2steep::Type::AnyType <: Yard2steep::Type::TypeBase
|
5
|
+
def to_s: -> any
|
6
|
+
end
|
7
|
+
class Yard2steep::Type::NormalType <: Yard2steep::Type::TypeBase
|
8
|
+
def initialize: (type: String) -> any
|
9
|
+
def to_s: -> any
|
10
|
+
end
|
11
|
+
class Yard2steep::Type::ArrayType <: Yard2steep::Type::TypeBase
|
12
|
+
def initialize: (type: Array<TypeBase>) -> any
|
13
|
+
def to_s: -> any
|
14
|
+
end
|
15
|
+
class Yard2steep::Type::HashType <: Yard2steep::Type::TypeBase
|
16
|
+
def initialize: (key: Array<TypeBase>, val: Array<TypeBase>) -> any
|
17
|
+
def to_s: -> any
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Yard2steep::Type::Parser
|
2
|
+
def self.parse: (any) -> Array<TypeBase>
|
3
|
+
def initialize: (any) -> any
|
4
|
+
def parse: -> any
|
5
|
+
def parse_type: -> TypeBase
|
6
|
+
def parse_normal_type: (String) -> NormalType
|
7
|
+
def parse_multiple_types: (String) -> Array<TypeBase>
|
8
|
+
def parse_array: -> ArrayType
|
9
|
+
def parse_hash: -> any
|
10
|
+
def expect!: (String) -> any
|
11
|
+
def get: -> any
|
12
|
+
def peek: -> any
|
13
|
+
def debug_print!: (String) -> any
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard2steep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nao Minami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,9 @@ files:
|
|
118
118
|
- lib/yard2steep/engine.rb
|
119
119
|
- lib/yard2steep/gen.rb
|
120
120
|
- lib/yard2steep/parser.rb
|
121
|
+
- lib/yard2steep/type.rb
|
122
|
+
- lib/yard2steep/type/ast.rb
|
123
|
+
- lib/yard2steep/type/parser.rb
|
121
124
|
- lib/yard2steep/util.rb
|
122
125
|
- lib/yard2steep/version.rb
|
123
126
|
- sig/steep-scaffold/td.rbi
|
@@ -134,6 +137,9 @@ files:
|
|
134
137
|
- sig/yard2steep/yard2steep/engine.rbi
|
135
138
|
- sig/yard2steep/yard2steep/gen.rbi
|
136
139
|
- sig/yard2steep/yard2steep/parser.rbi
|
140
|
+
- sig/yard2steep/yard2steep/type.rbi
|
141
|
+
- sig/yard2steep/yard2steep/type/ast.rbi
|
142
|
+
- sig/yard2steep/yard2steep/type/parser.rbi
|
137
143
|
- sig/yard2steep/yard2steep/util.rbi
|
138
144
|
- sig/yard2steep/yard2steep/version.rbi
|
139
145
|
- yard2steep.gemspec
|