rbs-inline 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +109 -0
- data/Rakefile +12 -0
- data/Steepfile +27 -0
- data/exe/rbs-inline +6 -0
- data/lib/rbs/inline/annotation_parser.rb +765 -0
- data/lib/rbs/inline/ast/annotations.rb +454 -0
- data/lib/rbs/inline/ast/comment_lines.rb +42 -0
- data/lib/rbs/inline/ast/declarations.rb +243 -0
- data/lib/rbs/inline/ast/members.rb +599 -0
- data/lib/rbs/inline/ast/tree.rb +141 -0
- data/lib/rbs/inline/cli.rb +106 -0
- data/lib/rbs/inline/node_utils.rb +12 -0
- data/lib/rbs/inline/parser.rb +360 -0
- data/lib/rbs/inline/version.rb +7 -0
- data/lib/rbs/inline/writer.rb +210 -0
- data/lib/rbs/inline.rb +22 -0
- data/rbs_collection.lock.yaml +68 -0
- data/rbs_collection.yaml +17 -0
- data/sig/generated/rbs/inline/annotation_parser.rbs +222 -0
- data/sig/generated/rbs/inline/ast/annotations.rbs +185 -0
- data/sig/generated/rbs/inline/ast/declarations.rbs +116 -0
- data/sig/generated/rbs/inline/ast/members.rbs +179 -0
- data/sig/generated/rbs/inline/cli.rbs +21 -0
- data/sig/generated/rbs/inline/parser.rbs +116 -0
- data/sig/rbs/inline/annotation_parser.rbs +0 -0
- data/sig/rbs/inline/ast/comment_lines.rbs +27 -0
- data/sig/rbs/inline/ast/members.rbs +24 -0
- data/sig/rbs/inline/ast/tree.rbs +98 -0
- data/sig/rbs/inline/node_utils.rbs +7 -0
- data/sig/rbs/inline/writer.rbs +27 -0
- data/sig/rbs/inline.rbs +41 -0
- data/yard-samples/hello.rb +6 -0
- data/yard-samples/sample1.rb +26 -0
- metadata +111 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
module RBS
|
2
|
+
module Inline
|
3
|
+
module AST
|
4
|
+
class Tree
|
5
|
+
type token = [Symbol, String]
|
6
|
+
|
7
|
+
type tree = token | Tree | Types::t | MethodType | nil
|
8
|
+
|
9
|
+
attr_reader trees: Array[tree]
|
10
|
+
|
11
|
+
# Children but without `tWHITESPACE` tokens
|
12
|
+
#
|
13
|
+
attr_reader non_trivia_trees: Array[tree]
|
14
|
+
|
15
|
+
attr_reader type: Symbol
|
16
|
+
|
17
|
+
def initialize: (Symbol type) -> void
|
18
|
+
|
19
|
+
def <<: (tree) -> self
|
20
|
+
|
21
|
+
# Returns n-th token from the children
|
22
|
+
#
|
23
|
+
# Raises if the value is not a token or nil.
|
24
|
+
#
|
25
|
+
def nth_token: (Integer) -> token?
|
26
|
+
|
27
|
+
# Returns n-th token from the children
|
28
|
+
#
|
29
|
+
# Returns `nil` if the value is not a token.
|
30
|
+
#
|
31
|
+
def nth_token?: (Integer) -> token?
|
32
|
+
|
33
|
+
# Returns n-th token from the children
|
34
|
+
#
|
35
|
+
# Raises if the value is not token.
|
36
|
+
#
|
37
|
+
def nth_token!: (Integer) -> token
|
38
|
+
|
39
|
+
# Returns n-th tree from the children
|
40
|
+
#
|
41
|
+
# Raises if the value is not a tree or nil.
|
42
|
+
#
|
43
|
+
def nth_tree: (Integer) -> Tree?
|
44
|
+
|
45
|
+
# Returns n-th tree from the children
|
46
|
+
#
|
47
|
+
# Returns `nil` if the value is not a tree or nil.
|
48
|
+
#
|
49
|
+
def nth_tree?: (Integer) -> Tree?
|
50
|
+
|
51
|
+
# Returns n-th tree from the children
|
52
|
+
#
|
53
|
+
# Raises if the value is not a tree.
|
54
|
+
#
|
55
|
+
def nth_tree!: (Integer) -> Tree
|
56
|
+
|
57
|
+
# Returns n-th type from the children
|
58
|
+
#
|
59
|
+
# Raises if the value is not a tree or nil.
|
60
|
+
#
|
61
|
+
def nth_type: (Integer) -> Types::t?
|
62
|
+
|
63
|
+
# Returns n-th type from the children
|
64
|
+
#
|
65
|
+
# Returns `nil` if the value is not a type.
|
66
|
+
#
|
67
|
+
def nth_type?: (Integer) -> Types::t?
|
68
|
+
|
69
|
+
# Returns n-th type from the children
|
70
|
+
#
|
71
|
+
# Raises if the value is not a type.
|
72
|
+
#
|
73
|
+
def nth_type!: (Integer) -> Types::t
|
74
|
+
|
75
|
+
# Returns n-th method type from the children
|
76
|
+
#
|
77
|
+
# Raises if the value is not a method type or `nil`.
|
78
|
+
#
|
79
|
+
def nth_method_type: (Integer) -> MethodType?
|
80
|
+
|
81
|
+
# Returns n-th method type from the children
|
82
|
+
#
|
83
|
+
# Returns `nil` if the value is not a method type.
|
84
|
+
#
|
85
|
+
def nth_method_type?: (Integer) -> MethodType?
|
86
|
+
|
87
|
+
# Returns n-th method tree from the children
|
88
|
+
#
|
89
|
+
# Raises if the value is not a method tree.
|
90
|
+
#
|
91
|
+
def nth_method_type!: (Integer) -> MethodType
|
92
|
+
|
93
|
+
# Returns the source code associated to the tree
|
94
|
+
def to_s: () -> String
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RBS
|
2
|
+
module Inline
|
3
|
+
class Writer
|
4
|
+
attr_reader output: String
|
5
|
+
|
6
|
+
attr_reader writer: RBS::Writer
|
7
|
+
|
8
|
+
def self.write: (Array[AST::Annotations::Use], Array[AST::Declarations::t]) -> String
|
9
|
+
|
10
|
+
def initialize: (?String) -> void
|
11
|
+
|
12
|
+
def write: (Array[AST::Annotations::Use], Array[AST::Declarations::t]) -> void
|
13
|
+
|
14
|
+
def header: (*String) -> void
|
15
|
+
|
16
|
+
def translate_decl: (AST::Declarations::t) -> RBS::AST::Declarations::t?
|
17
|
+
|
18
|
+
def translate_class_decl: (AST::Declarations::ClassDecl) -> RBS::AST::Declarations::Class?
|
19
|
+
|
20
|
+
def translate_module_decl: (AST::Declarations::ModuleDecl) -> RBS::AST::Declarations::Module?
|
21
|
+
|
22
|
+
def translate_constant_decl: (AST::Declarations::ConstantDecl) -> RBS::AST::Declarations::Constant?
|
23
|
+
|
24
|
+
def translate_member: (AST::Members::t) -> Array[RBS::AST::Members::t | RBS::AST::Declarations::t]?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/sig/rbs/inline.rbs
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module RBS
|
2
|
+
module Inline
|
3
|
+
type token = [Symbol, String]
|
4
|
+
|
5
|
+
VERSION: String
|
6
|
+
|
7
|
+
module AST
|
8
|
+
module Declarations
|
9
|
+
end
|
10
|
+
|
11
|
+
module Annotations
|
12
|
+
type t = VarType
|
13
|
+
| ReturnType
|
14
|
+
| Use
|
15
|
+
| Inherits
|
16
|
+
| Generic
|
17
|
+
| ModuleSelf
|
18
|
+
| Skip
|
19
|
+
| Assertion
|
20
|
+
| Application
|
21
|
+
| RBSAnnotation
|
22
|
+
| Override
|
23
|
+
| IvarType
|
24
|
+
| Yields
|
25
|
+
| Embedded
|
26
|
+
# | Def
|
27
|
+
# | AttrReader | AttrWriter | AttrAccessor
|
28
|
+
# | Include | Extend | Prepend
|
29
|
+
# | Alias
|
30
|
+
end
|
31
|
+
|
32
|
+
module Members
|
33
|
+
type ruby = RubyDef | RubyAlias | RubyMixin | RubyAttr | RubyPublic | RubyPrivate
|
34
|
+
|
35
|
+
type rbs = RBSIvar | RBSEmbedded
|
36
|
+
|
37
|
+
type t = ruby | rbs
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Foo
|
2
|
+
# This is `Foo#foo` method
|
3
|
+
#
|
4
|
+
# @param i [Integer] Size of something
|
5
|
+
# @param j [Symbol,Integer] Something doing meaningful
|
6
|
+
# @return [String?] Returns a string or nil
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# @rbs.method (Integer, String) -> void
|
10
|
+
# | [A] () { () [self: String] -> A } -> A?
|
11
|
+
#
|
12
|
+
def foo(i, j)
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
# @rbs.inline
|
17
|
+
# attr_reader hoge: String
|
18
|
+
# attr_reader name: String?
|
19
|
+
def hoge
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class Foo
|
24
|
+
# @rbs.inline include Foo[String]
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rbs-inline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Soutaro Matsumoto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: prism
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.24.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.24.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rbs
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.5.0.pre
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.5.0.pre
|
41
|
+
description: Inline RBS type declaration.
|
42
|
+
email:
|
43
|
+
- matsumoto@soutaro.com
|
44
|
+
executables:
|
45
|
+
- rbs-inline
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- CHANGELOG.md
|
50
|
+
- CODE_OF_CONDUCT.md
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- Steepfile
|
55
|
+
- exe/rbs-inline
|
56
|
+
- lib/rbs/inline.rb
|
57
|
+
- lib/rbs/inline/annotation_parser.rb
|
58
|
+
- lib/rbs/inline/ast/annotations.rb
|
59
|
+
- lib/rbs/inline/ast/comment_lines.rb
|
60
|
+
- lib/rbs/inline/ast/declarations.rb
|
61
|
+
- lib/rbs/inline/ast/members.rb
|
62
|
+
- lib/rbs/inline/ast/tree.rb
|
63
|
+
- lib/rbs/inline/cli.rb
|
64
|
+
- lib/rbs/inline/node_utils.rb
|
65
|
+
- lib/rbs/inline/parser.rb
|
66
|
+
- lib/rbs/inline/version.rb
|
67
|
+
- lib/rbs/inline/writer.rb
|
68
|
+
- rbs_collection.lock.yaml
|
69
|
+
- rbs_collection.yaml
|
70
|
+
- sig/generated/rbs/inline/annotation_parser.rbs
|
71
|
+
- sig/generated/rbs/inline/ast/annotations.rbs
|
72
|
+
- sig/generated/rbs/inline/ast/declarations.rbs
|
73
|
+
- sig/generated/rbs/inline/ast/members.rbs
|
74
|
+
- sig/generated/rbs/inline/cli.rbs
|
75
|
+
- sig/generated/rbs/inline/parser.rbs
|
76
|
+
- sig/rbs/inline.rbs
|
77
|
+
- sig/rbs/inline/annotation_parser.rbs
|
78
|
+
- sig/rbs/inline/ast/comment_lines.rbs
|
79
|
+
- sig/rbs/inline/ast/members.rbs
|
80
|
+
- sig/rbs/inline/ast/tree.rbs
|
81
|
+
- sig/rbs/inline/node_utils.rbs
|
82
|
+
- sig/rbs/inline/writer.rbs
|
83
|
+
- yard-samples/hello.rb
|
84
|
+
- yard-samples/sample1.rb
|
85
|
+
homepage: https://github.com/soutaro/rbs-inline
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata:
|
89
|
+
homepage_uri: https://github.com/soutaro/rbs-inline
|
90
|
+
source_code_uri: https://github.com/soutaro/rbs-inline
|
91
|
+
changelog_uri: https://github.com/soutaro/rbs-inline/blob/master/CHANGELOG.md
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 3.3.0
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.5.3
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Inline RBS type declaration.
|
111
|
+
test_files: []
|