From: Tobias Peters Date: 2003-09-09T18:01:59+09:00 Subject: Re: ANN: MetaTags 1.0 On Tue, 9 Sep 2003, Ryan Pavlik wrote: > On Mon, 8 Sep 2003 21:58:17 +0900 > Tobias Peters wrote: > > > > > > I'd rather like > > method_info <<-DOC > > Create a new MyClass object giving optional defaults > > for "a" and "b". > > > > Category: constructors > > Parameters: > > * a: A: The "a" object; defaults to 5 > > * b: B > > DOC > > def initialize(a=5,b=B.new) ... end > > > > I.e. less punctuation, make your "Desc:" tag the default, get method > > name by overiding method_added > > Unfortunately there's nothing tying the method to the method_info > without telling it. Yes there is. method_added is what you need. See: >>>>>>>>test_method_added.rb>>>>>>>> METHOD_DOCS = [] class Method_Doc def initialize(data, klass) @data = data @klass = klass METHOD_DOCS << self end attr_accessor :method_name attr_reader :data, :klass end class Module def method_doc(data) @last_method_doc = Method_Doc.new(data, self); end alias pre_method_doc_method_added method_added def method_added(name) (doc = @last_method_doc) && (doc.method_name = name) pre_method_doc_method_added(name) end end class Example method_doc <<-DOC This does some serious init work DOC def initialize(a,b) @a,@b=a,b end end p METHOD_DOCS <<<<<<<<<<<] @klass info comes from Module#method_doc, @method_name info comes from Module#method_added > In a few cases, I've used this in subclasses > without any method redefinition, just to make the wordking more > appropriate. (This is used to generate various forms.) I cannot follow. Tobias