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

Parser goes weird on complex regexp in code #1023

Closed
zverok opened this issue Sep 17, 2016 · 2 comments
Closed

Parser goes weird on complex regexp in code #1023

zverok opened this issue Sep 17, 2016 · 2 comments
Labels

Comments

@zverok
Copy link

zverok commented Sep 17, 2016

Steps to reproduce

Minimal code I was able to create for reproducing the issue:

class BaseWrapper
  def description(text)
    @object.description =
      text
      .gsub(/^[ \t]+/, '')      # remove spaces at a beginning of each line
      .gsub(/\A\n|\n\s*\Z/, '')
  end

  class PostProcessProxy
  end
end

What's going on after this is instead of PostProcessProxy there is ostProcessProxy in docs (and all the other entity names after problematic method is screwed this or that way).

Specifically, problem is created by those two lines:

      .gsub(/^[ \t]+/, '')      # remove spaces at a beginning of each line
      .gsub(/\A\n|\n\s*\Z/, '')

If I'll remove the second with complicated regexp -- everything becomes ok. If I remove the comment from the first of them -- everything becomes ok. But in current state of those lines everything is screwed up.

Environment details:

  • OS: Ubuntu 14.04
  • Ruby version (ruby -v): ruby 2.2.4p230 (2015-12-16 revision 53155) [i686-linux]
  • YARD version (yard -v): yard 0.9.5
@lsegal lsegal added the Bug label Sep 25, 2016
@iarkhanhelsky
Copy link

There is no problem with regex. Less code to reproduce same issue:

class BreakParser
  def break_parser
    obj # This comment breaks all.
      .bar
  end
end

class AffectedClass
end

calling yard --list will produce:

yard/t.rb:1: BreakParser
yard/t.rb:2: BreakParser#break_parser
yard/t.rb:8: ffectedClass

No matter how many methods after break_parser will be inserted in BreakParser class. All of them will be fine. Only next class will be affected.

The problem in AstNode#source_range it maps to"ffectedClass " (note trailing space) instead of "AffectedClass".

Issue causes totally unreadable documentation in more complex examples.

@lsegal
Copy link
Owner

lsegal commented Jul 6, 2017

Thanks for reporting-- sorry this took so long to track down!

lsegal added a commit that referenced this issue Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants