Whenever I install gems I see ri and rdoc follow. I know this is documentation but what is the difference between the two and how to use them?
RDoc [..] is the embedded documentation generator for the Ruby programming language. [..] RDoc is included as part of the Ruby core distribution.
RDoc also provides the engine for creating Ruby ri data files. ri is (more or less) Ruby's version of man pages, serving up API information from the command line.
To access the local RDoc for your gems, type gem server
and point your browser to http://localhost:8808
.
If the RDocs for your gems aren't installed, gem rdoc --all
will install the documentation for all of your gems.
It might seem like local documentation isn't necessary. Many developers purposefully skip installing it in favor of online documentation. However, for those of us using legacy tools like Rails 2, it can make finding the right documentation fast and easy.
RDoc
automatically generates documentation from the comments and structure of your code. https://github.com/rdoc/rdoc So think Doxygen. Use it to generate automatic documentation for code you have written.ri
is offline help files for example if you don't have internet. http://www.caliban.org/ruby/rubyguide.shtml#ri Thinkperldoc
. Use it when you have a question about a class, likeri Enumerator
should bring up
Enumerator < Object
= Includes: Enumerable (from ruby core)
(from ruby core) ------------------------------------------------------------------------------ A class which allows both internal and external iteration.
An Enumerator can be created by the following methods. * Kernel#to_enum * Kernel#enum_for * Enumerator.new
Most methods have two forms: a block form where the contents are evaluated for each item in the enumeration, and a non-block form which returns a new Enumerator wrapping the iteration.
enumerator = %w(one two three).each puts enumerator.class # => Enumerator enumerator.each_with_object("foo") do |item,obj| puts "#{obj}: #{item}" end # foo: one # foo: two # foo: three enum_with_obj = enumerator.each_with_object("foo") puts enum_with_obj.class # => Enumerator enum_with_obj.each do |item,obj| puts "#{obj: #{item}" end # foo: one # foo: two # foo: three
This allows you to chain Enumerators together........
© 2022 - 2024 — McMap. All rights reserved.
ri
is a manual reader that reads only a single format (ri
data files), and such a format is one of the formats that RDoc can generate? – Suchlike