0

Say I have a method like this

# @return [Integer] number of arguments provided to the method
def return_number_of_arguments(*args)
  return args.length
end

How could I add @param documentation?

Ideas I have:

@param [*Object] any objects

but I couldn't find anything in the yard docs

max pleaner
  • 26,189
  • 9
  • 66
  • 118

1 Answers1

1

Since args will be splatted to an Array within the method body, I'd write

# @param args [Array] elements to count
# @return [Integer] number of arguments provided to the method
def return_number_of_arguments(*args)
  return args.length
end
Carsten
  • 531
  • 4
  • 15
  • I don't see what the point of this would be. For example if a method takes any number of successive strings arguments, it would be counterproductive to document it as taking an array, right? – max pleaner Aug 18 '16 at 05:34
  • @maxpleaner I see your point. I'm looking at how the passed argument will be treated internally – not necessarily the best POV for API docs. Apparently the `@overload` tag exists for that, see http://stackoverflow.com/questions/30416185/best-way-to-document-splatted-parameter-with-yard?rq=1 – Carsten Sep 13 '16 at 08:38