From: Dave Thomas Date: 2003-04-25T09:13:34+09:00 Subject: Re: ASCII class inheritance tree generator Simon Vandemoortele wrote: aphviz.org and *graphr* (see RAA) this certainly seems within > reach. I even saw a one year old thread about possible inclusion in > *rdoc* (see RAA) but nothing seems to have come of it ... RDoc has done this for a while now. The attached is something I knocked this morning during the first round of discussions: it uses dot as you describe. Run with no parameter to get the basic classes, and with -errors to get the error hierarchy: ruby classes.rb [-errors] >classes.dot dot -Tpng classes.dot >classes.png Cheers Dave - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cl = [] ObjectSpace.each_object(Module) do |c| cl << c unless c.to_s =~ /^Errno::/ end puts "digraph Ruby {" puts " rankdir=LR;" if ARGV[0] == "-errors" cl.each do |c| if c.kind_of?(Class) && (c <= Exception)# && c.superclass != Object puts %{ "#{c.name}" -> "#{c.superclass.name}";} if c.superclass c.included_modules.each do |m| puts %{ "#{m.name}" [ fontcolor=blue, color=blue ];} puts %{ "#{c.name}" -> "#{m.name}" [ color=blue ] ;} unless m == Kernel end end end else cl.each do |c| if c.kind_of?(Class) && !(c <= Exception) && c.superclass != Object puts %{ "#{c.name}" -> "#{c.superclass.name}";} if c.superclass end c.included_modules.each do |m| puts %{ "#{m.name}" [ fontcolor=blue, color=blue ];} puts %{ "#{c.name}" -> "#{m.name}" [ color=blue ] ;} unless m == Kernel end end end puts "}"