I’m using YARD to document my project. YARD document attributes created with
attr_accessor :some_attribute
in a separate section "Instance Attribute Summary". Now I have another attribute, but with custom setter and getter
def some_other_attribute
# ...
end
def some_other_attribute= value
# ...
end
so basically my question is, how can I get YARD to document this pair of setter/getter just like attr_accessor in the previous case, and list some_other_attribute within "Instance Attribute Summary"?
As of 0.8 (which is in pre-release right now), the
@!attributedirective is the recommended way to denote that an object is an attribute. The@attr_*tags are deprecated in favour of this directive. You could also do (in 0.8.0+):To parse code that isn’t necessarily executed by Ruby. Prior to 0.8, you could just add the attr_accessor directly and then redefine the setter/getter as follows:
Ruby shouldn’t mind, except that in
ruby -wit will warn about method redefinitions. If this bugs you, you can addundef foo, foo=in there too. It’s a little messy (if you care about -w), which is why we added things like@!parseand@!attribute.