From: Avi Bryant Date: 2001-03-02T18:25:20+09:00 Subject: [ruby-talk:11891] ANN: MethodInfo Just a quick hack, but I thought it might be useful: http://beta4.com/methinfo.rb This module simplistically parses ruby source files as they are loaded to extract method definitions, method code, and the first comment block (consecutive # comments or one =begin/end) before a method. It might be used in a code browser, or to automatically generate RD, HTML, or XML reference for a module (a javadoc-like system would be nice...). Usage: require 'methinfo' class Foo attr_accessor :q # print the value of x + y def bar(x, y) puts x+y end end info = Foo.method_info(:bar) p info.defn #=> "bar(x, y)" p info.params #=> ["x", "y"] p info.comment #=> "print the value of x + y" p info.source #=> "def bar(x, y)\n\tputs x+y\nend" p Foo.method_info("q=").defn #=> "attr_accessor :q"