I'm using YARD to document my code. I have a method that has an optional parameter with a default value. How do I notate that the parameter is optional and has a default value?
Example:
# Squares a number
#
# @param the number to square
def square_a_number(number = 2)
number * number
end
YARD automatically figures out the default value based on the method definition. Sweedish!
For example, the following code documentation will produce the subsequent YARD doc:
# Squares a number.
#
# @param number [Integer] The number to square.
#
def square_a_number(number = 2)
number * number
end
Parameters:
number (Integer optional) (defaults to: 2)