-
Notifications
You must be signed in to change notification settings - Fork 172
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
incorrect doc reference when methods are too close #2786
Comments
Thank you for creating the issue! The mistake comes from this line. Essentially, we wanted to ensure that we didn't miss documentation for projects that add comments to their declaration with a blank line in between. Like this: # Documentation for Foo
class Foo
# Documentation for bar
def bar
end
end However, our check is a bit naive. If there's no comment immediately above the declaration, we check if there's a comment in the line above that one, without checking if the contents of the line in between is another declaration, which leads to the bug. We should only consider comments as part of the documentation if the line in between is blank. |
So, you mean whether a method will have a document, which depends on whether there is a comment above it. The comment can be above the method within one line break. So, I think the solution could be to check whether the code above the method has |
Essentially, this line has to change to be start_line -= 1 unless @comments_by_line.key?(start_line) || !source[start_line - 1].empty? We don't have direct access to the source, but the parse result has a handle to it somewhere. |
@vinistock Thanks, that's clear enough! I am gonna create a PR for this issue. |
@vinistock, I tried out what you said. I didn't find a way to use parse_result as you do in the pseudo-code.
|
Good idea, I think deleting the comments from the hash is a good strategy 👍. |
While developing PR #2733, I accidentally found this very tiny bug! But there may be a different way to look at it. Anyway, just bring it up!
Description
If we have two methods like the example, the
bar
will share the doc fromfoo
.But if we add one line between the two methods, the
bar
will act normally!Additional Info
Here is where I found it over the conversation on PR #2733
The text was updated successfully, but these errors were encountered: