Search code examples
rubyyard

YARD documentation for a method that returns a class


I need to tag the @return type of a method that returns a class instead of an instance. Example:

# @return [String]  # This implies that the return type is a String object
def string_class
  String            # The method actually returns the String class itself
end

Does YARD have a standard for this? My first guess was @return [Class<String>] but I haven't been able to find documentation for anything like it.


Solution

  • According to the YARD team themselves, the preferred way to document the provided example is Class<String>. Reference: https://github.com/lsegal/yard/issues/1109