yard-sorbet 0.5.2 → 0.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abed4a7ebc07752257feab235b53a7a0162c348b3dd614fed606aa9299840115
4
- data.tar.gz: 8799257d6fa6a2f24689c3e737ed484fce741c0098c60648eed4e370273bb161
3
+ metadata.gz: ee5168e45f37fe7d16db534727b57fad2a08e05acda8298ef421589aa72f0354
4
+ data.tar.gz: ce10ba6df63c35ba4b52eb4f7d8b02878cfb01fea7424e966aad739691d1d767
5
5
  SHA512:
6
- metadata.gz: ff78cce014d6d8443ac4b00fd980c6f316e9f11b091e2a031fbe6ed2b9ffc5e68657500a4d952fa9eb7f649f914f102acc509960aa5d6c6cddbc449a86d18e66
7
- data.tar.gz: 201e32a5fb1de713569b8476c8acaa4634853d11a8538cad9770d06c9bc0fe396b900b50626f883cbd6dfe8ee8846703e91c50a4bee7a3a191d70fac66737b9d
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
- docstring.add_tag(YARD::Tags::Tag.new(:param, prop.doc, prop.types, prop.prop_name))
38
+ TagUtils.upsert_tag(docstring, 'param', prop.types, prop.prop_name, prop.doc)
38
39
  end
39
- docstring.add_tag(YARD::Tags::Tag.new(:return, '', class_ns))
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.to_raw
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, '', types, 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
@@ -4,5 +4,5 @@
4
4
  # Types are documentation
5
5
  module YARDSorbet
6
6
  # {https://rubygems.org/gems/yard-sorbet Version history}
7
- VERSION = '0.5.2'
7
+ VERSION = '0.5.3'
8
8
  end
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.2
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-07-01 00:00:00.000000000 Z
11
+ date: 2021-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler-audit