7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/yard/handlers/ruby/bit_struct_handler.rb', line 7
def process
name = statement.parameters[0].jump(:tstring_content, :ident).source
bitlength = statement.parameters[1].jump(:tstring_content, :ident).source
type = case statement.method_name(true)
when :unsigned, :signed
"Fixnum"
when :string
"String"
else
"Object"
end
reader = YARD::CodeObjects::MethodObject.new(namespace, name)
reader.dynamic = true
register(reader)
if reader.docstring.blank?
doc = "Value of the `#{name}` field\n"
reader.docstring.replace(doc)
end
writer = reader.dup
writer.name = "#{name}="
unless reader.docstring.has_tag?(:return)
reader.docstring.add_tag(
YARD::Tags::Tag.new(:return, "#{bitlength}-bit #{statement.method_name(true)} value", type)
)
end
namespace.attributes[scope][name] = SymbolHash[:read => reader, :write => writer]
end
|