Just document the methods in the script as you would for any class- or module-based methods. YARD should document them as part of the "Top Level Namespace".
The following modification to your script just works, removing the class String
wrapper:
#!/usr/bin/env ruby -wKU
# 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
You might also want to consider documenting the API of the script for its users, which is for a different purpose and audience of course.
Also do consider separating the command-line interface from the methods that perform actions - in which case you will end up creating suitable modules and classes. This is a natural pattern when making anything remotely complicated, and would allow you to share your logic between scripts in future, or perhaps into things that are not invoked from the command line. You could take a look at the thor
gem - it is a framework for creating command-line scripts, and includes examples of command-line interfaces that follow a nice pattern of abstraction. Thor has support for easily including standard practice usage and help in a command-line script.