-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to write documents for binary operators such as +, -, etc. #487
Comments
The short answer is we don't support this, though you could write a small plugin to override templates and have these signatures generated. YARD tries to maintain consistency across the way it shows signatures for method names, so although some methods can be used as binary operators in the grammar, the documentation itself is still just method documentation. It's not really YARD's job to discuss the syntax of the Ruby language. We could have a separate distinction for operators, but I'm not sure it's worth it, nor is it strictly accurate. If we started showing varying signatures within the method summary, it would be visually awkward, I think. Part of the benefit of showing signatures in a consistent fashion is that users know what to expect, where to click, what information is relevant, etc. If you really want to remind users that things like +, -, etc. are binary operators, using |
Thank you. I'll use Well, expert ruby developers will know that binary operations are syntax sugar of method calls. They can find what they seek. But what about novices? |
This is an interesting question (and problem). You're right, novices might get confused by this. But they also might not. I'd love to interview some (new) Ruby users reading docs to find out what the sticking points are. Unfortunately, those users are harder to find. If you know any new users who want to get in touch with their personal feedback, I'd be super happy to listen. Personally, I'd like to think that the consistency that YARD provides will help, not hurt them. There are a lot of things documentation tools can provide, but there are also limitations. I think the signature line should detail the method and parameter names, possibly a return type, it should not detail how the method is used. I think that is better left for an example tag. |
Look at the following code:
I want
(Object) <- self + other
or so as a call-sequence, because "+" is a binary operator.But I get
(Object) +(other)
.@overload self + other
doesn't solve it. I get(Object) self(+other)
by it.How can I change the call-sequence that looks like an arithmetic binary operation?
The text was updated successfully, but these errors were encountered: