From: Sam Roberts Date: 2004-04-26T10:54:06+09:00 Subject: Re: rdoc - can I choose which methods are "attributes"? Quoteing vjoel@PATH.Berkeley.EDU, on Mon, Apr 26, 2004 at 06:19:37AM +0900: > Sam Roberts wrote: > >I thought I saw discussion about this once, but I don't see anything in > >the current rdoc docs (http://www.ruby-doc.org/stdlib/). > > > >Treating methods as attrs if they were defined with attr, attr_reader, > >etc. seems to break the whole point of uniform access, its just > >an implmentation technique. > > > >The defaults are often great, but is there any way, say a "# > >:attr(r,w):" comment, that I can use to get some of my methods to show > >up in the "Attributes" section of the docs? > > This isn't exactly what you're looking for, but maybe it helps. > > The rdoc help says: > > --accessor, -A accessorname[,..] > comma separated list of additional class methods > that should be treated like 'attr_reader' and > friends. Option may be repeated. Each accessorname > may have '=text' appended, in which case that text > appears where the r/w/rw appears for normal accessor > > So for example if you have > > class Person > string_attribute :name > end I guess I could abuse this mechanism to do something like: ri --accessor an_attr_r=r class Class def an_attr_r(*args) end end class Foo def group @foo * 1 end an_attr_r :group end I don't know if this would work, exactly, maybe this is the wrong way to define an_attr_r, but even if it did work, its a pretty strikingly cumbersome way to say that Foo#group should show up in the Attribute section as "group [r]"! Sam