-
-
Notifications
You must be signed in to change notification settings - Fork 412
Description
I know this isn't super documented or supported, but I'm trying to figure out if I'm doing something particularly wrong.
I'm trying to add YARD comments to Google Protobuf. Taking https://github.com/protocolbuffers/protobuf/blob/main/ruby/ext/google/protobuf_c/message.c#L686 as an example, the class is dynamically generated. I'd like to use comments to force YARD to assign the method comments to an object that YARD doesn't know about yet (in this case AbstractMessage).
I've tried doing it this way:
/*
* Document-class: AbstractMessage
*/
/*
* Document-method: AbstractMessage#dup
* call-seq:
* Message.dup => new_message
*
* @return [AbstractMessage]
* Performs a shallow copy of this message and returns the new copy.
*/
static VALUE Message_dup(VALUE _self) {
// ...
}
Unfortunately, it doesn't work - YARD doesn't see this method at all. I've tried to wade into the YARD code and from what I can tell:
- YARD interprets this method as a TopLevelStatement, but the C method handler only works on BodyStatements.
- There is an OverrideCommentHandler, but it only seems to support class and module declarations.
There were other smaller crashes here because of the dynamic nature which I had to monkey patch - but I wanted to know if I was missing something obvious here. Is this not actually supported? If not, where should I be looking to add support? Add :method to OverrideCommentHandler? (That seems to require me to re-parse the comment again for @ tags and call-seq declarations?)
Or is there a way to parse these as pure "Ruby-ish" comments? There is a !@method override but not a !@class override.
Any help would be welcome.