diff options
author | nfagerlund <nick.fagerlund@gmail.com> | 2011-05-26 10:32:22 -0700 |
---|---|---|
committer | nfagerlund <nick.fagerlund@gmail.com> | 2011-05-26 11:12:06 -0700 |
commit | 996dc076e9ca61613f80fc79f0ffe667b14d1ebb (patch) | |
tree | 162867950f0fb2379de1186dbe3afb145f710279 /lib/puppet | |
parent | 6a1b6e0656c6b3939e48bcd2f558deb343bddb7b (diff) | |
download | puppet-996dc076e9ca61613f80fc79f0ffe667b14d1ebb.tar.gz puppet-996dc076e9ca61613f80fc79f0ffe667b14d1ebb.tar.xz puppet-996dc076e9ca61613f80fc79f0ffe667b14d1ebb.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')
-rw-r--r-- | lib/puppet/interface/documentation.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index aedcc1c24..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 - @short_description = lines[0, grab].join("\n") + ' [...]' + 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 |