This is best shown with a real life example using a default attribute reader along with an explicit attribute writer which should be documented with overloads as per your comment here:
class Arc
# Center point
#
# @overload center_xy
# @return [AIXM::XY]
# @overload center_xy=(value)
# @param value [AIXM::XY]
attr_reader :center_xy
def center_xy=(value)
# do some stuff here
@center_xy = value
end
end
However, this documents the writer as follows:
#center_xy=(value) ⇒ Object
While technically correct, it should be:
#center_xy=(value) ⇒ AIXM::XY
It's of course possible to add an explicit @return to the writer docstring.
However, shouldn't the default return of the writer better be the return of the corresponding reader – given how Ruby attribute writer methods work these days?
Update: Actually, that's not true: Ruby these days always returns the parameter of the writer, so a better default for the writer return would be whatever is set for the @param (in this case AIXM::XY from @param value [AIXM::XY]).
Btw: Thanks for YARD, love the generated docs and how well they work with Dash. 🥳
This is best shown with a real life example using a default attribute reader along with an explicit attribute writer which should be documented with overloads as per your comment here:
However, this documents the writer as follows:
While technically correct, it should be:
It's of course possible to add an explicit
@returnto the writer docstring.However, shouldn't the default return of the writer better be the return of the corresponding reader – given how Ruby attribute writer methods work these days?Update: Actually, that's not true: Ruby these days always returns the parameter of the writer, so a better default for the writer return would be whatever is set for the
@param(in this caseAIXM::XYfrom@param value [AIXM::XY]).Btw: Thanks for YARD, love the generated docs and how well they work with Dash. 🥳