lsegal / yard

YARD is a Ruby Documentation tool. The Y stands for "Yay!"
http://yardoc.org
MIT License
1.94k stars 397 forks source link

Attributes handled through custom C accessors #362

Closed pcarrier closed 12 years ago

pcarrier commented 13 years ago

Hello,

When wrapping a C structure foo, which exposes an attribute bar, one exposes this attribute by defining methods "bar" and "bar=" on the foo-wrapping Ruby class.

To that purpose, rb_definemethod() is invoked with VALUE()() and VALUE(_)(VALUE) C functions for the foo-wrapping class.

yardoc will then display methods bar() and bar=() and not an attribute bar, which is obviously an expected behaviour.

A trick with rdoc is to:

Unfortunately neither seem handled by yardoc, which won't display an attribute, nor hide the raw methods.

A similar, ideally cleaner :) solution would be much appreciated.

Pierre

pcarrier commented 13 years ago

For the record: @lsegal pcarrier fwiw it looks like the _attr thing is not supported in our version of the c parser, but thats a bug. you should open a ticket so we can add it. @lsegal though its a little more complicated than that, the parser would still ignore commented rbdefine* calls. rdoc should too, unless they changed it

lsegal commented 12 years ago

Hey Pierre, I opted for RDoc's "hack" method of placing the rb_define_attr in a /* */ comment block for now. We will be revisiting this for 0.8.0 though-- there's a good chance we will be refactoring the C parser to create a real AST and go through the handler architecture, because right now CRuby is missing a lot of things pure ruby does, like macro support and other goodies.