yard_to_rbs_inline 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/Rakefile +1 -0
- data/examples/example-converted.rb +28 -0
- data/exe/yard-to-rbs-inline +3 -5
- data/exe/yard_to_rbs_inline +6 -0
- data/lib/yard_to_rbs_inline/cli.rb +14 -2
- data/lib/yard_to_rbs_inline/version.rb +1 -1
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eda8d5f227b1e1ecacaeba2d22f44e181eb3aa13f7dcd7c51ddec960a62db61
|
4
|
+
data.tar.gz: ffffb3b3acb9dd46a24dbab9dae4318052db497ce4d8bf6fab097e248d42319f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a18d283ec8a67a3690bb87fc4db11c219e4769a8dbf4172e5baf341b6fd5be8e7283947772d1bc5aacba6ed2c8f91f2b76983369adb0f8068fca93d0279be5a
|
7
|
+
data.tar.gz: b6b4f3a71e6b1ee5a04d8a6314d7cd53b5b1ba62a070fe05d293c9883357be7382ddde9c54483c1588eb678ab0263e9da208c6435705504f05d12ac3c0fb30be
|
data/README.md
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
# yard → rbs-inline
|
2
2
|
|
3
|
-
Rewrite YARD type annotations in
|
3
|
+
Rewrite [YARD type annotations](https://yardoc.org/types.html) in your codes to [rbs-inline](https://github.com/soutaro/rbs-inline).
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
+
Install this gem with the following command.
|
8
|
+
|
7
9
|
```console
|
8
|
-
|
10
|
+
gem install yard_to_rbs_inline
|
11
|
+
```
|
9
12
|
|
13
|
+
Then, run the following command to insert rbs-inline comments to your codes.
|
14
|
+
|
15
|
+
```console
|
10
16
|
# Print rewrited code to stdout.
|
11
|
-
|
17
|
+
yard_to_rbs_inline --dry-run your-file.rb
|
12
18
|
|
13
19
|
# Overwrite files.
|
14
|
-
|
20
|
+
yard_to_rbs_inline your-file.rb
|
15
21
|
```
|
data/Rakefile
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# rbs_inline: enabled
|
2
|
+
|
3
|
+
class Code
|
4
|
+
# @return [String]
|
5
|
+
attr_reader :source #:: String
|
6
|
+
|
7
|
+
# @param source [String]
|
8
|
+
#:: (String source) -> untyped
|
9
|
+
def initialize(source)
|
10
|
+
@source = source
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param new_source [String]
|
14
|
+
# @return [Code]
|
15
|
+
#:: (String new_source) -> Code
|
16
|
+
def rewrite(new_source)
|
17
|
+
@source = new_source
|
18
|
+
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param recover [Boolean].
|
23
|
+
# @return [Array<Token>]
|
24
|
+
#:: (?recover: bool) -> Array[Token]
|
25
|
+
def tokenize(recover: false)
|
26
|
+
parser.tokenize(source, recover: recover)
|
27
|
+
end
|
28
|
+
end
|
data/exe/yard-to-rbs-inline
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
if Dir.exist?(File.join(__dir__, "..", ".git"))
|
4
|
-
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
5
|
-
end
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__)) if Dir.exist?(File.join(__dir__, "..", ".git"))
|
6
4
|
|
7
|
-
require
|
8
|
-
YardToRbsInline::Cli.start(ARGV)
|
5
|
+
require "yard_to_rbs_inline"
|
6
|
+
exit(YardToRbsInline::Cli.start(ARGV))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# rbs_inline: enabled
|
2
2
|
|
3
|
-
require
|
3
|
+
require "optparse"
|
4
4
|
|
5
5
|
module YardToRbsInline
|
6
6
|
class Cli
|
@@ -8,12 +8,24 @@ module YardToRbsInline
|
|
8
8
|
opt = OptionParser.new
|
9
9
|
dry_run = false
|
10
10
|
|
11
|
-
opt.
|
11
|
+
opt.banner = <<~STRING
|
12
|
+
Usage: yard-to-rbs-inline [options] <files ...>
|
13
|
+
|
14
|
+
STRING
|
15
|
+
|
16
|
+
opt.on("-n", "--dry-run", "Dry run") { dry_run = true }
|
12
17
|
opt.parse!(argv)
|
13
18
|
|
19
|
+
if argv.empty?
|
20
|
+
warn opt.help
|
21
|
+
return 1
|
22
|
+
end
|
23
|
+
|
14
24
|
argv.each do |file|
|
15
25
|
Converter.convert(file, dry_run: dry_run)
|
16
26
|
end
|
27
|
+
|
28
|
+
0
|
17
29
|
end
|
18
30
|
end
|
19
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard_to_rbs_inline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoya Chiba
|
@@ -24,11 +24,26 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bump
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Converter of yard to rbs-inline
|
28
42
|
email:
|
29
43
|
- tomo.asleep@gmail.com
|
30
44
|
executables:
|
31
45
|
- yard-to-rbs-inline
|
46
|
+
- yard_to_rbs_inline
|
32
47
|
extensions: []
|
33
48
|
extra_rdoc_files: []
|
34
49
|
files:
|
@@ -39,8 +54,10 @@ files:
|
|
39
54
|
- LICENSE
|
40
55
|
- README.md
|
41
56
|
- Rakefile
|
57
|
+
- examples/example-converted.rb
|
42
58
|
- examples/example.rb
|
43
59
|
- exe/yard-to-rbs-inline
|
60
|
+
- exe/yard_to_rbs_inline
|
44
61
|
- lib/yard_to_rbs_inline.rb
|
45
62
|
- lib/yard_to_rbs_inline/cli.rb
|
46
63
|
- lib/yard_to_rbs_inline/converter.rb
|