Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ri and rdoc

Tags:

ruby

rdoc

ri

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?

like image 746
thenengah Avatar asked Sep 04 '10 20:09

thenengah


3 Answers

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.

From: http://en.wikipedia.org/wiki/RDoc

like image 60
Esselans Avatar answered Oct 23 '22 23:10

Esselans


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 --allwill 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.

like image 20
Steven Hirlston Avatar answered Oct 23 '22 23:10

Steven Hirlston


  • 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 Think perldoc. Use it when you have a question about a class, like ri 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........

like image 24
isomorphismes Avatar answered Oct 23 '22 23:10

isomorphismes