yard 0.9.42 → 0.9.43

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: 60d3b726173ec326d88ee6b893b7a4f83776601ad52686c3ddcf2c7dd40522ea
4
- data.tar.gz: 2d5d0b74bbb12f6c01556c5cd774876e997d777c5ec5c8dd2b5fc5763b03c250
3
+ metadata.gz: 92d411c4d39cc74df916cbac8719ebd7ac6ed1fb17b37022148f584440bda554
4
+ data.tar.gz: 9582c48d6c1949c055e22035f325abc957ec31900613f5b04307f7f27fc011a4
5
5
  SHA512:
6
- metadata.gz: af71bc2ead0fcc45dcf67c4e8da45eeeff4159c8d9b4d83aba8b23ddfe328fd57f1c75b908ae2c96566bb2d882a936ebac09729cd90f73265c321a86b5a3966b
7
- data.tar.gz: 518398b298dba0a9250434e426e14cd84642dee10d5fc4a769f11492783f7e5392933bbd451613a4f1d4b0e0cbf3b8f2541c85e9dcbb3d06c1f7ff47944231eb
6
+ metadata.gz: d566d6989e868b3bc4959037309c9c07a89608f07a39ad2719ead8765fca6ab3ae6240bfe7d56394ad47c8d75c5999d02313f6f7eaedb056a2ea584750d15cc1
7
+ data.tar.gz: 641e462842732b47a67ff95eda6cfdb0373de7b2f487ceb7aa827815c0f8201fa55639979f7df17ec4d12864de60c4cc631fc7921cc787b20a04f5493cd86033
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # main
2
2
 
3
+ # [0.9.43] - April 17th, 2026
4
+
5
+ [0.9.43]: https://github.com/lsegal/yard/compare/v0.9.42...v0.9.43
6
+
7
+ - Fix attribute registration in .rbs files (#1583)
8
+
3
9
  # [0.9.42] - April 16th, 2026
4
10
 
5
11
  [0.9.42]: https://github.com/lsegal/yard/compare/v0.9.41...v0.9.42
@@ -15,7 +15,9 @@ class YARD::Handlers::RBS::AttributeHandler < YARD::Handlers::RBS::Base
15
15
  case statement.type
16
16
  when :attr_reader
17
17
  register_reader(attr_name, yard_types, mscope)
18
+ register_existing_attribute_method(attr_name, "#{attr_name}=", :write, mscope)
18
19
  when :attr_writer
20
+ register_existing_attribute_method(attr_name, attr_name, :read, mscope)
19
21
  register_writer(attr_name, yard_types, mscope)
20
22
  when :attr_accessor
21
23
  register_reader(attr_name, yard_types, mscope)
@@ -26,18 +28,52 @@ class YARD::Handlers::RBS::AttributeHandler < YARD::Handlers::RBS::Base
26
28
  private
27
29
 
28
30
  def register_reader(name, types, scope)
29
- obj = register MethodObject.new(namespace, name, scope)
30
- if types && !obj.has_tag?(:return)
31
- obj.add_tag YARD::Tags::Tag.new(:return, '', types)
32
- end
31
+ obj = MethodObject.new(namespace, name, scope)
32
+ obj.source ||= "def #{name}\n @#{name}\nend"
33
+ obj.signature ||= "def #{name}"
34
+ obj = register(obj)
35
+ obj.docstring = "Returns the value of attribute #{name}." if obj.docstring.blank?(false)
36
+ apply_tag_types(obj, :return, types)
37
+ namespace.attributes[obj.scope][name] ||= SymbolHash[:read => nil, :write => nil]
38
+ namespace.attributes[obj.scope][name][:read] = obj
33
39
  obj
34
40
  end
35
41
 
36
42
  def register_writer(name, types, scope)
37
- obj = register MethodObject.new(namespace, "#{name}=", scope)
38
- if types && !obj.has_tag?(:param)
39
- obj.add_tag YARD::Tags::Tag.new(:param, '', types, "value")
40
- end
43
+ obj = MethodObject.new(namespace, "#{name}=", scope)
44
+ obj.parameters = [['value', nil]]
45
+ obj.source ||= "def #{name}=(value)\n @#{name} = value\nend"
46
+ obj.signature ||= "def #{name}=(value)"
47
+ obj = register(obj)
48
+ obj.docstring = "Sets the attribute #{name}\n@param value the value to set the attribute #{name} to." if obj.docstring.blank?(false)
49
+ apply_tag_types(obj, :param, types, "value")
50
+ namespace.attributes[obj.scope][name] ||= SymbolHash[:read => nil, :write => nil]
51
+ namespace.attributes[obj.scope][name][:write] = obj
41
52
  obj
42
53
  end
54
+
55
+ def register_existing_attribute_method(attr_name, meth_name, type, scope)
56
+ namespace.attributes[scope][attr_name] ||= SymbolHash[:read => nil, :write => nil]
57
+ return if namespace.attributes[scope][attr_name][type]
58
+
59
+ obj = namespace.children.find do |other|
60
+ other.name == meth_name.to_sym && other.scope == scope
61
+ end
62
+
63
+ namespace.attributes[scope][attr_name][type] = obj if obj
64
+ end
65
+
66
+ def apply_tag_types(obj, tag_name, types, tag_param_name = nil)
67
+ return unless types
68
+
69
+ tag = obj.tags(tag_name).find do |existing_tag|
70
+ existing_tag.name == tag_param_name
71
+ end
72
+
73
+ if tag
74
+ tag.types ||= types
75
+ else
76
+ obj.add_tag YARD::Tags::Tag.new(tag_name, '', types, tag_param_name)
77
+ end
78
+ end
43
79
  end
data/lib/yard/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module YARD
5
- VERSION = '0.9.42'
5
+ VERSION = '0.9.43'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.42
4
+ version: 0.9.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-16 00:00:00.000000000 Z
11
+ date: 2026-04-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  YARD is a documentation generation tool for the Ruby programming language.