# Rdoc Hooks!

**URL:** <https://www.ruby-forum.com/t/rdoc-hooks/77318>\
**Category:** Ruby\
**Created:** [November 26, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/rdoc-hooks/77318 "2006-11-26T22:47:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnuvince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/82dd89/32.png) [@gnuvince](https://www.ruby-forum.com/u/gnuvince)\
**Post date:** [November 26, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/rdoc-hooks/77318/1 "2006-11-26T22:47:45Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![gnuvince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/82dd89/32.png) [@gnuvince](https://www.ruby-forum.com/u/gnuvince)\
**Post date:** [November 28, 2006, 12:08pm UTC](https://www.ruby-forum.com/t/rdoc-hooks/77318/2 "2006-11-28T12:08:40Z")

</div>

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. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
