YARD::Docstring#summary appends "." on each use
Opened this issue · 0 comments
dkubb commented
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