Rdoc Hooks!

Hello all !

Not so long ago, I posted a question about hooks in rdoc. It appeared
that there are none, and that I was welcome to create some. So I did.
The attached patch (against 1.8.5) does the job for me.

Here is the principle: the --hook option allows rdoc to require some
files. The files should contain statements of the like

RDoc::Hook.hook(/def_delegators/) do |name, args, comment, context, mod|
return unless mod.document_self
to = args.shift
for a in args
meth = RDoc::Alias.new("", a, “#{to}.#{a}”, comment)
context.add_alias(meth)
end
end

This code declares a hook for things like

A nice comment

def_delegators :@some_stuff, :some_method, :some_other_method

The block is called with

name = “def_delegators”
args = ["@some_stuff", “some_method”, “some_other_method”]
comment = “# A nice comment”
context = ??? # An object representing the class/module currently
processed
mod = ??? # We’re interested basically only in the document_self
attribute.

This syntax should be pretty flexible for all meta-programming
purposes. I did my best to keep the modifications to the code as little
as possible, it really shouldn’t break anything.

It would be cool if some people could test this code. I would then
forward the patch to ruby-code.

Thanks !

Vince

On Nov 26, 2006, at 1346 , Vincent F. wrote:

Not so long ago, I posted a question about hooks in rdoc. It
appeared
that there are none, and that I was welcome to create some. So I did.
The attached patch (against 1.8.5) does the job for me.

Please post this to the rdoc tracker on rubyforge.

It will only get lost here.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com