How can one document a function with a variable number of arguments in YARD?
The following makes sense because args
is an Array
inside the method, although none of the params are an Array
as such:
# this function doesn’t do anything
#
# @param [Array<Symbol>] args these arguments do something
# @return [nil]
def myfun(*args)
# ...
end
Note the *
is dropped from the param name in the comment. This is just to be consistent - args
is an Array
, but *args
is not.
A quick search shows quite a few projects using this style, including inside Yard's own .rb files (e.g. see source for initialize in Verifier class) - although no examples of this convention are given in the guide.