$_doc = [] class Module attr :docs # The idea here is to have dynamic docs. # # doc "X does such and such" # doc "it is very powerful" # class X # doc "f does such and such" # doc "it is where the power lies" # def f # ... # end # end # # One of the great things about doc, is that # it can be used to "inherit" documentation. def doc(str) $_doc << string end def method_added(meth) @docs ||= {} @docs[self, meth] << $_doc $_doc.clear nil end end