I am interested in documenting my code, the majority of which are scripts where I do not create new classes.
From reading the YARD docs, and trying to actually implement some YARD documentation, it seems that you declare your YARD tags within a defined class. I have successfully used YARD when I create a class or add new methods to a class, as in the sample code below, and I have also been able to document simple things using YARD tags like @author and @example.
#!/usr/bin/env ruby -wKU
## a YARD test
class String
# Prints a string using two supplied strings
#
# @param str1 [String] A string to print
# @param str2 [String] A string to print
# @return [String] A printed string
def yardTest(str1, str2)
p sprintf("Hello, %s, %s", str1, str2)
end
end

My questions are:
- Is there a way to use YARD tags to document code (especially methods) without defining classes?
- If not, what solutions exist other than putting extensive comments in my code?