yard
yard copied to clipboard
YARD not working on C++ sources
YARD does not successfully parse my C++ sources.
Steps to reproduce
rb_define_singleton_method(mMemoryPool, "enable", (VALUE(*)(ANYARGS))rb_memory_pool_enable, 0);
# the (VALUE(*)(ANYARGS)) cast is necessary for C++
Actual Output
No method documented.
Expected Output
Method document is generated.
Environment details:
- OS: [Mac OSX and Ubuntu 16.04]
- Ruby version (
ruby -v): [2.4.1p111] - YARD version (
yard -v): [0.9.2]
I've found https://github.com/lsegal/yard/issues/697. As it states, (METHOD) works, but (VALUE(*)(ANYARGS)) does not work.
The problem now is that we do not have METHOD macro in ruby.h.
I found that we can work around as:
rb_define_singleton_method(mMemoryPool, "enable", RUBY_METHOD_FUNC(rb_memory_pool_enable), 0);
RUBY_METHOD_FUNC(func) is defined in ruby.h.
Is the workaround sufficient for your use case? I believe that solving this with more complex parsing might not be needed and would love to avoid it if possible.
Didn't know the Ruby headers had a macro for that. We have been using our own macro for our C++ application: https://github.com/SketchUp/ruby-c-extension-examples/blob/master/Hello%20World/src/RubyUtils/RubyUtils.h#L21
That's been working for us, along with YARD now that it can handle C++ namespaces.
I'm doing some issue gardening 🌱🌿 🌷 and came upon this issue. It seems outdated, with no activity for 5 years.
By closing some old issues we reduce the list of open issues to a more manageable set. Let me know if you think this is a mistake and that the issue should stay open.
To maintainers
Open the 'Discussions' tab on the repo. That way, much of what's in issues today can be easily moved to Discussions (there will be a dedicated button on each issue, after it's enabled).