yard-sig 0.2.0 → 0.2.2
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/CHANGELOG.md +11 -0
- data/lib/yard-sig/sig.rb +23 -4
- data/lib/yard-sig/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5f0199099b90174466cf9c16956ad076ebef5c79a371eb28bd96e9f7ead2195
|
4
|
+
data.tar.gz: 1760b6025f143dc79fdb34cf48f8f4cc2779047fbfe5203e74bf5a633e4b1eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18333b749e23f6da2ab2f6b946e8c1fce265fd1fa9c4ebbd6b108d93dd8e4226b0ef513b18e1ceafa151511a09f9e6161bc92a1067fd826fc68e4440da81de1a
|
7
|
+
data.tar.gz: 5eb6cfcc8a229cd0550bd447db8c9397578ef51f67c178d739f22af3e008d7894ed3dc85bdeedb0f888da46d0fa0cc4dbdfe32a615cca3a4709a1d08201cd7b7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.2] - 2024-01-15
|
4
|
+
|
5
|
+
- fix: support keyword arguments
|
6
|
+
|
7
|
+
## [0.2.1] - 2024-01-08
|
8
|
+
|
9
|
+
- fix: use the hash specific syntax
|
10
|
+
- fix: support optional types
|
11
|
+
- ci: CI against ruby 3.3
|
12
|
+
- ci: upgrade actions/checkout
|
13
|
+
|
3
14
|
## [0.2.0] - 2023-07-07
|
4
15
|
|
5
16
|
- feat: support [AaronC81/sord](https://github.com/AaronC81/sord)
|
data/lib/yard-sig/sig.rb
CHANGED
@@ -25,12 +25,16 @@ module YardSig
|
|
25
25
|
@rbs_method_type ||= RBS::Parser.parse_method_type(@source)
|
26
26
|
end
|
27
27
|
|
28
|
-
def rbs_type_to_tags(rbs_type, within_block: false)
|
28
|
+
def rbs_type_to_tags(rbs_type, within_block: false) # rubocop:disable Metrics/AbcSize
|
29
29
|
positionals = rbs_type.required_positionals + rbs_type.optional_positionals
|
30
30
|
|
31
31
|
tags = positionals.map.with_index do |param, i|
|
32
32
|
build_param_tag(param, :positionals, pos: i, within_block: within_block)
|
33
33
|
end
|
34
|
+
|
35
|
+
tags += rbs_type.required_keywords.map { |name, type| build_param_tag_for_keyword(name, type) }
|
36
|
+
tags += rbs_type.optional_keywords.map { |name, type| build_param_tag_for_keyword(name, type) }
|
37
|
+
|
34
38
|
tags << build_param_tag(rbs_type.rest_positionals, :rest, within_block: within_block)
|
35
39
|
tags << build_param_tag(rbs_type.rest_keywords, :keyrest, within_block: within_block)
|
36
40
|
tags << build_return_tag(rbs_type.return_type, within_block: within_block)
|
@@ -50,12 +54,19 @@ module YardSig
|
|
50
54
|
if kind == :rest
|
51
55
|
yard_types = "Array<#{yard_types}>"
|
52
56
|
elsif kind == :keyrest
|
53
|
-
yard_types = "Hash
|
57
|
+
yard_types = "Hash{Symbol => #{yard_types}}"
|
54
58
|
end
|
55
59
|
|
56
60
|
YARD::Tags::Tag.new(tag_name, "", yard_types, name)
|
57
61
|
end
|
58
62
|
|
63
|
+
def build_param_tag_for_keyword(name, type)
|
64
|
+
yard_types = to_yard_type(type.type)
|
65
|
+
return unless yard_types
|
66
|
+
|
67
|
+
YARD::Tags::Tag.new(:param, "", yard_types, name.to_s)
|
68
|
+
end
|
69
|
+
|
59
70
|
def build_return_tag(type, within_block: false)
|
60
71
|
return unless type
|
61
72
|
|
@@ -81,9 +92,17 @@ module YardSig
|
|
81
92
|
"Boolean"
|
82
93
|
when RBS::Types::Bases::Instance
|
83
94
|
@namespace.to_s
|
95
|
+
when RBS::Types::Optional
|
96
|
+
"#{to_yard_type(type.type)}, nil"
|
84
97
|
when RBS::Types::ClassInstance
|
85
|
-
args = type.args.map { |t| to_yard_type(t) }
|
86
|
-
args.empty?
|
98
|
+
args = type.args.map { |t| to_yard_type(t) }
|
99
|
+
if args.empty?
|
100
|
+
type.to_s
|
101
|
+
elsif type.name.name == :Hash
|
102
|
+
"#{type.name}{#{args[0]} => #{args[1]}}"
|
103
|
+
else
|
104
|
+
"#{type.name}<#{args.join(", ")}>"
|
105
|
+
end
|
87
106
|
else
|
88
107
|
type.to_s
|
89
108
|
end
|
data/lib/yard-sig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-sig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takumi Shotoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -63,8 +63,8 @@ licenses:
|
|
63
63
|
- MIT
|
64
64
|
metadata:
|
65
65
|
homepage_uri: https://github.com/sinsoku/yard-sig
|
66
|
-
source_code_uri: https://github.com/sinsoku/yard-sig/blob/v0.2.
|
67
|
-
changelog_uri: https://github.com/sinsoku/yard-sig/tree/v0.2.
|
66
|
+
source_code_uri: https://github.com/sinsoku/yard-sig/blob/v0.2.2/CHANGELOG.md
|
67
|
+
changelog_uri: https://github.com/sinsoku/yard-sig/tree/v0.2.2
|
68
68
|
post_install_message:
|
69
69
|
rdoc_options: []
|
70
70
|
require_paths:
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.6.0.dev
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: A YARD plugin for writing documentations with RBS syntax
|