Reputation: 281
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.
Upvotes: 6
Views: 1410
Reputation: 281
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
Upvotes: 8
Reputation: 28305
In ruby, (almost) everything is an object, including classes themselves!
String.class == Class
(There is a class called Class
, of which String
is an instance.) Therefore, you can document the method like this:
# @return [Class]
def string_class
String
end
Upvotes: 2