Search code examples
rubyenumerableyard

How to use Yard to document enumerable type and the types that they contain?


Using the ruby Yard doc tool I can write

# @param bar [String]
def foo(bar)
end

however if the parameter is an enumerable

# @param bar [Enumerable[String]]
def foo(bar)
end

Is the above the correct way or not?


Solution

  • Do it like this:

    # @param [Enumerable<String>] bar
    def foo(bar)
    end
    

    Reference: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md#Declaring_Types