yard-sorbet 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yard-sorbet/handlers/struct_class_handler.rb +4 -4
- data/lib/yard-sorbet/tag_utils.rb +14 -11
- data/lib/yard-sorbet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee5168e45f37fe7d16db534727b57fad2a08e05acda8298ef421589aa72f0354
|
4
|
+
data.tar.gz: ce10ba6df63c35ba4b52eb4f7d8b02878cfb01fea7424e966aad739691d1d767
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faa0b506388d501f6567ddfd08144185b1e761a1d4d4cfec12e3256f3985f626ddbc2da1423b37896fbe132a1e729a3c44b995b957eb0391aa48ded9519978d4
|
7
|
+
data.tar.gz: 2afbc9875afecab271abccfd12b5023c3e7db429f23f689fdbed18ed2e0fd7f3b51137ee86b649bb501ea921c469774e2096887d1d063599ae72939951b2f719
|
@@ -33,12 +33,12 @@ module YARDSorbet
|
|
33
33
|
# There is a chance that there is a custom initializer, so make sure we steal the existing docstring
|
34
34
|
# and source
|
35
35
|
docstring, directives = Directives.extract_directives(object.docstring)
|
36
|
+
object.tags.each { |tag| docstring.add_tag(tag) }
|
36
37
|
props.each do |prop|
|
37
|
-
|
38
|
+
TagUtils.upsert_tag(docstring, 'param', prop.types, prop.prop_name, prop.doc)
|
38
39
|
end
|
39
|
-
|
40
|
+
TagUtils.upsert_tag(docstring, 'return', ['void'])
|
40
41
|
decorate_t_struct_init(object, props, docstring, directives)
|
41
|
-
register(object)
|
42
42
|
end
|
43
43
|
|
44
44
|
sig do
|
@@ -54,7 +54,7 @@ module YARDSorbet
|
|
54
54
|
object.parameters = to_object_parameters(props)
|
55
55
|
# The "source" of our constructor is the field declarations
|
56
56
|
object.source ||= props.map(&:source).join("\n")
|
57
|
-
object.docstring = docstring
|
57
|
+
object.docstring = docstring
|
58
58
|
Directives.add_directives(object.docstring, directives)
|
59
59
|
end
|
60
60
|
|
@@ -6,16 +6,26 @@ module YARDSorbet
|
|
6
6
|
module TagUtils
|
7
7
|
extend T::Sig
|
8
8
|
|
9
|
+
# @return the tag with the matching `tag_name` and `name`, or `nil`
|
10
|
+
sig do
|
11
|
+
params(docstring: YARD::Docstring, tag_name: String, name: T.nilable(String))
|
12
|
+
.returns(T.nilable(YARD::Tags::Tag))
|
13
|
+
end
|
14
|
+
def self.find_tag(docstring, tag_name, name)
|
15
|
+
docstring.tags.find { |t| t.tag_name == tag_name && t.name == name }
|
16
|
+
end
|
17
|
+
|
9
18
|
# Create or update a `YARD` tag with type information
|
10
19
|
sig do
|
11
20
|
params(
|
12
21
|
docstring: YARD::Docstring,
|
13
22
|
tag_name: String,
|
14
23
|
types: T.nilable(T::Array[String]),
|
15
|
-
name: T.nilable(String)
|
24
|
+
name: T.nilable(String),
|
25
|
+
text: String
|
16
26
|
).void
|
17
27
|
end
|
18
|
-
def self.upsert_tag(docstring, tag_name, types = nil, name = nil)
|
28
|
+
def self.upsert_tag(docstring, tag_name, types = nil, name = nil, text = '')
|
19
29
|
tag = find_tag(docstring, tag_name, name)
|
20
30
|
if tag
|
21
31
|
return unless types
|
@@ -24,18 +34,11 @@ module YARDSorbet
|
|
24
34
|
docstring.delete_tag_if { |t| t == tag }
|
25
35
|
# overwrite any existing type annotation (sigs should win)
|
26
36
|
tag.types = types
|
37
|
+
tag.text = text unless text.empty?
|
27
38
|
else
|
28
|
-
tag = YARD::Tags::Tag.new(tag_name,
|
39
|
+
tag = YARD::Tags::Tag.new(tag_name, text, types, name)
|
29
40
|
end
|
30
41
|
docstring.add_tag(tag)
|
31
42
|
end
|
32
|
-
|
33
|
-
sig do
|
34
|
-
params(docstring: YARD::Docstring, tag_name: String, name: T.nilable(String))
|
35
|
-
.returns(T.nilable(YARD::Tags::Tag))
|
36
|
-
end
|
37
|
-
private_class_method def self.find_tag(docstring, tag_name, name)
|
38
|
-
docstring.tags.find { |t| t.tag_name == tag_name && t.name == name }
|
39
|
-
end
|
40
43
|
end
|
41
44
|
end
|
data/lib/yard-sorbet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Douglas Eichelberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler-audit
|