Skip to content
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

Multiple methods per line swallow next line #221

Closed
derula opened this issue Apr 25, 2013 · 4 comments
Closed

Multiple methods per line swallow next line #221

derula opened this issue Apr 25, 2013 · 4 comments
Labels
Milestone

Comments

@derula
Copy link

derula commented Apr 25, 2013

I know this is a fringe case (maybe a wontfix?), but: having multiple methods in a single line leads to... interesting results. An example:

def self.test1() end; def self.test1=() end
# :call-seq:
#  apples
def self.test2() end

Expected result: all three methods are documented; test2 gets a custom call-seq.
Actual result: only test1 and test2 are documented; test2 is documented with apples (standard call-seq).

Worse example:

class Class1
  def self.test1() end; def self.test1=() end
end
class Class2
  def self.test2() end
end

Expected result: classes are documented separately
Actual result: Class2 is erroneously documented as Class1::Class2

@drbrain
Copy link
Member

drbrain commented Apr 25, 2013

Similar to how rake's desc works, RDoc attaches a comment to the next documentable item it sees.

For the first example there's no comment present above test1, so I would expect test1 and test1= to be undocumented while test2 has has the custom call-seq. If there is an implied comment above test1, then only test1 should be documented.

Having one comment apply to two methods on the same line is something that is possible to implement, but it would make an already fairly messy parser even messier. Also, it is not a type of ruby I want to encourage people to write. I don't think I will add such a feature.

For the second example, Class2 should not be inside Class1.

RDoc is not handling ; properly, so I will fix this bug.

@derula
Copy link
Author

derula commented Apr 25, 2013

Fair enough, I generally agree with the behavior you described; however in the first example, test2 doesn't get the a custom call-seq like it should. I was suggesting that this might be the same bug as in the second example. I could be wrong though.

@drbrain
Copy link
Member

drbrain commented Apr 26, 2013

Ah, if test2 doesn't get a comment that is a bug, I will fix that too, and it's probably related to the class bug you found.

@drbrain
Copy link
Member

drbrain commented Aug 17, 2013

I wasn't able to reproduce the call-seq problem after fixing the bug you found with two methods on the same line.

This was a tough one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants