From: Greg Hauptmann Date: 2009-12-09T03:21:20+09:00 Subject: Re: how to understand Ruby code? (noting various mixins/includes) Is there a tool to assist here? thanks for the pointer to YARD - interestingly I just run across my whole rails app (which has AuthLogic as a plugin), but it did give some WARNINGS and finally an exception - I'll have a better look e.g. [warn]: in YARD::Handlers::Ruby::Legacy::ClassHandler: Undocumentable class 'base' [warn]: in file './vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema.rb':9: 9: class << base 10: attr_accessor :defining 11: alias :defining? :defining 12: 13: alias_method_chain :define, :redhillonrails_core 14: end /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/templates/default/module/html/defines.erb:2:in `erb': wrong argument type Symbol (expected Proc) (TypeError) from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/../lib/yard/templates/template.rb:225:in `erb' from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/templates/default/module/html/box_info.erb:28:in `erb' from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/../lib/yard/templates/template.rb:225:in `erb' from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/../lib/yard/templates/template.rb:306:in `render_section' from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/../lib/yard/templates/template.rb:196:in `run' from /opt/local/lib/ruby/1.8/erb.rb:743:in `each_with_index' from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/../lib/yard/templates/template.rb:191:in `each' from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/../lib/yard/templates/template.rb:191:in `each_with_index' ... 38 levels... from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/../lib/yard/cli/yardoc.rb:29:in `run' from /opt/local/lib/ruby/gems/1.8/gems/yard-0.4.0/bin/yardoc:4 from /opt/local/bin/yardoc:19: 2009/12/8 Florian Gilcher : > > On Dec 7, 2009, at 8:45 PM, Tony Arcieri wrote: > >> On Mon, Dec 7, 2009 at 4:47 PM, Greg Hauptmann < >> greg.hauptmann.ruby@gmail.com> wrote: >> >>> Just trying to make sense of the final object structure and where methods >>> resides seems to be a challenge.  The latest one I've been looking at >>> are things like AuthLogic and Paperclip which are used in the Rails >>> world. >>> >> >> I feel your pain, especially with AuthLogic.  It's very difficult to >> follow >> how methods are dispatched among a quagmire of mixins. > > > I found that YARD does a good job at finding static relationships between > classes > as well as informing you about them. It also provides a tool that draws you > a graph > out of them (yard-graph). > > For a sample: http://yardoc.org/docs/datamapper-dm-core/DataMapper/Model > (includes > 2 modules, extends another one, is defined in more then one file and defines > multiple > helper classes and modules under his namespace. > > It's not 100%, but catches most reasonable cases. For more gathering, there > is still > Kernel#set_trace_fun. I experimented with a visualization for that for > university, > but it explodes horribly quick. > > Regards, > Florian Gilcher > > -- Greg http://blog.gregnet.org/