I have a class that uses the def_delegators
method from the Forwardable module. I haven't found a way to get Yardoc to output documentation for it. I've tried using a macro but it won't output anything for these particular methods (everything else in the file is fine, and there are no errors), and I've several def_delegators
of differing lengths.
e.g.
class A
extend Forwardable
# other code…
# @!macro
# @see Array#$1
# @see Array#$2
# @see Array#$3
def_delegators :@xs, :size, :<<, :blah # …
Is there a gem, or a way to do this that means I can avoid trying to write a Yard extension?
After more experimentation I found that this worked quite well:
# @!method size
# @see Array#size
# @!method <<
# @see Array#<<
# @!method blah
# @see Array#blah
def_delegators :@xs, :size, :<<, :blah # …
There is quite possibly a way to do this in one or two lines, but compared to the work writing an extension I find this very acceptable.
I've just found this will link to the delegated methods' documentation better:
# @!method size
# @return (see Array#size)
This would take the already documented return value from the Array#size method. I expect the other tags will do this too. It's still quite verbose, but acceptable.