How can I document a function with a variable number of arguments in YARD?

I have a function that takes a variable number of arguments, for example:

def myfun(*args)
  # ...
end

All arguments are of the same type ( Symbol), so right now I'm documenting the function as if there was only one argument, saying that it can take more than one, for example:

# this function doesn’t do anything
# @param [Symbol]: this argument does something, you can add more symbols
#                  if you want
def myfun(*args)
  # ...
end

Is there a built-in way to handle this case?

+4
source share
1 answer

The following makes sense because it argsis Arrayinside the method, although none of the parameters are Arrayas such:

# this function doesn’t do anything
#
# @param [Array<Symbol>] args these arguments do something
# @return [nil]
def myfun(*args)
  # ...
end

, * . - args Array, *args .

, , .rb Yard (, . Verifier) - .

+5

Source: https://habr.com/ru/post/1538312/


All Articles