YARD::Docstring#summary appends "." on each use #9

Open
dkubb opened this Issue Jul 23, 2009 · 0 comments

Comments

Projects
None yet
1 participant

dkubb commented Jul 23, 2009

The #summary method prepends a period each time is is used on a non-blank summary. When used more than once on a docstring this causes several trailing periods to appear at the end of the summary.

The solution would be to check the last character and only append if it is not a period. An alternative (and IMHO better) solution would be to perform the appending one time, and memoize the results, so something like:

def summary
  return @summary if defined?(@summary)
  summary = split(/\.|\r?\n\r?\n/).first || ''
  unless summmary.empty? || summary[-1, 1] == '.'
    summary += '.'
  end
  @summary = summary.freeze
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment