From: ts Date: 2002-01-05T02:20:40+09:00 Subject: [ruby-talk:30226] Re: Docstrings >>>>> "M" == Massimiliano Mirra writes: M> @@docs = {} be carefull with class variables pigeon% cat b.rb #!/usr/bin/ruby module Documentable class << self def append_features(base_class) base_class.class_eval do @@docs = {} end def base_class.doc(method, docstring = nil) if docstring @@docs[method] = docstring else @@docs[method] end end end end end if $0 == __FILE__ class Foo include Documentable def bar end doc :bar, "Very useful?" end class Bar < Foo def bar end doc :bar, "you'll have a problem with your class variable" end puts Foo.doc :bar end pigeon% pigeon% b.rb you'll have a problem with your class variable pigeon% Guy Decoux