Ruby Documentation
Ruby documentation refers to the documentation generated by RDoc (http://rdoc.sourceforge.net), a program that extracts documentation from Ruby source files, both from C and Ruby files.
The documentation is stored in comments in the source files and encoded so that RDoc can easily find it. RDoc can generate output as HTML, XML, ri (Ruby information), or Windows help (chm) files.
To see the RDoc-generated HTML documentation for Ruby, go to http://www.ruby-doc.org/core. If you have Ruby documentation installed on your system, which you likely do if you followed the installation instructions earlier in the book, you can type something like the following at a shell prompt to get formatted documentation in return. Type:
ri Kernel.print
and you will get this output:
----------------------------------------------------------- Kernel#print
print(obj, ...) => nil
------------------------------------------------------------------------
Prints each object in turn to +$stdout+. If the
output field
separator (+$,+) is not +nil+, its contents will
appear between
each field. If the output record separator (+$\+) is
not +nil+, it
will be appended to the output. If no arguments are
given, prints
+$_+. Objects that aren't strings will be converted
by calling
their +to_s+ method.
print "cat", [1,2,3], 99, "\n"
$, = ", "
$\ = "\n"
print "cat", [1,2,3], 99
_produces:_
cat12399
cat, 1, 2, 3, 99Here are the RDOC formatting basics:
Paragraphs in comments become paragraphs in the documentation. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access