summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface/documentation.rb
diff options
context:
space:
mode:
authornfagerlund <nick.fagerlund@gmail.com>2011-05-26 10:32:22 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-05-26 16:08:31 -0700
commit149a12f882252150ef9d642c6cf0345306f772ee (patch)
treeef751192c0cec002f25048c490a8f5f933733258 /lib/puppet/interface/documentation.rb
parent2ebd2d9eda3c556244cda1ae62da95965a92d79b (diff)
downloadpuppet-149a12f882252150ef9d642c6cf0345306f772ee.tar.gz
puppet-149a12f882252150ef9d642c6cf0345306f772ee.tar.xz
puppet-149a12f882252150ef9d642c6cf0345306f772ee.zip
Maint: Fix ellipses for short descriptions
Previously, we were adding ellipsis to any short_description, which was misleading; they were only necessary when we were truncating in the _middle_ of a paragraph. This commit changes the behavior, and updates the tests to show when we expect ellipsis. Paired-with: Matt Robinson <matt@puppetlabs.com>
Diffstat (limited to 'lib/puppet/interface/documentation.rb')
-rw-r--r--lib/puppet/interface/documentation.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb
index 48e9a8b1a..fcaec2568 100644
--- a/lib/puppet/interface/documentation.rb
+++ b/lib/puppet/interface/documentation.rb
@@ -77,8 +77,10 @@ class Puppet::Interface
if @short_description.nil? then
return nil if @description.nil?
lines = @description.split("\n")
- grab = [5, lines.index('') || 5].min
+ first_paragraph_break = lines.index('') || 5
+ grab = [5, first_paragraph_break].min
@short_description = lines[0, grab].join("\n")
+ @short_description += ' [...]' if (grab < lines.length and first_paragraph_break >= 5)
end
@short_description
end